[PATCH 0/5] btrfs: send uevent on subvolume add/remove

From: Marcos Paulo de Souza
Date: Wed Oct 23 2019 - 22:34:40 EST


From: Marcos Paulo de Souza <mpdesouza@xxxxxxxx>

Hey guys,

these patches make btrfs to send an uevent to userspace whenever a subvolume is
added/removed. The changes are pretty straightforward. This patchset was based
in btrfs-misc-next.

The first patch adds an additional argument to btrfs_kobject_uevent to receive a
envp, and just forward this argument to kobject_uevent_envp.

Patch number 2 creates a new function that will be called by patches 4 and 5 to
setup the environment variable to be set to userspace using uevent. These two
environment variables are BTRFS_VOL_{NEW,DEL} and BTRFS_VOL_NAME. The first
variable will have the value 1 for subvolume add/remove (only one will be
exported, so udev can distinguish the event), and the second one hold the name
of the subvolume being added/removed.

Feel free to suggest any other useful information to be exported to userspace
when adding/removing a subvolume.

Patches 3 and 5 call btrfs_vol_uevent to send the event on subvolume add/remove.

Patch 4 creates a helper function to distinguish a subvolume from a snapshot,
since the same function is used to delete both. This function is used in patch
5.

Thanks for you reviews!

Marcos Paulo de Souza (5):
btrfs: sysfs: Add envp argument to btrfs_kobject_uevent
btrfs: ioctl: Introduce btrfs_vol_uevent
btrfs: ioctl: Call btrfs_vol_uevent on subvol creation
btrfs: ctree.h: Add btrfs_is_snapshot function
btrfs: ioctl: Call btrfs_vol_uevent on subvolume deletion

fs/btrfs/ctree.h | 14 ++++++++++++++
fs/btrfs/ioctl.c | 39 ++++++++++++++++++++++++++++++++++++++-
fs/btrfs/sysfs.c | 7 +++++--
fs/btrfs/sysfs.h | 3 ++-
fs/btrfs/volumes.c | 2 +-
5 files changed, 60 insertions(+), 5 deletions(-)

--
2.23.0