stat.c (87d8a69709d971913e6cc7210450fcb8be963667) stat.c (c7887325230aec47d47a32562a6e26014a0fafca)
1/*
2 * linux/fs/stat.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */
6
7#include <linux/module.h>
8#include <linux/mm.h>

--- 54 unchanged lines hidden (view full) ---

63 if (f) {
64 error = vfs_getattr(f->f_path.mnt, f->f_path.dentry, stat);
65 fput(f);
66 }
67 return error;
68}
69EXPORT_SYMBOL(vfs_fstat);
70
1/*
2 * linux/fs/stat.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */
6
7#include <linux/module.h>
8#include <linux/mm.h>

--- 54 unchanged lines hidden (view full) ---

63 if (f) {
64 error = vfs_getattr(f->f_path.mnt, f->f_path.dentry, stat);
65 fput(f);
66 }
67 return error;
68}
69EXPORT_SYMBOL(vfs_fstat);
70
71int vfs_fstatat(int dfd, char __user *filename, struct kstat *stat, int flag)
71int vfs_fstatat(int dfd, const char __user *filename, struct kstat *stat,
72 int flag)
72{
73 struct path path;
74 int error = -EINVAL;
75 int lookup_flags = 0;
76
77 if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
78 goto out;
79

--- 6 unchanged lines hidden (view full) ---

86
87 error = vfs_getattr(path.mnt, path.dentry, stat);
88 path_put(&path);
89out:
90 return error;
91}
92EXPORT_SYMBOL(vfs_fstatat);
93
73{
74 struct path path;
75 int error = -EINVAL;
76 int lookup_flags = 0;
77
78 if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
79 goto out;
80

--- 6 unchanged lines hidden (view full) ---

87
88 error = vfs_getattr(path.mnt, path.dentry, stat);
89 path_put(&path);
90out:
91 return error;
92}
93EXPORT_SYMBOL(vfs_fstatat);
94
94int vfs_stat(char __user *name, struct kstat *stat)
95int vfs_stat(const char __user *name, struct kstat *stat)
95{
96 return vfs_fstatat(AT_FDCWD, name, stat, 0);
97}
98EXPORT_SYMBOL(vfs_stat);
99
96{
97 return vfs_fstatat(AT_FDCWD, name, stat, 0);
98}
99EXPORT_SYMBOL(vfs_stat);
100
100int vfs_lstat(char __user *name, struct kstat *stat)
101int vfs_lstat(const char __user *name, struct kstat *stat)
101{
102 return vfs_fstatat(AT_FDCWD, name, stat, AT_SYMLINK_NOFOLLOW);
103}
104EXPORT_SYMBOL(vfs_lstat);
105
106
107#ifdef __ARCH_WANT_OLD_STAT
108

--- 33 unchanged lines hidden (view full) ---

142#endif
143 tmp.st_size = stat->size;
144 tmp.st_atime = stat->atime.tv_sec;
145 tmp.st_mtime = stat->mtime.tv_sec;
146 tmp.st_ctime = stat->ctime.tv_sec;
147 return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
148}
149
102{
103 return vfs_fstatat(AT_FDCWD, name, stat, AT_SYMLINK_NOFOLLOW);
104}
105EXPORT_SYMBOL(vfs_lstat);
106
107
108#ifdef __ARCH_WANT_OLD_STAT
109

--- 33 unchanged lines hidden (view full) ---

