mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
o dm_destroy_all() called on exit - but doesn't touch suspended devices yet.
o 'dmsetup remove_all' calls dm_destroy_all() to provide a quick way to prepare for unloading the module o Ran through indent again.
This commit is contained in:
parent
11d2da4036
commit
e09a7b5787
@ -43,8 +43,7 @@ void dm_task_destroy(struct dm_task *dmt)
|
||||
free(dmt);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (!dmt->dmi)
|
||||
return 0;
|
||||
@ -97,8 +96,7 @@ int dm_task_set_newname(struct dm_task *dmt, const char *newname)
|
||||
}
|
||||
|
||||
struct target *create_target(uint64_t start,
|
||||
uint64_t len,
|
||||
const char *type, const char *params)
|
||||
uint64_t len, const char *type, const char *params)
|
||||
{
|
||||
struct target *t = malloc(sizeof(*t));
|
||||
|
||||
@ -278,6 +276,10 @@ int dm_task_run(struct dm_task *dmt)
|
||||
command = DM_REMOVE;
|
||||
break;
|
||||
|
||||
case DM_DEVICE_REMOVE_ALL:
|
||||
command = DM_REMOVE_ALL;
|
||||
break;
|
||||
|
||||
case DM_DEVICE_SUSPEND:
|
||||
command = DM_SUSPEND;
|
||||
break;
|
||||
@ -334,4 +336,3 @@ int dm_task_run(struct dm_task *dmt)
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,7 @@
|
||||
* each ioctl command you want to execute.
|
||||
*/
|
||||
|
||||
|
||||
typedef void (*dm_log_fn)(int level, const char *file, int line,
|
||||
typedef void (*dm_log_fn) (int level, const char *file, int line,
|
||||
const char *f, ...);
|
||||
|
||||
/*
|
||||
@ -35,6 +34,7 @@ enum {
|
||||
DM_DEVICE_CREATE,
|
||||
DM_DEVICE_RELOAD,
|
||||
DM_DEVICE_REMOVE,
|
||||
DM_DEVICE_REMOVE_ALL,
|
||||
|
||||
DM_DEVICE_SUSPEND,
|
||||
DM_DEVICE_RESUME,
|
||||
@ -46,7 +46,6 @@ enum {
|
||||
DM_DEVICE_VERSION,
|
||||
};
|
||||
|
||||
|
||||
struct dm_task;
|
||||
|
||||
struct dm_task *dm_task_create(int type);
|
||||
@ -74,8 +73,7 @@ struct dm_deps {
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
struct dm_deps *dm_task_get_deps(struct dm_task *dmt);
|
||||
@ -89,9 +87,7 @@ int dm_task_set_minor(struct dm_task *dmt, int minor);
|
||||
*/
|
||||
int dm_task_add_target(struct dm_task *dmt,
|
||||
uint64_t start,
|
||||
uint64_t size,
|
||||
const char *ttype,
|
||||
const char *params);
|
||||
uint64_t size, const char *ttype, const char *params);
|
||||
|
||||
/*
|
||||
* Call this to actually run the ioctl.
|
||||
|
@ -36,7 +36,6 @@ enum {
|
||||
static int _switches[NUM_SWITCHES];
|
||||
static int _values[NUM_SWITCHES];
|
||||
|
||||
|
||||
/*
|
||||
* Commands
|
||||
*/
|
||||
@ -63,8 +62,7 @@ static int _parse_file(struct dm_task *dmt, const char *file)
|
||||
*ptr = '\0';
|
||||
|
||||
/* trim leading space */
|
||||
for (ptr = buffer; *ptr && isspace((int) *ptr); ptr++)
|
||||
;
|
||||
for (ptr = buffer; *ptr && isspace((int) *ptr); ptr++) ;
|
||||
|
||||
if (!*ptr || *ptr == '#')
|
||||
continue;
|
||||
@ -116,7 +114,7 @@ static int _load(int task, const char *name, const char *file)
|
||||
|
||||
r = 1;
|
||||
|
||||
out:
|
||||
out:
|
||||
dm_task_destroy(dmt);
|
||||
|
||||
return r;
|
||||
@ -151,7 +149,7 @@ static int _rename(int argc, char **argv)
|
||||
|
||||
r = 1;
|
||||
|
||||
out:
|
||||
out:
|
||||
dm_task_destroy(dmt);
|
||||
|
||||
return r;
|
||||
@ -172,7 +170,7 @@ static int _version(int argc, char **argv)
|
||||
if (!dm_task_run(dmt))
|
||||
goto out;
|
||||
|
||||
if (!dm_task_get_driver_version(dmt, (char *)&version,
|
||||
if (!dm_task_get_driver_version(dmt, (char *) &version,
|
||||
sizeof(version)))
|
||||
goto out;
|
||||
|
||||
@ -206,6 +204,11 @@ static int _simple(int task, const char *name)
|
||||
return r;
|
||||
}
|
||||
|
||||
static int _remove_all(int argc, char **argv)
|
||||
{
|
||||
return _simple(DM_DEVICE_REMOVE_ALL, "");
|
||||
}
|
||||
|
||||
static int _remove(int argc, char **argv)
|
||||
{
|
||||
return _simple(DM_DEVICE_REMOVE, argv[1]);
|
||||
@ -310,11 +313,10 @@ static int _deps(int argc, char **argv)
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* dispatch table
|
||||
*/
|
||||
typedef int (*command_fn)(int argc, char **argv);
|
||||
typedef int (*command_fn) (int argc, char **argv);
|
||||
|
||||
struct command {
|
||||
char *name;
|
||||
@ -326,6 +328,7 @@ struct command {
|
||||
static struct command _commands[] = {
|
||||
{"create", "<dev_name> <table_file>", 2, _create},
|
||||
{"remove", "<dev_name>", 1, _remove},
|
||||
{"remove_all", "", 0, _remove_all},
|
||||
{"suspend", "<dev_name>", 1, _suspend},
|
||||
{"resume", "<dev_name>", 1, _resume},
|
||||
{"reload", "<dev_name> <table_file>", 2, _reload},
|
||||
@ -336,14 +339,13 @@ static struct command _commands[] = {
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
static void _usage(FILE *out)
|
||||
static void _usage(FILE * out)
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf(out, "usage:\n");
|
||||
for (i = 0; _commands[i].name; i++)
|
||||
fprintf(out, "\t%s %s\n",
|
||||
_commands[i].name, _commands[i].help);
|
||||
fprintf(out, "\t%s %s\n", _commands[i].name, _commands[i].help);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -423,4 +425,3 @@ int main(int argc, char **argv)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user