mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
o Add support for getting dependencies for a device.
o dmsetup dependencies <dev>
This commit is contained in:
parent
c021b9bb83
commit
761e0a63e1
@ -75,6 +75,11 @@ int dm_task_get_info(struct dm_task *dmt, struct dm_info *info)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct dm_deps *dm_task_get_deps(struct dm_task *dmt)
|
||||||
|
{
|
||||||
|
return (struct dm_deps *) (((void *) dmt->dmi) + dmt->dmi->data_start);
|
||||||
|
}
|
||||||
|
|
||||||
int dm_task_set_ro(struct dm_task *dmt)
|
int dm_task_set_ro(struct dm_task *dmt)
|
||||||
{
|
{
|
||||||
dmt->read_only = 1;
|
dmt->read_only = 1;
|
||||||
@ -171,6 +176,8 @@ static void *_add_target(struct target *t, void *out, void *end)
|
|||||||
|
|
||||||
static struct dm_ioctl *_flatten(struct dm_task *dmt)
|
static struct dm_ioctl *_flatten(struct dm_task *dmt)
|
||||||
{
|
{
|
||||||
|
const size_t min_size = 16 * 1024;
|
||||||
|
|
||||||
struct dm_ioctl *dmi;
|
struct dm_ioctl *dmi;
|
||||||
struct target *t;
|
struct target *t;
|
||||||
size_t len = sizeof(struct dm_ioctl);
|
size_t len = sizeof(struct dm_ioctl);
|
||||||
@ -191,6 +198,13 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt)
|
|||||||
if (dmt->newname)
|
if (dmt->newname)
|
||||||
len += strlen(dmt->newname) + 1;
|
len += strlen(dmt->newname) + 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Give len a minimum size so that we have space to store
|
||||||
|
* dependencies or status information.
|
||||||
|
*/
|
||||||
|
if (len < min_size)
|
||||||
|
len = min_size;
|
||||||
|
|
||||||
if (!(dmi = malloc(len)))
|
if (!(dmi = malloc(len)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -276,6 +290,10 @@ int dm_task_run(struct dm_task *dmt)
|
|||||||
command = DM_INFO;
|
command = DM_INFO;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DM_DEVICE_DEPS:
|
||||||
|
command = DM_DEP;
|
||||||
|
break;
|
||||||
|
|
||||||
case DM_DEVICE_RENAME:
|
case DM_DEVICE_RENAME:
|
||||||
command = DM_RENAME;
|
command = DM_RENAME;
|
||||||
break;
|
break;
|
||||||
|
@ -39,6 +39,7 @@ enum {
|
|||||||
DM_DEVICE_RESUME,
|
DM_DEVICE_RESUME,
|
||||||
|
|
||||||
DM_DEVICE_INFO,
|
DM_DEVICE_INFO,
|
||||||
|
DM_DEVICE_DEPS,
|
||||||
DM_DEVICE_RENAME,
|
DM_DEVICE_RENAME,
|
||||||
|
|
||||||
DM_DEVICE_VERSION,
|
DM_DEVICE_VERSION,
|
||||||
@ -66,10 +67,18 @@ struct dm_info {
|
|||||||
unsigned int target_count;
|
unsigned int target_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct dm_deps {
|
||||||
|
unsigned int count;
|
||||||
|
dev_t device[0];
|
||||||
|
};
|
||||||
|
|
||||||
int dm_get_library_version(char *version, size_t size);
|
int dm_get_library_version(char *version, size_t size);
|
||||||
int dm_task_get_driver_version(struct dm_task *dmt, char *version, size_t size);
|
int dm_task_get_driver_version(struct dm_task *dmt, char *version,
|
||||||
|
size_t size);
|
||||||
int dm_task_get_info(struct dm_task *dmt, struct dm_info *dmi);
|
int dm_task_get_info(struct dm_task *dmt, struct dm_info *dmi);
|
||||||
|
|
||||||
|
struct dm_deps *dm_task_get_deps(struct dm_task *dmt);
|
||||||
|
|
||||||
int dm_task_set_ro(struct dm_task *dmt);
|
int dm_task_set_ro(struct dm_task *dmt);
|
||||||
int dm_task_set_newname(struct dm_task *dmt, const char *newname);
|
int dm_task_set_newname(struct dm_task *dmt, const char *newname);
|
||||||
int dm_task_set_minor(struct dm_task *dmt, int minor);
|
int dm_task_set_minor(struct dm_task *dmt, int minor);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <linux/kdev_t.h>
|
||||||
|
|
||||||
#define LINE_SIZE 1024
|
#define LINE_SIZE 1024
|
||||||
|
|
||||||
@ -264,6 +265,48 @@ static int _info(int argc, char **argv)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _deps(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int r = 0, i;
|
||||||
|
struct dm_deps *deps;
|
||||||
|
|
||||||
|
/* remove <dev_name> */
|
||||||
|
struct dm_task *dmt;
|
||||||
|
struct dm_info info;
|
||||||
|
|
||||||
|
if (!(dmt = dm_task_create(DM_DEVICE_DEPS)))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!dm_task_set_name(dmt, argv[1]))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (!dm_task_run(dmt))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (!(deps = dm_task_get_deps(dmt)))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (!info.exists) {
|
||||||
|
printf("Device does not exist.\n");
|
||||||
|
r = 1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%d dependencies\t:", deps->count);
|
||||||
|
|
||||||
|
for (i = 0; i < deps->count; i++)
|
||||||
|
printf(" (%d, %d)",
|
||||||
|
(int) MAJOR(deps->device[i]),
|
||||||
|
(int) MINOR(deps->device[i]));
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
r = 1;
|
||||||
|
|
||||||
|
out:
|
||||||
|
dm_task_destroy(dmt);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* dispatch table
|
* dispatch table
|
||||||
@ -284,6 +327,7 @@ static struct command _commands[] = {
|
|||||||
{"resume", "<dev_name>", 1, _resume},
|
{"resume", "<dev_name>", 1, _resume},
|
||||||
{"reload", "<dev_name> <table_file>", 2, _reload},
|
{"reload", "<dev_name> <table_file>", 2, _reload},
|
||||||
{"info", "<dev_name>", 1, _info},
|
{"info", "<dev_name>", 1, _info},
|
||||||
|
{"dependencies", "<dev_name>", 1, _deps},
|
||||||
{"rename", "<dev_name> <new_name>", 2, _rename},
|
{"rename", "<dev_name> <new_name>", 2, _rename},
|
||||||
{"version", "", 0, _version},
|
{"version", "", 0, _version},
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
|
Loading…
Reference in New Issue
Block a user