diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/compat.c | 19 | ||||
-rw-r--r-- | fs/stat.c | 56 |
2 files changed, 33 insertions, 42 deletions
diff --git a/fs/compat.c b/fs/compat.c index 3f84d5f15889..dda72e267092 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -204,21 +204,12 @@ asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user *filename, | |||
204 | struct compat_stat __user *statbuf, int flag) | 204 | struct compat_stat __user *statbuf, int flag) |
205 | { | 205 | { |
206 | struct kstat stat; | 206 | struct kstat stat; |
207 | int error = -EINVAL; | 207 | int error; |
208 | |||
209 | if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0) | ||
210 | goto out; | ||
211 | |||
212 | if (flag & AT_SYMLINK_NOFOLLOW) | ||
213 | error = vfs_lstat_fd(dfd, filename, &stat); | ||
214 | else | ||
215 | error = vfs_stat_fd(dfd, filename, &stat); | ||
216 | |||
217 | if (!error) | ||
218 | error = cp_compat_stat(&stat, statbuf); | ||
219 | 208 | ||
220 | out: | 209 | error = vfs_fstatat(dfd, filename, &stat, flag); |
221 | return error; | 210 | if (error) |
211 | return error; | ||
212 | return cp_compat_stat(&stat, statbuf); | ||
222 | } | 213 | } |
223 | #endif | 214 | #endif |
224 | 215 | ||
@@ -109,6 +109,24 @@ int vfs_fstat(unsigned int fd, struct kstat *stat) | |||
109 | 109 | ||
110 | EXPORT_SYMBOL(vfs_fstat); | 110 | EXPORT_SYMBOL(vfs_fstat); |
111 | 111 | ||
112 | int vfs_fstatat(int dfd, char __user *filename, struct kstat *stat, int flag) | ||
113 | { | ||
114 | int error = -EINVAL; | ||
115 | |||
116 | if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0) | ||
117 | goto out; | ||
118 | |||
119 | if (flag & AT_SYMLINK_NOFOLLOW) | ||
120 | error = vfs_lstat_fd(dfd, filename, stat); | ||
121 | else | ||
122 | error = vfs_stat_fd(dfd, filename, stat); | ||
123 | out: | ||
124 | return error; | ||
125 | } | ||
126 | |||
127 | EXPORT_SYMBOL(vfs_fstatat); | ||
128 | |||
129 | |||
112 | #ifdef __ARCH_WANT_OLD_STAT | 130 | #ifdef __ARCH_WANT_OLD_STAT |
113 | 131 | ||
114 | /* | 132 | /* |
@@ -264,21 +282,12 @@ SYSCALL_DEFINE4(newfstatat, int, dfd, char __user *, filename, | |||
264 | struct stat __user *, statbuf, int, flag) | 282 | struct stat __user *, statbuf, int, flag) |
265 | { | 283 | { |
266 | struct kstat stat; | 284 | struct kstat stat; |
267 | int error = -EINVAL; | 285 | int error; |
268 | |||
269 | if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0) | ||
270 | goto out; | ||
271 | |||
272 | if (flag & AT_SYMLINK_NOFOLLOW) | ||
273 | error = vfs_lstat_fd(dfd, filename, &stat); | ||
274 | else | ||
275 | error = vfs_stat_fd(dfd, filename, &stat); | ||
276 | |||
277 | if (!error) | ||
278 | error = cp_new_stat(&stat, statbuf); | ||
279 | 286 | ||
280 | out: | 287 | error = vfs_fstatat(dfd, filename, &stat, flag); |
281 | return error; | 288 | if (error) |
289 | return error; | ||
290 | return cp_new_stat(&stat, statbuf); | ||
282 | } | 291 | } |
283 | #endif | 292 | #endif |
284 | 293 | ||
@@ -404,21 +413,12 @@ SYSCALL_DEFINE4(fstatat64, int, dfd, char __user *, filename, | |||
404 | struct stat64 __user *, statbuf, int, flag) | 413 | struct stat64 __user *, statbuf, int, flag) |
405 | { | 414 | { |
406 | struct kstat stat; | 415 | struct kstat stat; |
407 | int error = -EINVAL; | 416 | int error; |
408 | |||
409 | if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0) | ||
410 | goto out; | ||
411 | |||
412 | if (flag & AT_SYMLINK_NOFOLLOW) | ||
413 | error = vfs_lstat_fd(dfd, filename, &stat); | ||
414 | else | ||
415 | error = vfs_stat_fd(dfd, filename, &stat); | ||
416 | |||
417 | if (!error) | ||
418 | error = cp_new_stat64(&stat, statbuf); | ||
419 | 417 | ||
420 | out: | 418 | error = vfs_fstatat(dfd, filename, &stat, flag); |
421 | return error; | 419 | if (error) |
420 | return error; | ||
421 | return cp_new_stat64(&stat, statbuf); | ||
422 | } | 422 | } |
423 | #endif /* __ARCH_WANT_STAT64 */ | 423 | #endif /* __ARCH_WANT_STAT64 */ |
424 | 424 | ||