1
0
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:
Alasdair Kergon 2002-03-07 20:56:10 +00:00
parent 11d2da4036
commit e09a7b5787
3 changed files with 66 additions and 68 deletions

View File

@ -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;
}

View File

@ -20,7 +20,6 @@
* each ioctl command you want to execute.
*/
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.

View File

@ -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;
@ -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,7 +313,6 @@ static int _deps(int argc, char **argv)
return r;
}
/*
* dispatch table
*/
@ -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},
@ -342,8 +345,7 @@ static void _usage(FILE *out)
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;
}