aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/generic.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2011-07-27 14:47:03 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-27 15:50:45 -0400
commit09570f914914d2beb0db29c5a9c7344934f2fa8c (patch)
treea93900db5e607887aca3ef2cecc2426abe007d87 /fs/proc/generic.c
parent5fd00b031530cc476240f654c078c930f1dcd6ea (diff)
proc: make struct proc_dir_entry::name a terminal array rather than a pointer
Since __proc_create() appends the name it is given to the end of the PDE structure that it allocates, there isn't a need to store a name pointer. Instead we can just replace the name pointer with a terminal char array of _unspecified_ length. The compiler will simply append the string to statically defined variables of PDE type overlapping any hole at the end of the structure and, unlike specifying an explicitly _zero_ length array, won't give a warning if you try to statically initialise it with a string of more than zero length. Also, whilst we're at it: (1) Move namelen to end just prior to name and reduce it to a single byte (name shouldn't be longer than NAME_MAX). (2) Move pde_unload_lock two places further on so that if it's four bytes in size on a 64-bit machine, it won't cause an unused hole in the PDE struct. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc/generic.c')
-rw-r--r--fs/proc/generic.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index f1637f17c37..9d99131d0d6 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -620,8 +620,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
620 if (!ent) goto out; 620 if (!ent) goto out;
621 621
622 memset(ent, 0, sizeof(struct proc_dir_entry)); 622 memset(ent, 0, sizeof(struct proc_dir_entry));
623 memcpy(((char *) ent) + sizeof(struct proc_dir_entry), fn, len + 1); 623 memcpy(ent->name, fn, len + 1);
624 ent->name = ((char *) ent) + sizeof(*ent);
625 ent->namelen = len; 624 ent->namelen = len;
626 ent->mode = mode; 625 ent->mode = mode;
627 ent->nlink = nlink; 626 ent->nlink = nlink;