From 181ea9a38139d7c6a7509a108c6fd82a396ae103 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Wed, 12 Jan 2005 22:10:14 +0000 Subject: [PATCH] Add dm_task_no_open_count() to skip getting open_count. --- WHATS_NEW_DM | 3 ++- libdm/.exported_symbols | 1 + libdm/ioctl/libdm-iface.c | 14 +++++++++++++- libdm/ioctl/libdm-targets.h | 1 + libdm/libdevmapper.h | 1 + tools/dmsetup.c | 33 ++++++++++++++++++++++++++++++++- 6 files changed, 50 insertions(+), 3 deletions(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index d14edcc07..c2bb6a5d6 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -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 ============================ diff --git a/libdm/.exported_symbols b/libdm/.exported_symbols index 01fe677e9..413148940 100644 --- a/libdm/.exported_symbols +++ b/libdm/.exported_symbols @@ -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 diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c index 47ea7147b..621d8db49 100644 --- a/libdm/ioctl/libdm-iface.c +++ b/libdm/ioctl/libdm-iface.c @@ -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) || diff --git a/libdm/ioctl/libdm-targets.h b/libdm/ioctl/libdm-targets.h index ecd6eabfd..d25efe17d 100644 --- a/libdm/ioctl/libdm-targets.h +++ b/libdm/ioctl/libdm-targets.h @@ -51,6 +51,7 @@ struct dm_task { char *newname; char *message; uint64_t sector; + int no_open_count; char *uuid; }; diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h index f0aeccde3..8cab2d94c 100644 --- a/libdm/libdevmapper.h +++ b/libdm/libdevmapper.h @@ -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. diff --git a/tools/dmsetup.c b/tools/dmsetup.c index 9c169a6e1..a3223f477 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -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 may be device name or -u 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]++; }