diff options
Diffstat (limited to 'fs/readdir.c')
-rw-r--r-- | fs/readdir.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/fs/readdir.c b/fs/readdir.c index f39f5b313252..efe52e676577 100644 --- a/fs/readdir.c +++ b/fs/readdir.c | |||
@@ -4,13 +4,13 @@ | |||
4 | * Copyright (C) 1995 Linus Torvalds | 4 | * Copyright (C) 1995 Linus Torvalds |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <linux/kernel.h> | ||
7 | #include <linux/module.h> | 8 | #include <linux/module.h> |
8 | #include <linux/time.h> | 9 | #include <linux/time.h> |
9 | #include <linux/mm.h> | 10 | #include <linux/mm.h> |
10 | #include <linux/errno.h> | 11 | #include <linux/errno.h> |
11 | #include <linux/stat.h> | 12 | #include <linux/stat.h> |
12 | #include <linux/file.h> | 13 | #include <linux/file.h> |
13 | #include <linux/smp_lock.h> | ||
14 | #include <linux/fs.h> | 14 | #include <linux/fs.h> |
15 | #include <linux/dirent.h> | 15 | #include <linux/dirent.h> |
16 | #include <linux/security.h> | 16 | #include <linux/security.h> |
@@ -52,7 +52,6 @@ EXPORT_SYMBOL(vfs_readdir); | |||
52 | * case (the low-level handlers don't need to care about this). | 52 | * case (the low-level handlers don't need to care about this). |
53 | */ | 53 | */ |
54 | #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de))) | 54 | #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de))) |
55 | #define ROUND_UP(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1)) | ||
56 | 55 | ||
57 | #ifdef __ARCH_WANT_OLD_READDIR | 56 | #ifdef __ARCH_WANT_OLD_READDIR |
58 | 57 | ||
@@ -147,7 +146,7 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset, | |||
147 | struct linux_dirent __user * dirent; | 146 | struct linux_dirent __user * dirent; |
148 | struct getdents_callback * buf = (struct getdents_callback *) __buf; | 147 | struct getdents_callback * buf = (struct getdents_callback *) __buf; |
149 | unsigned long d_ino; | 148 | unsigned long d_ino; |
150 | int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 2); | 149 | int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 2, sizeof(long)); |
151 | 150 | ||
152 | buf->error = -EINVAL; /* only used if we fail.. */ | 151 | buf->error = -EINVAL; /* only used if we fail.. */ |
153 | if (reclen > buf->count) | 152 | if (reclen > buf->count) |
@@ -220,8 +219,6 @@ out: | |||
220 | return error; | 219 | return error; |
221 | } | 220 | } |
222 | 221 | ||
223 | #define ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1)) | ||
224 | |||
225 | struct getdents_callback64 { | 222 | struct getdents_callback64 { |
226 | struct linux_dirent64 __user * current_dir; | 223 | struct linux_dirent64 __user * current_dir; |
227 | struct linux_dirent64 __user * previous; | 224 | struct linux_dirent64 __user * previous; |
@@ -234,7 +231,7 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset, | |||
234 | { | 231 | { |
235 | struct linux_dirent64 __user *dirent; | 232 | struct linux_dirent64 __user *dirent; |
236 | struct getdents_callback64 * buf = (struct getdents_callback64 *) __buf; | 233 | struct getdents_callback64 * buf = (struct getdents_callback64 *) __buf; |
237 | int reclen = ROUND_UP64(NAME_OFFSET(dirent) + namlen + 1); | 234 | int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 1, sizeof(u64)); |
238 | 235 | ||
239 | buf->error = -EINVAL; /* only used if we fail.. */ | 236 | buf->error = -EINVAL; /* only used if we fail.. */ |
240 | if (reclen > buf->count) | 237 | if (reclen > buf->count) |