mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Add dm_task_no_open_count() to skip getting open_count.
This commit is contained in:
parent
bfe848e1e9
commit
8e2dd0dfb2
@ -1,5 +1,6 @@
|
||||
Version 1.00.22 -
|
||||
Version 1.01.00 -
|
||||
============================
|
||||
Add dm_task_no_open_count() to skip getting open_count.
|
||||
|
||||
Version 1.00.21 - 7 Jan 2005
|
||||
============================
|
||||
|
@ -20,6 +20,7 @@ dm_task_set_minor
|
||||
dm_task_set_sector
|
||||
dm_task_set_message
|
||||
dm_task_add_target
|
||||
dm_task_no_open_count
|
||||
dm_get_next_target
|
||||
dm_task_run
|
||||
dm_set_dev_dir
|
||||
|
@ -929,6 +929,13 @@ int dm_task_set_sector(struct dm_task *dmt, uint64_t sector)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int dm_task_no_open_count(struct dm_task *dmt)
|
||||
{
|
||||
dmt->no_open_count = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int dm_task_set_event_nr(struct dm_task *dmt, uint32_t event_nr)
|
||||
{
|
||||
dmt->event_nr = event_nr;
|
||||
@ -1298,8 +1305,13 @@ int dm_task_run(struct dm_task *dmt)
|
||||
dmi->flags |= DM_STATUS_TABLE_FLAG;
|
||||
|
||||
dmi->flags |= DM_EXISTS_FLAG; /* FIXME */
|
||||
log_debug("dm %s %s %s %s%.0llu %s", _cmd_data_v4[dmt->type].name,
|
||||
|
||||
if (dmt->no_open_count)
|
||||
dmi->flags |= DM_SKIP_BDGET_FLAG;
|
||||
|
||||
log_debug("dm %s %s %s %s%c %.0llu %s", _cmd_data_v4[dmt->type].name,
|
||||
dmi->name, dmi->uuid, dmt->newname ? dmt->newname : "",
|
||||
dmt->no_open_count ? 'N' : 'O',
|
||||
dmt->sector, dmt->message ? dmt->message : "");
|
||||
if (ioctl(_control_fd, command, dmi) < 0) {
|
||||
if (errno == ENXIO && ((dmt->type == DM_DEVICE_INFO) ||
|
||||
|
@ -51,6 +51,7 @@ struct dm_task {
|
||||
char *newname;
|
||||
char *message;
|
||||
uint64_t sector;
|
||||
int no_open_count;
|
||||
|
||||
char *uuid;
|
||||
};
|
||||
|
@ -134,6 +134,7 @@ int dm_task_set_major(struct dm_task *dmt, int major);
|
||||
int dm_task_set_event_nr(struct dm_task *dmt, uint32_t event_nr);
|
||||
int dm_task_set_message(struct dm_task *dmt, const char *message);
|
||||
int dm_task_set_sector(struct dm_task *dmt, uint64_t sector);
|
||||
int dm_task_no_open_count(struct dm_task *dmt);
|
||||
|
||||
/*
|
||||
* Use these to prepare for a create or reload.
|
||||
|
@ -58,6 +58,7 @@ enum {
|
||||
MAJOR_ARG,
|
||||
MINOR_ARG,
|
||||
NOHEADINGS_ARG,
|
||||
NOOPENCOUNT_ARG,
|
||||
NOTABLE_ARG,
|
||||
UUID_ARG,
|
||||
VERBOSE_ARG,
|
||||
@ -291,6 +292,9 @@ static int _load(int argc, char **argv, void *data)
|
||||
if (_switches[READ_ONLY] && !dm_task_set_ro(dmt))
|
||||
goto out;
|
||||
|
||||
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
||||
goto out;
|
||||
|
||||
if (!dm_task_run(dmt))
|
||||
goto out;
|
||||
|
||||
@ -335,6 +339,9 @@ static int _create(int argc, char **argv, void *data)
|
||||
if (_switches[MINOR_ARG] && !dm_task_set_minor(dmt, _values[MINOR_ARG]))
|
||||
goto out;
|
||||
|
||||
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
||||
goto out;
|
||||
|
||||
if (!dm_task_run(dmt))
|
||||
goto out;
|
||||
|
||||
@ -364,6 +371,9 @@ static int _rename(int argc, char **argv, void *data)
|
||||
if (!dm_task_set_newname(dmt, argv[argc - 1]))
|
||||
goto out;
|
||||
|
||||
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
||||
goto out;
|
||||
|
||||
if (!dm_task_run(dmt))
|
||||
goto out;
|
||||
|
||||
@ -420,6 +430,9 @@ static int _message(int argc, char **argv, void *data)
|
||||
|
||||
free(str);
|
||||
|
||||
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
||||
goto out;
|
||||
|
||||
if (!dm_task_run(dmt))
|
||||
goto out;
|
||||
|
||||
@ -476,6 +489,9 @@ static int _simple(int task, const char *name, uint32_t event_nr, int display)
|
||||
if (event_nr && !dm_task_set_event_nr(dmt, event_nr))
|
||||
goto out;
|
||||
|
||||
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
||||
goto out;
|
||||
|
||||
r = dm_task_run(dmt);
|
||||
|
||||
if (r && display && _switches[VERBOSE_ARG])
|
||||
@ -599,6 +615,9 @@ static int _status(int argc, char **argv, void *data)
|
||||
if (!_set_task_device(dmt, name, 0))
|
||||
goto out;
|
||||
|
||||
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
||||
goto out;
|
||||
|
||||
if (!dm_task_run(dmt))
|
||||
goto out;
|
||||
|
||||
@ -674,6 +693,9 @@ static int _mknodes(int argc, char **argv, void *data)
|
||||
if (!_set_task_device(dmt, argc > 1 ? argv[1] : NULL, 1))
|
||||
goto out;
|
||||
|
||||
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
||||
goto out;
|
||||
|
||||
if (!dm_task_run(dmt))
|
||||
goto out;
|
||||
|
||||
@ -707,6 +729,9 @@ static int _info(int argc, char **argv, void *data)
|
||||
if (!_set_task_device(dmt, name, 0))
|
||||
goto out;
|
||||
|
||||
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
||||
goto out;
|
||||
|
||||
if (!dm_task_run(dmt))
|
||||
goto out;
|
||||
|
||||
@ -744,6 +769,9 @@ static int _deps(int argc, char **argv, void *data)
|
||||
if (!_set_task_device(dmt, name, 0))
|
||||
goto out;
|
||||
|
||||
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
||||
goto out;
|
||||
|
||||
if (!dm_task_run(dmt))
|
||||
goto out;
|
||||
|
||||
@ -841,7 +869,7 @@ static void _usage(FILE *out)
|
||||
|
||||
fprintf(out, "Usage:\n\n");
|
||||
fprintf(out, "dmsetup [--version] [-v|--verbose [-v|--verbose ...]]\n"
|
||||
" [-r|--readonly]\n\n");
|
||||
" [-r|--readonly] [--noopencount]\n\n");
|
||||
for (i = 0; _commands[i].name; i++)
|
||||
fprintf(out, "\t%s %s\n", _commands[i].name, _commands[i].help);
|
||||
fprintf(out, "\n<device> may be device name or -u <uuid> or "
|
||||
@ -873,6 +901,7 @@ static int _process_switches(int *argc, char ***argv)
|
||||
{"major", 1, NULL, MAJOR_ARG},
|
||||
{"minor", 1, NULL, MINOR_ARG},
|
||||
{"noheadings", 0, NULL, NOHEADINGS_ARG},
|
||||
{"noopencount", 0, NULL, NOOPENCOUNT_ARG},
|
||||
{"notable", 0, NULL, NOTABLE_ARG},
|
||||
{"uuid", 1, NULL, UUID_ARG},
|
||||
{"verbose", 1, NULL, VERBOSE_ARG},
|
||||
@ -915,6 +944,8 @@ static int _process_switches(int *argc, char ***argv)
|
||||
}
|
||||
if ((ind == NOHEADINGS_ARG))
|
||||
_switches[NOHEADINGS_ARG]++;
|
||||
if ((ind == NOOPENCOUNT_ARG))
|
||||
_switches[NOOPENCOUNT_ARG]++;
|
||||
if ((ind == VERSION_ARG))
|
||||
_switches[VERSION_ARG]++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user