diff options
Diffstat (limited to 'fs/readdir.c')
-rw-r--r-- | fs/readdir.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/readdir.c b/fs/readdir.c index 7723401f8d8b..356f71528ad6 100644 --- a/fs/readdir.c +++ b/fs/readdir.c | |||
@@ -4,6 +4,7 @@ | |||
4 | * Copyright (C) 1995 Linus Torvalds | 4 | * Copyright (C) 1995 Linus Torvalds |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <linux/stddef.h> | ||
7 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
8 | #include <linux/module.h> | 9 | #include <linux/module.h> |
9 | #include <linux/time.h> | 10 | #include <linux/time.h> |
@@ -54,7 +55,6 @@ EXPORT_SYMBOL(vfs_readdir); | |||
54 | * anyway. Thus the special "fillonedir()" function for that | 55 | * anyway. Thus the special "fillonedir()" function for that |
55 | * case (the low-level handlers don't need to care about this). | 56 | * case (the low-level handlers don't need to care about this). |
56 | */ | 57 | */ |
57 | #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de))) | ||
58 | 58 | ||
59 | #ifdef __ARCH_WANT_OLD_READDIR | 59 | #ifdef __ARCH_WANT_OLD_READDIR |
60 | 60 | ||
@@ -152,7 +152,8 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset, | |||
152 | struct linux_dirent __user * dirent; | 152 | struct linux_dirent __user * dirent; |
153 | struct getdents_callback * buf = (struct getdents_callback *) __buf; | 153 | struct getdents_callback * buf = (struct getdents_callback *) __buf; |
154 | unsigned long d_ino; | 154 | unsigned long d_ino; |
155 | int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 2, sizeof(long)); | 155 | int reclen = ALIGN(offsetof(struct linux_dirent, d_name) + namlen + 2, |
156 | sizeof(long)); | ||
156 | 157 | ||
157 | buf->error = -EINVAL; /* only used if we fail.. */ | 158 | buf->error = -EINVAL; /* only used if we fail.. */ |
158 | if (reclen > buf->count) | 159 | if (reclen > buf->count) |
@@ -237,7 +238,8 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset, | |||
237 | { | 238 | { |
238 | struct linux_dirent64 __user *dirent; | 239 | struct linux_dirent64 __user *dirent; |
239 | struct getdents_callback64 * buf = (struct getdents_callback64 *) __buf; | 240 | struct getdents_callback64 * buf = (struct getdents_callback64 *) __buf; |
240 | int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 1, sizeof(u64)); | 241 | int reclen = ALIGN(offsetof(struct linux_dirent64, d_name) + namlen + 1, |
242 | sizeof(u64)); | ||
241 | 243 | ||
242 | buf->error = -EINVAL; /* only used if we fail.. */ | 244 | buf->error = -EINVAL; /* only used if we fail.. */ |
243 | if (reclen > buf->count) | 245 | if (reclen > buf->count) |