diff options
| author | Greg Kroah-Hartman <greg@kroah.com> | 2004-09-15 00:16:46 -0700 |
|---|---|---|
| committer | Greg Kroah-Hartman <greg@kroah.com> | 2004-09-15 00:16:46 -0700 |
| commit | 29917e272bd25f227eddf43d4fd0a8e9e6794e3d (patch) | |
| tree | f39cb0c661242e22fa12a154bb89cd1d814a0e11 | |
| parent | db062d4a6fefc23b61c0315ac286cfeae0791329 (diff) | |
kevent: add block mount and umount support
Send notification over the new netlink socket to let userspace know that
the filesystem code claims/releases the superblock on an blockdevice.
This way, userspace can get rid of constantly polling /proc/mounts to
watch for filesystem changes.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
| -rw-r--r-- | fs/super.c | 17 | ||||
| -rw-r--r-- | include/linux/kobject_uevent.h | 1 | ||||
| -rw-r--r-- | lib/kobject_uevent.c | 1 |
3 files changed, 18 insertions, 1 deletions
diff --git a/fs/super.c b/fs/super.c index 38c23bf558d4..eccf4d4cbebf 100644 --- a/fs/super.c +++ b/fs/super.c @@ -35,6 +35,7 @@ #include <linux/vfs.h> #include <linux/writeback.h> /* for the emergency remount stuff */ #include <linux/idr.h> +#include <linux/kobject.h> #include <asm/uaccess.h> @@ -633,6 +634,16 @@ static int test_bdev_super(struct super_block *s, void *data) return (void *)s->s_bdev == data; } +static void bdev_uevent(struct block_device *bdev, enum kobject_action action) +{ + if (bdev->bd_disk) { + if (bdev->bd_part) + kobject_uevent(&bdev->bd_part->kobj, action, NULL); + else + kobject_uevent(&bdev->bd_disk->kobj, action, NULL); + } +} + struct super_block *get_sb_bdev(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, int (*fill_super)(struct super_block *, void *, int)) @@ -675,8 +686,10 @@ struct super_block *get_sb_bdev(struct file_system_type *fs_type, up_write(&s->s_umount); deactivate_super(s); s = ERR_PTR(error); - } else + } else { s->s_flags |= MS_ACTIVE; + bdev_uevent(bdev, KOBJ_MOUNT); + } } return s; @@ -691,6 +704,8 @@ EXPORT_SYMBOL(get_sb_bdev); void kill_block_super(struct super_block *sb) { struct block_device *bdev = sb->s_bdev; + + bdev_uevent(bdev, KOBJ_UMOUNT); generic_shutdown_super(sb); set_blocksize(bdev, sb->s_old_blocksize); close_bdev_excl(bdev); diff --git a/include/linux/kobject_uevent.h b/include/linux/kobject_uevent.h index f263daf7f3dc..ad0f04424522 100644 --- a/include/linux/kobject_uevent.h +++ b/include/linux/kobject_uevent.h @@ -21,6 +21,7 @@ enum kobject_action { KOBJ_REMOVE = 0x01, /* remove event, for hotplug */ KOBJ_CHANGE = 0x02, /* a sysfs attribute file has changed */ KOBJ_MOUNT = 0x03, /* mount event for block devices */ + KOBJ_UMOUNT = 0x04, /* umount event for block devices */ KOBJ_MAX_ACTION, /* must be last action listed */ }; diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index 349839872925..33e0cef31ba8 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c @@ -32,6 +32,7 @@ static char *actions[] = { "remove", /* 0x01 */ "change", /* 0x02 */ "mount", /* 0x03 */ + "umount", /* 0x04 */ }; static char *action_to_string(enum kobject_action action) |
