switch simple cases of fget_light to fdget
[linux-2.6-block.git] / fs / fcntl.c
index 40a5bfb72ccae234265a1e2c2126c847e48da1c4..91af39a33af7ebd2b9863ad4907297075fe9f5f0 100644 (file)
@@ -348,25 +348,23 @@ static int check_fcntl_cmd(unsigned cmd)
 
 SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
 {      
-       struct file *filp;
-       int fput_needed;
+       struct fd f = fdget_raw(fd);
        long err = -EBADF;
 
-       filp = fget_raw_light(fd, &fput_needed);
-       if (!filp)
+       if (!f.file)
                goto out;
 
-       if (unlikely(filp->f_mode & FMODE_PATH)) {
+       if (unlikely(f.file->f_mode & FMODE_PATH)) {
                if (!check_fcntl_cmd(cmd))
                        goto out1;
        }
 
-       err = security_file_fcntl(filp, cmd, arg);
+       err = security_file_fcntl(f.file, cmd, arg);
        if (!err)
-               err = do_fcntl(fd, cmd, arg, filp);
+               err = do_fcntl(fd, cmd, arg, f.file);
 
 out1:
-       fput_light(filp, fput_needed);
+       fdput(f);
 out:
        return err;
 }
@@ -375,38 +373,36 @@ out:
 SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
                unsigned long, arg)
 {      
-       struct file * filp;
+       struct fd f = fdget_raw(fd);
        long err = -EBADF;
-       int fput_needed;
 
-       filp = fget_raw_light(fd, &fput_needed);
-       if (!filp)
+       if (!f.file)
                goto out;
 
-       if (unlikely(filp->f_mode & FMODE_PATH)) {
+       if (unlikely(f.file->f_mode & FMODE_PATH)) {
                if (!check_fcntl_cmd(cmd))
                        goto out1;
        }
 
-       err = security_file_fcntl(filp, cmd, arg);
+       err = security_file_fcntl(f.file, cmd, arg);
        if (err)
                goto out1;
        
        switch (cmd) {
                case F_GETLK64:
-                       err = fcntl_getlk64(filp, (struct flock64 __user *) arg);
+                       err = fcntl_getlk64(f.file, (struct flock64 __user *) arg);
                        break;
                case F_SETLK64:
                case F_SETLKW64:
-                       err = fcntl_setlk64(fd, filp, cmd,
+                       err = fcntl_setlk64(fd, f.file, cmd,
                                        (struct flock64 __user *) arg);
                        break;
                default:
-                       err = do_fcntl(fd, cmd, arg, filp);
+                       err = do_fcntl(fd, cmd, arg, f.file);
                        break;
        }
 out1:
-       fput_light(filp, fput_needed);
+       fdput(f);
 out:
        return err;
 }