Re: [RFC PATCH 1/2] fs/locks: add flock_setlk to help set flock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 29, 2018 at 12:08 PM, yangerkun <yangerkun@xxxxxxxxxx> wrote:
> Split sys_flock(), add flock_setlk() routine to help kernel set
> flock easily.
>
> Signed-off-by: yangerkun <yangerkun@xxxxxxxxxx>
> ---
>  fs/locks.c         | 29 +++++++++++++++++------------
>  include/linux/fs.h |  1 +
>  2 files changed, 18 insertions(+), 12 deletions(-)
>
> diff --git a/fs/locks.c b/fs/locks.c
> index d6ff4be..aeef6cf 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -1974,6 +1974,22 @@ int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl)
>  }
>  EXPORT_SYMBOL(locks_lock_inode_wait);
>
> +int flock_setlk(struct file *filp, struct file_lock *lock)
> +{
> +       int err;
> +
> +       err = security_file_lock(filp, lock->fl_type);
> +       if (err)
> +               return err;
> +
> +       if (filp->f_op->flock && is_remote_lock(filp))
> +               return filp->f_op->flock(filp,
> +                                       (lock->fl_flags & FL_SLEEP) ? F_SETLKW : F_SETLK,
> +                                       lock);

Although this was moved as is, please add {} around non-oneliner.

> +       else
> +               return locks_lock_file_wait(filp, lock);

And leave this without else.

> +}
> +

You need to EXPORT_SYMBOL if you want to use this from overlayfs.

Thanks,
Amir.
--
To unsubscribe from this list: send the line "unsubscribe linux-unionfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux