[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YGDFxh7+724niztd@zeniv-ca.linux.org.uk>
Date: Sun, 28 Mar 2021 18:07:02 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: Miklos Szeredi <mszeredi@...hat.com>
Cc: linux-fsdevel@...r.kernel.org,
"Darrick J . Wong" <djwong@...nel.org>,
Amir Goldstein <amir73il@...il.com>,
David Sterba <dsterba@...e.cz>,
Christian Brauner <christian.brauner@...ntu.com>,
Eric Biggers <ebiggers@...nel.org>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 01/18] vfs: add fileattr ops
On Thu, Mar 25, 2021 at 08:37:38PM +0100, Miklos Szeredi wrote:
> +int vfs_fileattr_get(struct dentry *dentry, struct fileattr *fa)
> +{
> + struct inode *inode = d_inode(dentry);
> +
> + if (d_is_special(dentry))
> + return -ENOTTY;
FWIW - why? For uses via ioctl() you simply won't get there with
device nodes et.al. - they have file_operations of their own.
If we add syscall(s) for getting/setting those, there's no reason
for e.g. a device node not to have those attributes...
> +static int ioctl_getflags(struct file *file, void __user *argp)
unsigned int __user *argp, surely?
> +{
> + struct fileattr fa = { .flags_valid = true }; /* hint only */
> + unsigned int flags;
> + int err;
> +
> + err = vfs_fileattr_get(file->f_path.dentry, &fa);
> + if (!err) {
> + flags = fa.flags;
> + if (copy_to_user(argp, &flags, sizeof(flags)))
> + err = -EFAULT;
... and put_user() here.
> + }
> + return err;
> +}
> +
> +static int ioctl_setflags(struct file *file, void __user *argp)
> +{
> + struct fileattr fa;
> + unsigned int flags;
> + int err;
> +
> + if (copy_from_user(&flags, argp, sizeof(flags)))
> + return -EFAULT;
> +
> + err = mnt_want_write_file(file);
> + if (!err) {
> + fileattr_fill_flags(&fa, flags);
> + err = vfs_fileattr_set(file_mnt_user_ns(file), file_dentry(file), &fa);
> + mnt_drop_write_file(file);
> + }
> + return err;
> +}
Similar here.
Powered by blists - more mailing lists