Module Name: src
Committed By: christos
Date: Tue Sep 27 01:40:32 UTC 2011
Modified Files:
src/sys/sys: dirent.h extattr.h mqueue.h param.h syslimits.h xattr.h
Log Message:
Introduce KERNEL_NAME_MAX = 255, and bump NAME_MAX to 511. This makes
NAME_MAX match MAXNAMLEN, while at the same time does not allow names
to exceed KERNEL_NAME_MAX (enforced in vfs_lookup) so that binaries
don't break.
To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/sys/dirent.h
cvs rdiff -u -r1.7 -r1.8 src/sys/sys/extattr.h
cvs rdiff -u -r1.13 -r1.14 src/sys/sys/mqueue.h
cvs rdiff -u -r1.393 -r1.394 src/sys/sys/param.h
cvs rdiff -u -r1.24 -r1.25 src/sys/sys/syslimits.h
cvs rdiff -u -r1.4 -r1.5 src/sys/sys/xattr.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/sys/dirent.h
diff -u src/sys/sys/dirent.h:1.27 src/sys/sys/dirent.h:1.28
--- src/sys/sys/dirent.h:1.27 Tue Aug 9 16:05:04 2011
+++ src/sys/sys/dirent.h Mon Sep 26 21:40:32 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dirent.h,v 1.27 2011/08/09 20:05:04 dholland Exp $ */
+/* $NetBSD: dirent.h,v 1.28 2011/09/27 01:40:32 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -52,7 +52,7 @@ struct dirent {
uint16_t d_namlen; /* length of string in d_name */
uint8_t d_type; /* file type, see below */
#if defined(_NETBSD_SOURCE)
-#define MAXNAMLEN 511
+#define MAXNAMLEN 511 /* must be kept in sync with NAME_MAX */
char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */
#else
char d_name[511 + 1]; /* name must be no longer than this */
Index: src/sys/sys/extattr.h
diff -u src/sys/sys/extattr.h:1.7 src/sys/sys/extattr.h:1.8
--- src/sys/sys/extattr.h:1.7 Wed Aug 3 00:11:17 2011
+++ src/sys/sys/extattr.h Mon Sep 26 21:40:32 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: extattr.h,v 1.7 2011/08/03 04:11:17 manu Exp $ */
+/* $NetBSD: extattr.h,v 1.8 2011/09/27 01:40:32 christos Exp $ */
/*-
* Copyright (c) 1999-2001 Robert N. M. Watson
@@ -52,12 +52,12 @@
#ifdef _KERNEL
-#include <sys/syslimits.h>
+#include <sys/param.h>
/* VOP_LISTEXTATTR flags */
#define EXTATTR_LIST_LENPREFIX 1 /* names with length prefix */
-#define EXTATTR_MAXNAMELEN NAME_MAX
+#define EXTATTR_MAXNAMELEN KERNEL_NAME_MAX
struct lwp;
struct vnode;
int extattr_check_cred(struct vnode *, int, kauth_cred_t,
Index: src/sys/sys/mqueue.h
diff -u src/sys/sys/mqueue.h:1.13 src/sys/sys/mqueue.h:1.14
--- src/sys/sys/mqueue.h:1.13 Sun Apr 24 16:17:53 2011
+++ src/sys/sys/mqueue.h Mon Sep 26 21:40:32 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: mqueue.h,v 1.13 2011/04/24 20:17:53 rmind Exp $ */
+/* $NetBSD: mqueue.h,v 1.14 2011/09/27 01:40:32 christos Exp $ */
/*
* Copyright (c) 2007-2009 Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -50,6 +50,7 @@ struct mq_attr {
#include <sys/queue.h>
#include <sys/selinfo.h>
#include <sys/types.h>
+#include <sys/param.h>
/*
* Flags below are used in mq_flags for internal purposes.
@@ -62,7 +63,7 @@ struct mq_attr {
#define MQ_RECEIVE 0x20000000
/* Maximal length of mqueue name */
-#define MQ_NAMELEN (NAME_MAX + 1)
+#define MQ_NAMELEN (KERNEL_NAME_MAX + 1)
/* Default size of the message */
#define MQ_DEF_MSGSIZE 1024
Index: src/sys/sys/param.h
diff -u src/sys/sys/param.h:1.393 src/sys/sys/param.h:1.394
--- src/sys/sys/param.h:1.393 Fri Sep 23 10:47:41 2011
+++ src/sys/sys/param.h Mon Sep 26 21:40:32 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.393 2011/09/23 14:47:41 christos Exp $ */
+/* $NetBSD: param.h,v 1.394 2011/09/27 01:40:32 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@@ -323,6 +323,15 @@
#define MAXPATHLEN PATH_MAX
#define MAXSYMLINKS 32
+/*
+ * This is the maximum individual filename component length enforced by
+ * namei. Filesystems cannot exceed this limit. The upper bound for that
+ * limit is NAME_MAX. We don't bump it for now, for compatibility with
+ * old binaries during the time where MAXPATHLEN was 511 and NAME_MAX was
+ * 255
+ */
+#define KERNEL_NAME_MAX 255
+
/* Bit map related macros. */
#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
Index: src/sys/sys/syslimits.h
diff -u src/sys/sys/syslimits.h:1.24 src/sys/sys/syslimits.h:1.25
--- src/sys/sys/syslimits.h:1.24 Mon Feb 25 12:29:13 2008
+++ src/sys/sys/syslimits.h Mon Sep 26 21:40:32 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: syslimits.h,v 1.24 2008/02/25 17:29:13 ad Exp $ */
+/* $NetBSD: syslimits.h,v 1.25 2011/09/27 01:40:32 christos Exp $ */
/*
* Copyright (c) 1988, 1993
@@ -46,7 +46,8 @@
#define LINK_MAX 32767 /* max file link count */
#define MAX_CANON 255 /* max bytes in term canon input line */
#define MAX_INPUT 255 /* max bytes in terminal input */
-#define NAME_MAX 255 /* max bytes in a file name */
+#define NAME_MAX 511 /* max bytes in a file name, must be
+ /* kept in sync with MAXPATHLEN */
#define NGROUPS_MAX 16 /* max supplemental group id's */
#define UID_MAX 2147483647U /* max value for a uid_t (2^31-2) */
#ifndef OPEN_MAX
Index: src/sys/sys/xattr.h
diff -u src/sys/sys/xattr.h:1.4 src/sys/sys/xattr.h:1.5
--- src/sys/sys/xattr.h:1.4 Mon Jul 18 07:28:24 2011
+++ src/sys/sys/xattr.h Mon Sep 26 21:40:32 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: xattr.h,v 1.4 2011/07/18 11:28:24 drochner Exp $ */
+/* $NetBSD: xattr.h,v 1.5 2011/09/27 01:40:32 christos Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -41,13 +41,13 @@
#define _SYS_XATTR_H_
#include <sys/types.h>
-#include <sys/syslimits.h>
+#include <sys/param.h>
/*
* This is compatible with EXTATTR_MAXNAMELEN, and also happens to be
* the same as Linux (255).
*/
-#define XATTR_NAME_MAX NAME_MAX
+#define XATTR_NAME_MAX KERNEL_NAME_MAX
#define XATTR_SIZE_MAX 65536 /* NetBSD does not enforce this */