1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

o Support /sbin/hotplug

This commit is contained in:
Steven Whitehouse 2001-09-14 15:35:06 +00:00
parent fb170684a0
commit 875fa752a0

View File

@ -38,6 +38,7 @@
#include <linux/blkpg.h> #include <linux/blkpg.h>
#include <linux/hdreg.h> #include <linux/hdreg.h>
#include <linux/lvm.h> #include <linux/lvm.h>
#include <linux/kmod.h>
#define MAX_DEVICES 64 #define MAX_DEVICES 64
#define DEFAULT_READ_AHEAD 64 #define DEFAULT_READ_AHEAD 64
@ -603,6 +604,40 @@ static int unregister_device(struct mapped_device *md)
return 0; return 0;
} }
#ifdef CONFIG_HOTPLUG
static void dm_sbin_hotplug(struct mapped_device *md, int create)
{
int i;
char *argv[3];
char *envp[5];
char name[DM_NAME_LEN + 16];
if (!hotplug_path[0])
return;
sprintf(name, "DMNAME=%s\n", md->name);
i = 0;
argv[i++] = hotplug_path;
argv[i++] = "devmap";
argv[i] = 0;
i = 0;
envp[i++] = "HOME=/";
envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
envp[i++] = name;
if (create)
envp[i++] = "ACTION=add";
else
envp[i++] = "ACTION=remove";
envp[i] = 0;
call_usermodehelper(argv[0], argv, envp);
}
#else
#define dm_sbin_hotplug(md, create) do { } while(0)
#endif /* CONFIG_HOTPLUG */
/* /*
* constructor for a new device * constructor for a new device
*/ */
@ -633,6 +668,8 @@ int dm_create(const char *name, int minor)
} }
up_write(&_dev_lock); up_write(&_dev_lock);
dm_sbin_hotplug(md, 1);
return 0; return 0;
} }
@ -667,6 +704,8 @@ int dm_remove(const char *name)
_devs[minor] = 0; _devs[minor] = 0;
up_write(&_dev_lock); up_write(&_dev_lock);
dm_sbin_hotplug(md, 0);
return 0; return 0;
} }