lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Wed, 23 Oct 2019 23:36:33 -0300 From: Marcos Paulo de Souza <marcos.souza.org@...il.com> To: linux-kernel@...r.kernel.org Cc: clm@...com, josef@...icpanda.com, dsterba@...e.com, linux-btrfs@...r.kernel.org, mpdesouza@...e.com Subject: [PATCH 2/5] btrfs: ioctl: Introduce btrfs_vol_uevent From: Marcos Paulo de Souza <mpdesouza@...e.com> This new function will be used to send uevents when a subvolume is created or removed. Two environment variables are being exported: BTRFS_VOL_NAME: contains the name of the volume being added/removed BTRFS_VOL_{ADD|DEL}: will signalize whether a subvolume is created/deleted Signed-off-by: Marcos Paulo de Souza <mpdesouza@...e.com> --- fs/btrfs/ioctl.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index de730e56d3f5..174cbe71d6be 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -940,6 +940,33 @@ static inline int btrfs_may_create(struct inode *dir, struct dentry *child) return inode_permission(dir, MAY_WRITE | MAY_EXEC); } +static inline int btrfs_vol_uevent(struct block_device *bdev, bool vol_added, + const char *name) +{ + char *envp[3]; + int ret = -ENOMEM; + + envp[0] = kasprintf(GFP_KERNEL, "BTRFS_VOL_NAME=%s", name); + if (!envp[0]) + return ret; + + envp[1] = kasprintf(GFP_KERNEL, "BTRFS_VOL_%s=1", + vol_added ? "NEW" : "DEL"); + if (!envp[1]) + goto free; + + envp[2] = NULL; + + btrfs_kobject_uevent(bdev, KOBJ_CHANGE, envp); + + ret = 0; + + kfree(envp[1]); +free: + kfree(envp[0]); + return ret; +} + /* * Create a new subvolume below @parent. This is largely modeled after * sys_mkdirat and vfs_mkdir, but we only do a single component lookup -- 2.23.0
Powered by blists - more mailing lists