SUNRPC: Fix rpcauth_prune_expired
[safe/jmp/linux-2.6] / fs / stat.c
index 60a31d5..7c46fbe 100644 (file)
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -8,7 +8,6 @@
 #include <linux/mm.h>
 #include <linux/errno.h>
 #include <linux/file.h>
-#include <linux/smp_lock.h>
 #include <linux/highuid.h>
 #include <linux/fs.h>
 #include <linux/namei.h>
@@ -51,13 +50,6 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
                return inode->i_op->getattr(mnt, dentry, stat);
 
        generic_fillattr(inode, stat);
-       if (!stat->blksize) {
-               struct super_block *s = inode->i_sb;
-               unsigned blocks;
-               blocks = (stat->size+s->s_blocksize-1) >> s->s_blocksize_bits;
-               stat->blocks = (s->s_blocksize / 512) * blocks;
-               stat->blksize = s->s_blocksize;
-       }
        return 0;
 }
 
@@ -65,13 +57,13 @@ EXPORT_SYMBOL(vfs_getattr);
 
 int vfs_stat_fd(int dfd, char __user *name, struct kstat *stat)
 {
-       struct nameidata nd;
+       struct path path;
        int error;
 
-       error = __user_walk_fd(dfd, name, LOOKUP_FOLLOW, &nd);
+       error = user_path_at(dfd, name, LOOKUP_FOLLOW, &path);
        if (!error) {
-               error = vfs_getattr(nd.mnt, nd.dentry, stat);
-               path_release(&nd);
+               error = vfs_getattr(path.mnt, path.dentry, stat);
+               path_put(&path);
        }
        return error;
 }
@@ -85,13 +77,13 @@ EXPORT_SYMBOL(vfs_stat);
 
 int vfs_lstat_fd(int dfd, char __user *name, struct kstat *stat)
 {
-       struct nameidata nd;
+       struct path path;
        int error;
 
-       error = __user_walk_fd(dfd, name, 0, &nd);
+       error = user_path_at(dfd, name, 0, &path);
        if (!error) {
-               error = vfs_getattr(nd.mnt, nd.dentry, stat);
-               path_release(&nd);
+               error = vfs_getattr(path.mnt, path.dentry, stat);
+               path_put(&path);
        }
        return error;
 }
@@ -109,7 +101,7 @@ int vfs_fstat(unsigned int fd, struct kstat *stat)
        int error = -EBADF;
 
        if (f) {
-               error = vfs_getattr(f->f_vfsmnt, f->f_dentry, stat);
+               error = vfs_getattr(f->f_path.mnt, f->f_path.dentry, stat);
                fput(f);
        }
        return error;
@@ -140,6 +132,8 @@ static int cp_old_stat(struct kstat *stat, struct __old_kernel_stat __user * sta
        memset(&tmp, 0, sizeof(struct __old_kernel_stat));
        tmp.st_dev = old_encode_dev(stat->dev);
        tmp.st_ino = stat->ino;
+       if (sizeof(tmp.st_ino) < sizeof(stat->ino) && tmp.st_ino != stat->ino)
+               return -EOVERFLOW;
        tmp.st_mode = stat->mode;
        tmp.st_nlink = stat->nlink;
        if (tmp.st_nlink != stat->nlink)
@@ -210,6 +204,8 @@ static int cp_new_stat(struct kstat *stat, struct stat __user *statbuf)
        tmp.st_dev = new_encode_dev(stat->dev);
 #endif
        tmp.st_ino = stat->ino;
+       if (sizeof(tmp.st_ino) < sizeof(stat->ino) && tmp.st_ino != stat->ino)
+               return -EOVERFLOW;
        tmp.st_mode = stat->mode;
        tmp.st_nlink = stat->nlink;
        if (tmp.st_nlink != stat->nlink)
@@ -295,28 +291,29 @@ asmlinkage long sys_newfstat(unsigned int fd, struct stat __user *statbuf)
        return error;
 }
 
-asmlinkage long sys_readlinkat(int dfd, const char __user *path,
+asmlinkage long sys_readlinkat(int dfd, const char __user *pathname,
                                char __user *buf, int bufsiz)
 {
-       struct nameidata nd;
+       struct path path;
        int error;
 
        if (bufsiz <= 0)
                return -EINVAL;
 
-       error = __user_walk_fd(dfd, path, 0, &nd);
+       error = user_path_at(dfd, pathname, 0, &path);
        if (!error) {
-               struct inode * inode = nd.dentry->d_inode;
+               struct inode *inode = path.dentry->d_inode;
 
                error = -EINVAL;
                if (inode->i_op && inode->i_op->readlink) {
-                       error = security_inode_readlink(nd.dentry);
+                       error = security_inode_readlink(path.dentry);
                        if (!error) {
-                               touch_atime(nd.mnt, nd.dentry);
-                               error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
+                               touch_atime(path.mnt, path.dentry);
+                               error = inode->i_op->readlink(path.dentry,
+                                                             buf, bufsiz);
                        }
                }
-               path_release(&nd);
+               path_put(&path);
        }
        return error;
 }
@@ -347,6 +344,8 @@ static long cp_new_stat64(struct kstat *stat, struct stat64 __user *statbuf)
        tmp.st_rdev = huge_encode_dev(stat->rdev);
 #endif
        tmp.st_ino = stat->ino;
+       if (sizeof(tmp.st_ino) < sizeof(stat->ino) && tmp.st_ino != stat->ino)
+               return -EOVERFLOW;
 #ifdef STAT64_HAS_BROKEN_ST_INO
        tmp.__st_ino = stat->ino;
 #endif