]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/open.c
make sure that fchdir() won't accept referral points, etc.
[karo-tx-linux.git] / fs / open.c
index 9921f70bc5ca07dab62d19ff9fded8d4a60ae9f0..9f4bbd7cc51acb6467c86da806eebaa068fc9f69 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -301,12 +301,10 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
        if (S_ISFIFO(inode->i_mode))
                return -ESPIPE;
 
-       /*
-        * Let individual file system decide if it supports preallocation
-        * for directories or not.
-        */
-       if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode) &&
-           !S_ISBLK(inode->i_mode))
+       if (S_ISDIR(inode->i_mode))
+               return -EISDIR;
+
+       if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))
                return -ENODEV;
 
        /* Check for wrap through zero too */
@@ -316,7 +314,7 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
        if (!file->f_op->fallocate)
                return -EOPNOTSUPP;
 
-       sb_start_write(inode->i_sb);
+       file_start_write(file);
        ret = file->f_op->fallocate(file, mode, offset, len);
 
        /*
@@ -329,7 +327,7 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
        if (ret == 0)
                fsnotify_modify(file);
 
-       sb_end_write(inode->i_sb);
+       file_end_write(file);
        return ret;
 }
 EXPORT_SYMBOL_GPL(vfs_fallocate);
@@ -461,20 +459,17 @@ out:
 SYSCALL_DEFINE1(fchdir, unsigned int, fd)
 {
        struct fd f = fdget_raw(fd);
-       struct inode *inode;
-       int error = -EBADF;
+       int error;
 
        error = -EBADF;
        if (!f.file)
                goto out;
 
-       inode = file_inode(f.file);
-
        error = -ENOTDIR;
-       if (!S_ISDIR(inode->i_mode))
+       if (!d_can_lookup(f.file->f_path.dentry))
                goto out_putf;
 
-       error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
+       error = inode_permission(file_inode(f.file), MAY_EXEC | MAY_CHDIR);
        if (!error)
                set_fs_pwd(current->fs, &f.file->f_path);
 out_putf: