CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-10-31 18:53:34 Added files: tools : dmsetup.c Log message: move dmsetup here - will be edited in repo to retain hist Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1 /cvs/lvm2/LVM2/tools/dmsetup.c,v --> standard output revision 1.1
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2009-08-06 15:05:11 Modified files: tools : dmsetup.c Log message: Add 'udevcookies' command for dmsetup. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.121&r2=1.122 --- LVM2/tools/dmsetup.c 2009/08/06 15:04:30 1.121 +++ LVM2/tools/dmsetup.c 2009/08/06 15:05:10 1.122 @@ -36,6 +36,7 @@ #include <sys/param.h> #include <locale.h> #include <langinfo.h> +#include <time.h> #include <fcntl.h> #include <sys/stat.h> @@ -853,6 +854,45 @@ } #endif +static int _udevcookies(int argc __attribute((unused)), char **argv __attribute((unused)), void *data __attribute((unused))) +{ + int max_id, id, sid; + struct seminfo sinfo; + struct semid_ds sdata; + int val; + char *time_str; + + if ((max_id = semctl(0, 0, SEM_INFO, &sinfo)) < 0) { + log_sys_error("sem_ctl", "SEM_INFO"); + return 0; + } + + printf("cookie semid value last_semop_time\n"); + + for (id = 0; id <= max_id; id++) { + if ((sid = semctl(id, 0, SEM_STAT, &sdata)) < 0) + continue; + + if (sdata.sem_perm.__key >> 16 == DM_COOKIE_MAGIC) { + if ((val = semctl(sid, 0, GETVAL)) < 0) { + log_error("semid %d: sem_ctl failed for " + "cookie 0x%" PRIx32 ": %s", + sid, sdata.sem_perm.__key, + strerror(errno)); + continue; + } + + time_str = ctime((const time_t *) &sdata.sem_otime); + + printf("0x%-10x %-10d %-10d %s", sdata.sem_perm.__key, + sid, val, time_str ? time_str : "unknown"); + } + } + + return 1; +} + + static int _version(int argc __attribute((unused)), char **argv __attribute((unused)), void *data __attribute((unused))) { char version[80]; @@ -2385,6 +2425,7 @@ {"mknodes", "[<device>]", 0, 1, _mknodes}, {"udevcomplete", "<cookie>", 1, 1, _udevcomplete}, {"udevcomplete_all", "", 0, 0, _udevcomplete_all}, + {"udevcookies", "", 0, 0, _udevcookies}, {"targets", "", 0, 0, _targets}, {"version", "", 0, 0, _version}, {"setgeometry", "<device> <cyl> <head> <sect> <start>", 5, 5, _setgeometry},
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2009-08-06 15:56:51 Modified files: tools : dmsetup.c Log message: Fix semaphore includes in dmsetup for udev sync. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.122&r2=1.123 --- LVM2/tools/dmsetup.c 2009/08/06 15:05:10 1.122 +++ LVM2/tools/dmsetup.c 2009/08/06 15:56:50 1.123 @@ -280,34 +280,6 @@ struct dm_split_name *split_name; }; -static char _yes_no_prompt(const char *prompt, ...) -{ - int c = 0, ret = 0; - va_list ap; - - do { - if (c == '\n' || !c) { - va_start(ap, prompt); - vprintf(prompt, ap); - va_end(ap); - } - - if ((c = getchar()) == EOF) { - ret = 'n'; - break; - } - - c = tolower(c); - if ((c == 'y') || (c == 'n')) - ret = c; - } while (!ret || c != '\n'); - - if (c != '\n') - printf("\n"); - - return ret; -} - static struct dm_task *_get_deps_task(int major, int minor) { struct dm_task *dmt; @@ -804,8 +776,41 @@ return 1; } +static int _udevcookies(int argc __attribute((unused)), char **argv __attribute((unused)), void *data __attribute((unused))) +{ + return 1; +} + #else +static char _yes_no_prompt(const char *prompt, ...) +{ + int c = 0, ret = 0; + va_list ap; + + do { + if (c == '\n' || !c) { + va_start(ap, prompt); + vprintf(prompt, ap); + va_end(ap); + } + + if ((c = getchar()) == EOF) { + ret = 'n'; + break; + } + + c = tolower(c); + if ((c == 'y') || (c == 'n')) + ret = c; + } while (!ret || c != '\n'); + + if (c != '\n') + printf("\n"); + + return ret; +} + static int _udevcomplete_all(int argc __attribute((unused)), char **argv __attribute((unused)), void *data __attribute((unused))) { int max_id, id, sid; @@ -852,7 +857,6 @@ return 1; } -#endif static int _udevcookies(int argc __attribute((unused)), char **argv __attribute((unused)), void *data __attribute((unused))) { @@ -891,7 +895,7 @@ return 1; } - +#endif static int _version(int argc __attribute((unused)), char **argv __attribute((unused)), void *data __attribute((unused))) {
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2009-12-11 13:04:30 Modified files: tools : dmsetup.c Log message: Fix coredump and memory leak for 'dmsetup help -c' Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.128&r2=1.129 --- LVM2/tools/dmsetup.c 2009/11/13 12:43:22 1.128 +++ LVM2/tools/dmsetup.c 2009/12/11 13:04:30 1.129 @@ -2402,7 +2402,7 @@ size_t len = 0; int r = 0; - if (!strcmp(c->name, "splitname")) + if (c && !strcmp(c->name, "splitname")) options = (char *) splitname_report_options; /* emulate old dmsetup behaviour */ @@ -2591,7 +2591,11 @@ _switches[OPTIONS_ARG] = 1; _string_args[OPTIONS_ARG] = (char *) "help"; _switches[SORT_ARG] = 0; - + + if (_report) { + dm_report_free(_report); + _report = NULL; + } (void) _report_init(NULL); }
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-07-05 22:56:32 Modified files: tools : dmsetup.c Log message: Fix dmlosetup snprintf %llu compiler warning. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.138&r2=1.139 --- LVM2/tools/dmsetup.c 2010/04/28 13:37:37 1.138 +++ LVM2/tools/dmsetup.c 2010/07/05 22:56:31 1.139 @@ -2942,7 +2942,7 @@ close(fd); if (dm_snprintf(table, tlen, "%llu %llu loop %s %llu\n", 0ULL, - (long long unsigned)sectors, file, off) < 0) + (long long unsigned)sectors, file, (long long unsigned)off) < 0) return 0; if (_switches[VERBOSE_ARG] > 1) @@ -2956,8 +2956,6 @@ return 0; } - - static int _process_losetup_switches(const char *base, int *argc, char ***argv, const char *dev_dir) {
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-07-08 13:31:07 Modified files: tools : dmsetup.c Log message: Set return value 0 for 'dmsetup -c -o help' Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.139&r2=1.140 --- LVM2/tools/dmsetup.c 2010/07/05 22:56:31 1.139 +++ LVM2/tools/dmsetup.c 2010/07/08 13:31:03 1.140 @@ -3341,6 +3341,7 @@ if (argc == 0) { _usage(stderr); + r = 0; goto out; }
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-10-25 13:36:58 Modified files: tools : dmsetup.c Log message: Fix constness warning Fix usage of const 'data' pointer and also assign void* directly without uneeded cast for C. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.146&r2=1.147 --- LVM2/tools/dmsetup.c 2010/10/15 01:10:29 1.146 +++ LVM2/tools/dmsetup.c 2010/10/25 13:36:57 1.147 @@ -2399,7 +2399,7 @@ struct dm_report_field *field, const void *data, void *private) { - struct dm_deps *deps = (struct dm_deps *) data; + const struct dm_deps *deps = data; int i; char buf[DM_MAX_TYPE_NAME], *repstr;
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-11-30 22:53:38 Modified files: tools : dmsetup.c Log message: Test uuid for NULL Add test for NULL before passing uuid as src argument to memcpy. As memcpy function is declared as function not accepting NULL. Though we pass NULL only with zero length so this patch presents no functional change to the code. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.148&r2=1.149 --- LVM2/tools/dmsetup.c 2010/11/24 09:43:18 1.148 +++ LVM2/tools/dmsetup.c 2010/11/30 22:53:37 1.149 @@ -343,7 +343,9 @@ return NULL; } - memcpy(uuid_prefix, uuid, len); + if (uuid) + memcpy(uuid_prefix, uuid, len); + uuid_prefix[len] = '\0'; return uuid_prefix;
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-12-20 14:36:12 Modified files: tools : dmsetup.c Log message: Remove dead assignment Variable 'r' is never read so remove it and just cast result from _error_device function to (void). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.150&r2=1.151 --- LVM2/tools/dmsetup.c 2010/12/20 13:37:26 1.150 +++ LVM2/tools/dmsetup.c 2010/12/20 14:36:12 1.151 @@ -1386,10 +1386,8 @@ static int _remove(int argc, char **argv, void *data __attribute__((unused))) { - int r; - if (_switches[FORCE_ARG] && argc > 1) - r = _error_device(argc, argv, NULL); + (void) _error_device(argc, argv, NULL); return _simple(DM_DEVICE_REMOVE, argc > 1 ? argv[1] : NULL, 0, 0); }
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-03-29 21:56:53 Modified files: tools : dmsetup.c Log message: Add attribute printf Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.157&r2=1.158 --- LVM2/tools/dmsetup.c 2011/03/29 21:49:18 1.157 +++ LVM2/tools/dmsetup.c 2011/03/29 21:56:53 1.158 @@ -1050,6 +1050,7 @@ return dm_udev_wait(_udev_cookie); } +__attribute__((format(printf, 1, 2))) static char _yes_no_prompt(const char *prompt, ...) { int c = 0, ret = 0;
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-12-01 14:57:31 Modified files: tools : dmsetup.c Log message: update old comment Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.169&r2=1.170 --- LVM2/tools/dmsetup.c 2011/09/22 17:12:28 1.169 +++ LVM2/tools/dmsetup.c 2011/12/01 14:57:30 1.170 @@ -2049,6 +2049,11 @@ _out_char(']'); } +/* FIXME Display table or status line. (Disallow both?) */ +static void _display_tree_targets(struct dm_tree_node *node, unsigned depth) +{ +} + static void _display_tree_node(struct dm_tree_node *node, unsigned depth, unsigned first_child __attribute__((unused)), unsigned last_child, unsigned has_children) @@ -2109,7 +2114,7 @@ if (TR_PRINT_TARGETS) { _tree_more[depth + 1] = has_children; - // FIXME _display_tree_targets(name, depth + 2); + _display_tree_targets(node, depth + 2); } }
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2012-01-20 10:58:17 Modified files: tools : dmsetup.c Log message: Tiny cleanup Just remove double braces from conditions when they are not really needed. (So it doesn't look like an assignment and comparison). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.172&r2=1.173 --- LVM2/tools/dmsetup.c 2012/01/18 18:52:02 1.172 +++ LVM2/tools/dmsetup.c 2012/01/20 10:58:17 1.173 @@ -3467,32 +3467,32 @@ /* FIXME Accept modes as per chmod */ _int_args[MODE_ARG] = (int) strtol(optarg, NULL, 8); } - if ((ind == EXEC_ARG)) { + if (ind == EXEC_ARG) { _switches[EXEC_ARG]++; _command = optarg; } - if ((ind == TARGET_ARG)) { + if (ind == TARGET_ARG) { _switches[TARGET_ARG]++; _target = optarg; } - if ((ind == INACTIVE_ARG)) - _switches[INACTIVE_ARG]++; - if ((ind == NAMEPREFIXES_ARG)) + if (ind == INACTIVE_ARG) + _switches[INACTIVE_ARG]++; + if (ind == NAMEPREFIXES_ARG) _switches[NAMEPREFIXES_ARG]++; - if ((ind == NOFLUSH_ARG)) + if (ind == NOFLUSH_ARG) _switches[NOFLUSH_ARG]++; - if ((ind == NOHEADINGS_ARG)) + if (ind == NOHEADINGS_ARG) _switches[NOHEADINGS_ARG]++; - if ((ind == NOLOCKFS_ARG)) + if (ind == NOLOCKFS_ARG) _switches[NOLOCKFS_ARG]++; - if ((ind == NOOPENCOUNT_ARG)) + if (ind == NOOPENCOUNT_ARG) _switches[NOOPENCOUNT_ARG]++; - if ((ind == READAHEAD_ARG)) { + if (ind == READAHEAD_ARG) { _switches[READAHEAD_ARG]++; if (!strcasecmp(optarg, "auto")) _int_args[READAHEAD_ARG] = DM_READ_AHEAD_AUTO; else if (!strcasecmp(optarg, "none")) - _int_args[READAHEAD_ARG] = DM_READ_AHEAD_NONE; + _int_args[READAHEAD_ARG] = DM_READ_AHEAD_NONE; else { for (s = optarg; isspace(*s); s++) ; @@ -3507,23 +3507,23 @@ } } } - if ((ind == RETRY_ARG)) + if (ind == RETRY_ARG) _switches[RETRY_ARG]++; - if ((ind == ROWS_ARG)) + if (ind == ROWS_ARG) _switches[ROWS_ARG]++; - if ((ind == SETUUID_ARG)) + if (ind == SETUUID_ARG) _switches[SETUUID_ARG]++; - if ((ind == SHOWKEYS_ARG)) + if (ind == SHOWKEYS_ARG) _switches[SHOWKEYS_ARG]++; - if ((ind == TABLE_ARG)) { + if (ind == TABLE_ARG) { _switches[TABLE_ARG]++; _table = optarg; } - if ((ind == TREE_ARG)) + if (ind == TREE_ARG) _switches[TREE_ARG]++; - if ((ind == UNQUOTED_ARG)) + if (ind == UNQUOTED_ARG) _switches[UNQUOTED_ARG]++; - if ((ind == VERSION_ARG)) + if (ind == VERSION_ARG) _switches[VERSION_ARG]++; }
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2012-02-15 14:21:00 Modified files: tools : dmsetup.c Log message: Fix segfault in dmsetup when using table specification with --table. Segfault introduced with the patch that added dm_free(_table) at the end of dmsetup (in this release). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.179&r2=1.180 --- LVM2/tools/dmsetup.c 2012/02/15 12:08:57 1.179 +++ LVM2/tools/dmsetup.c 2012/02/15 14:20:59 1.180 @@ -3654,7 +3654,11 @@ _switches[SHOWKEYS_ARG]++; if (ind == TABLE_ARG) { _switches[TABLE_ARG]++; - _table = optarg; + if (!(_table = dm_malloc(strlen(optarg + 1)))) { + log_error("Could not allocate memory for table string."); + return 0; + } + strcpy(_table, optarg); } if (ind == TREE_ARG) _switches[TREE_ARG]++;
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2012-02-15 14:27:53 Modified files: tools : dmsetup.c Log message: Simplify with dm_strdup Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.180&r2=1.181 --- LVM2/tools/dmsetup.c 2012/02/15 14:20:59 1.180 +++ LVM2/tools/dmsetup.c 2012/02/15 14:27:53 1.181 @@ -3654,11 +3654,10 @@ _switches[SHOWKEYS_ARG]++; if (ind == TABLE_ARG) { _switches[TABLE_ARG]++; - if (!(_table = dm_malloc(strlen(optarg + 1)))) { + if (!(_table = dm_strdup(optarg))) { log_error("Could not allocate memory for table string."); return 0; } - strcpy(_table, optarg); } if (ind == TREE_ARG) _switches[TREE_ARG]++;
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2012-03-01 21:50:36 Modified files: tools : dmsetup.c Log message: Test alloc fail Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.183&r2=1.184 --- LVM2/tools/dmsetup.c 2012/02/28 14:24:57 1.183 +++ LVM2/tools/dmsetup.c 2012/03/01 21:50:35 1.184 @@ -380,7 +380,9 @@ return NULL; } - split_name->subsystem = _extract_uuid_prefix(uuid, separator); + if (!(split_name->subsystem = _extract_uuid_prefix(uuid, separator))) + return_NULL; + split_name->vg_name = split_name->lv_name = split_name->lv_layer = (char *) "";