143#endif
144 tmp.st_size = stat->size;
145 tmp.st_atime = stat->atime.tv_sec;
146 tmp.st_mtime = stat->mtime.tv_sec;
147 tmp.st_ctime = stat->ctime.tv_sec;
148 return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
149}
150
150SYSCALL_DEFINE2(stat, char __user *, filename, struct __old_kernel_stat __user *, statbuf)
151SYSCALL_DEFINE2(stat, const char __user *, filename,
152 struct __old_kernel_stat __user *, statbuf)
151{
152 struct kstat stat;
153 int error;
154
155 error = vfs_stat(filename, &stat);
156 if (error)
157 return error;
158
159 return cp_old_stat(&stat, statbuf);
160}
161
153{
154 struct kstat stat;
155 int error;
156
157 error = vfs_stat(filename, &stat);
158 if (error)
159 return error;
160
161 return cp_old_stat(&stat, statbuf);
162}
163
162SYSCALL_DEFINE2(lstat, char __user *, filename, struct __old_kernel_stat __user *, statbuf)
164SYSCALL_DEFINE2(lstat, const char __user *, filename,
165 struct __old_kernel_stat __user *, statbuf)
163{
164 struct kstat stat;
165 int error;
166
167 error = vfs_lstat(filename, &stat);
168 if (error)
169 return error;
170

--- 58 unchanged lines hidden (view full) ---

229 tmp.st_mtime_nsec = stat->mtime.tv_nsec;
230 tmp.st_ctime_nsec = stat->ctime.tv_nsec;
231#endif
232 tmp.st_blocks = stat->blocks;
233 tmp.st_blksize = stat->blksize;
234 return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
235}
236
166{
167 struct kstat stat;
168 int error;
169
170 error = vfs_lstat(filename, &stat);
171 if (error)
172 return error;
173

--- 58 unchanged lines hidden (view full) ---

232 tmp.st_mtime_nsec = stat->mtime.tv_nsec;
233 tmp.st_ctime_nsec = stat->ctime.tv_nsec;
234#endif
235 tmp.st_blocks = stat->blocks;
236 tmp.st_blksize = stat->blksize;
237 return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
238}
239
237SYSCALL_DEFINE2(newstat, char __user *, filename, struct stat __user *, statbuf)
240SYSCALL_DEFINE2(newstat, const char __user *, filename,
241 struct stat __user *, statbuf)
238{
239 struct kstat stat;
240 int error = vfs_stat(filename, &stat);
241
242 if (error)
243 return error;
244 return cp_new_stat(&stat, statbuf);
245}
246
242{
243 struct kstat stat;
244 int error = vfs_stat(filename, &stat);
245
246 if (error)
247 return error;
248 return cp_new_stat(&stat, statbuf);
249}
250
247SYSCALL_DEFINE2(newlstat, char __user *, filename, struct stat __user *, statbuf)
251SYSCALL_DEFINE2(newlstat, const char __user *, filename,
252 struct stat __user *, statbuf)
248{
249 struct kstat stat;
250 int error;
251
252 error = vfs_lstat(filename, &stat);
253 if (error)
254 return error;
255
256 return cp_new_stat(&stat, statbuf);
257}
258
259#if !defined(__ARCH_WANT_STAT64) || defined(__ARCH_WANT_SYS_NEWFSTATAT)
253{
254 struct kstat stat;
255 int error;
256
257 error = vfs_lstat(filename, &stat);
258 if (error)
259 return error;
260
261 return cp_new_stat(&stat, statbuf);
262}
263
264#if !defined(__ARCH_WANT_STAT64) || defined(__ARCH_WANT_SYS_NEWFSTATAT)
260SYSCALL_DEFINE4(newfstatat, int, dfd, char __user *, filename,
265SYSCALL_DEFINE4(newfstatat, int, dfd, const char __user *, filename,
261 struct stat __user *, statbuf, int, flag)
262{
263 struct kstat stat;
264 int error;
265
266 error = vfs_fstatat(dfd, filename, &stat, flag);
267 if (error)
268 return error;

--- 81 unchanged lines hidden (view full) ---

350 tmp.st_ctime = stat->ctime.tv_sec;
351 tmp.st_ctime_nsec = stat->ctime.tv_nsec;
352 tmp.st_size = stat->size;
353 tmp.st_blocks = stat->blocks;
354 tmp.st_blksize = stat->blksize;
355 return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
356}
357
266 struct stat __user *, statbuf, int, flag)
267{
268 struct kstat stat;
269 int error;
270
271 error = vfs_fstatat(dfd, filename, &stat, flag);
272 if (error)
273 return error;

--- 81 unchanged lines hidden (view full) ---

355 tmp.st_ctime = stat->ctime.tv_sec;
356 tmp.st_ctime_nsec = stat->ctime.tv_nsec;
357 tmp.st_size = stat->size;
358 tmp.st_blocks = stat->blocks;
359 tmp.st_blksize = stat->blksize;
360 return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
361}
362
358SYSCALL_DEFINE2(stat64, char __user *, filename, struct stat64 __user *, statbuf)
363SYSCALL_DEFINE2(stat64, const char __user *, filename,
364 struct stat64 __user *, statbuf)
359{
360 struct kstat stat;
361 int error = vfs_stat(filename, &stat);
362
363 if (!error)
364 error = cp_new_stat64(&stat, statbuf);
365
366 return error;
367}
368
365{
366 struct kstat stat;
367 int error = vfs_stat(filename, &stat);
368
369 if (!error)
370 error = cp_new_stat64(&stat, statbuf);
371
372 return error;
373}
374
369SYSCALL_DEFINE2(lstat64, char __user *, filename, struct stat64 __user *, statbuf)
375SYSCALL_DEFINE2(lstat64, const char __user *, filename,
376 struct stat64 __user *, statbuf)
370{
371 struct kstat stat;
372 int error = vfs_lstat(filename, &stat);
373
374 if (!error)
375 error = cp_new_stat64(&stat, statbuf);
376
377 return error;

--- 5 unchanged lines hidden (view full) ---

383 int error = vfs_fstat(fd, &stat);
384
385 if (!error)
386 error = cp_new_stat64(&stat, statbuf);
387
388 return error;
389}
390
377{
378 struct kstat stat;
379 int error = vfs_lstat(filename, &stat);
380
381 if (!error)
382 error = cp_new_stat64(&stat, statbuf);
383
384 return error;

--- 5 unchanged lines hidden (view full) ---

390 int error = vfs_fstat(fd, &stat);
391
392 if (!error)
393 error = cp_new_stat64(&stat, statbuf);
394
395 return error;
396}
397
391SYSCALL_DEFINE4(fstatat64, int, dfd, char __user *, filename,
398SYSCALL_DEFINE4(fstatat64, int, dfd, const char __user *, filename,
392 struct stat64 __user *, statbuf, int, flag)
393{
394 struct kstat stat;
395 int error;
396
397 error = vfs_fstatat(dfd, filename, &stat, flag);
398 if (error)
399 return error;

--- 61 unchanged lines hidden ---
399 struct stat64 __user *, statbuf, int, flag)
400{
401 struct kstat stat;
402 int error;
403
404 error = vfs_fstatat(dfd, filename, &stat, flag);
405 if (error)
406 return error;

--- 61 unchanged lines hidden ---