/* flock() system call entry point. Apply a FL_FLOCK style lock to * an open file descriptor. */ asmlinkage int sys_flock(unsigned int fd, unsigned int cmd) { struct file_lock file_lock; struct file *filp; int error; lock_kernel(); error = -EBADF; filp = fget(fd); if (!filp) goto out; error = -EINVAL; if (!flock_make_lock(filp, &file_lock, cmd)) goto out_putf; error = -EBADF; if ((file_lock.fl_type != F_UNLCK) && !(filp->f_mode & 3)) goto out_putf; error = flock_lock_file(filp, &file_lock, (cmd & (LOCK_UN | LOCK_NB)) ? 0 : 1); out_putf: fput(filp); out: unlock_kernel(); return (error); }
/* flock() system call entry point. Apply a FL_FLOCK style lock to * an open file descriptor. */ asmlinkage int sys_flock(unsigned int fd, unsigned int cmd) { struct file_lock file_lock; struct file *filp; if ((fd >= NR_OPEN) || !(filp = current->files->fd[fd])) return (-EBADF); if (!flock_make_lock(filp, &file_lock, cmd)) return (-EINVAL); if ((file_lock.fl_type != F_UNLCK) && !(filp->f_mode & 3)) return (-EBADF); return (flock_lock_file(filp, &file_lock, (cmd & (LOCK_UN | LOCK_NB)) ? 0 : 1)); }