7 #include <linux/export.h>
9 #include <linux/errno.h>
18 #include <asm/uaccess.h>
19 #include <asm/unistd.h>
30 stat->
size = i_size_read(inode);
49 if (inode->
i_op->getattr)
50 return inode->
i_op->getattr(mnt, dentry, stat);
60 struct fd f = fdget_raw(fd);
88 error =
user_path_at(dfd, filename, lookup_flags, &path);
112 #ifdef __ARCH_WANT_OLD_STAT
120 static int warncount = 5;
125 printk(
KERN_WARNING "VFS: Warning: %s using old stat() call. Recompile your binary.\n",
127 }
else if (warncount < 0) {
133 tmp.st_dev = old_encode_dev(stat->
dev);
135 if (
sizeof(
tmp.st_ino) <
sizeof(stat->
ino) &&
tmp.st_ino != stat->
ino)
143 tmp.st_rdev = old_encode_dev(stat->
rdev);
144 #if BITS_PER_LONG == 32
165 return cp_old_stat(&stat, statbuf);
178 return cp_old_stat(&stat, statbuf);
187 error = cp_old_stat(&stat, statbuf);
194 #if BITS_PER_LONG == 32
195 # define choose_32_64(a,b) a
197 # define choose_32_64(a,b) b
200 #define valid_dev(x) choose_32_64(old_valid_dev,new_valid_dev)(x)
201 #define encode_dev(x) choose_32_64(old_encode_dev,new_encode_dev)(x)
203 #ifndef INIT_STRUCT_STAT_PADDING
204 # define INIT_STRUCT_STAT_PADDING(st) memset(&st, 0, sizeof(st))
207 static int cp_new_stat(
struct kstat *stat,
struct stat __user *statbuf)
213 #if BITS_PER_LONG == 32
234 #ifdef STAT_HAVE_NSEC
245 struct stat __user *, statbuf)
252 return cp_new_stat(&stat, statbuf);
256 struct stat __user *, statbuf)
265 return cp_new_stat(&stat, statbuf);
268 #if !defined(__ARCH_WANT_STAT64) || defined(__ARCH_WANT_SYS_NEWFSTATAT)
270 struct stat __user *, statbuf,
int,
flag)
278 return cp_new_stat(&stat, statbuf);
288 error = cp_new_stat(&stat, statbuf);
294 char __user *,
buf,
int, bufsiz)
308 if (inode->
i_op->readlink) {
329 #if defined(__ARCH_WANT_STAT64) || defined(__ARCH_WANT_COMPAT_STAT64)
331 #ifndef INIT_STRUCT_STAT64_PADDING
332 # define INIT_STRUCT_STAT64_PADDING(st) memset(&st, 0, sizeof(st))
335 static long cp_new_stat64(
struct kstat *stat,
struct stat64 __user *statbuf)
339 INIT_STRUCT_STAT64_PADDING(
tmp);
342 if (!new_valid_dev(stat->
dev) || !new_valid_dev(stat->
rdev))
344 tmp.st_dev = new_encode_dev(stat->
dev);
345 tmp.st_rdev = new_encode_dev(stat->
rdev);
347 tmp.st_dev = huge_encode_dev(stat->
dev);
348 tmp.st_rdev = huge_encode_dev(stat->
rdev);
351 if (
sizeof(
tmp.st_ino) <
sizeof(stat->
ino) &&
tmp.st_ino != stat->
ino)
353 #ifdef STAT64_HAS_BROKEN_ST_INO
361 tmp.st_atime_nsec = stat->
atime.tv_nsec;
363 tmp.st_mtime_nsec = stat->
mtime.tv_nsec;
365 tmp.st_ctime_nsec = stat->
ctime.tv_nsec;
373 struct stat64 __user *, statbuf)
379 error = cp_new_stat64(&stat, statbuf);
385 struct stat64 __user *, statbuf)
391 error = cp_new_stat64(&stat, statbuf);
402 error = cp_new_stat64(&stat, statbuf);
416 return cp_new_stat64(&stat, statbuf);
434 spin_lock(&inode->
i_lock);
436 spin_unlock(&inode->
i_lock);
443 spin_lock(&inode->
i_lock);
451 spin_unlock(&inode->
i_lock);
460 spin_lock(&inode->
i_lock);
462 spin_unlock(&inode->
i_lock);