1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-30 17:18:21 +03:00

o You can now specify the dev directory for libdm

o  dm_dir() returns the full path to the device-mapper dir (eg, /dev/device-mapper).

o  put stat in on _rm_node
This commit is contained in:
Joe Thornber 2001-11-21 17:08:37 +00:00
parent 8c2fd26dfa
commit 8f8cf896d6
2 changed files with 19 additions and 3 deletions

View File

@ -74,8 +74,9 @@ int dm_task_add_target(struct dm_task *dmt,
int dm_task_run(struct dm_task *dmt);
/*
* Return the device-mapper directory
* Configure the device-mapper directory
*/
int dm_set_dev_dir(const char *dir);
const char *dm_dir(void);
#endif /* LIB_DEVICE_MAPPER_H */

View File

@ -23,6 +23,8 @@
#define DEV_DIR "/dev/"
#define ALIGNMENT sizeof(int)
static char _dm_dir[PATH_MAX] = DEV_DIR DM_DIR;
/*
* Library users can provide their own logging
* function.
@ -292,9 +294,13 @@ static int _add_dev_node(const char *dev_name, dev_t dev)
static int _rm_dev_node(const char *dev_name)
{
char path[PATH_MAX];
struct stat info;
_build_dev_path(path, sizeof(path), dev_name);
if (stat(path, &info) < 0)
return 1;
if (unlink(path) < 0) {
log("Unable to unlink device node for '%s'", dev_name);
return 0;
@ -308,13 +314,16 @@ int dm_task_run(struct dm_task *dmt)
int fd = -1;
struct dm_ioctl *dmi = _flatten(dmt);
unsigned int command;
char control[PATH_MAX];
if (!dmi) {
log("Couldn't create ioctl argument");
return 0;
}
if ((fd = open(DEV_DIR DM_DIR "/control", O_RDWR)) < 0) {
snprintf(control, sizeof(control), "%s/control", _dm_dir);
if ((fd = open(control, O_RDWR)) < 0) {
log("Couldn't open device-mapper control device");
goto bad;
}
@ -376,7 +385,13 @@ int dm_task_run(struct dm_task *dmt)
return 0;
}
int dm_set_dev_dir(const char *dir)
{
snprintf(_dm_dir, sizeof(_dm_dir), "%s/%s", dir, DM_DIR);
return 1;
}
const char *dm_dir(void)
{
return DM_DIR;
return _dm_dir;
}