From 5a923ff8ad346e635422c8b11e8911d11b43ff4a Mon Sep 17 00:00:00 2001 From: Peter Rajnoha Date: Wed, 15 Feb 2012 12:02:58 +0000 Subject: [PATCH] Add --manglename option to dmsetup to select the name mangling mode. --- WHATS_NEW_DM | 1 + tools/dmsetup.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index a70630600..7cf2d67c7 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.71 - ==================================== + Add --manglename option to dmsetup to select the name mangling mode. Add dm_task_get_name_mangled/unmangled to libdevmapper. Mangle device name on dm_task_set_name/newname call if necessary. Add dm_set/get_name_mangling_mode to set/get name mangling in libdevmapper. diff --git a/tools/dmsetup.c b/tools/dmsetup.c index f59d39d23..1c41f7fa2 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -126,6 +126,7 @@ enum { GID_ARG, HELP_ARG, INACTIVE_ARG, + MANGLENAME_ARG, MAJOR_ARG, MINOR_ARG, MODE_ARG, @@ -2908,7 +2909,7 @@ static void _usage(FILE *out) fprintf(out, "Usage:\n\n"); fprintf(out, "dmsetup [--version] [-h|--help [-c|-C|--columns]]\n" - " [--checks] [-v|--verbose [-v|--verbose ...]]\n" + " [--checks] [--manglename ] [-v|--verbose [-v|--verbose ...]]\n" " [-r|--readonly] [--noopencount] [--nolockfs] [--inactive]\n" " [--udevcookie [cookie]] [--noudevrules] [--noudevsync] [--verifyudev]\n" " [-y|--yes] [--readahead [+]|auto|none] [--retry]\n" @@ -2918,6 +2919,7 @@ static void _usage(FILE *out) fprintf(out, "\t%s %s\n", _commands[i].name, _commands[i].help); fprintf(out, "\n may be device name or -u or " "-j -m \n"); + fprintf(out, " is one of 'none', 'auto' and 'hex'.\n"); fprintf(out, " are comma-separated. Use 'help -c' for list.\n"); fprintf(out, "Table_file contents may be supplied on stdin.\n"); fprintf(out, "Options are: devno, devname, blkdevname.\n"); @@ -3322,6 +3324,7 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir) {"gid", 1, &ind, GID_ARG}, {"help", 0, &ind, HELP_ARG}, {"inactive", 0, &ind, INACTIVE_ARG}, + {"manglename", 1, &ind, MANGLENAME_ARG}, {"major", 1, &ind, MAJOR_ARG}, {"minor", 1, &ind, MINOR_ARG}, {"mode", 1, &ind, MODE_ARG}, @@ -3494,6 +3497,20 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir) } if (ind == INACTIVE_ARG) _switches[INACTIVE_ARG]++; + if ((ind == MANGLENAME_ARG)) { + _switches[MANGLENAME_ARG]++; + if (!strcasecmp(optarg, "none")) + _int_args[MANGLENAME_ARG] = DM_STRING_MANGLING_NONE; + else if (!strcasecmp(optarg, "auto")) + _int_args[MANGLENAME_ARG] = DM_STRING_MANGLING_AUTO; + else if (!strcasecmp(optarg, "hex")) + _int_args[MANGLENAME_ARG] = DM_STRING_MANGLING_HEX; + else { + log_error("Unknown name mangling mode"); + return 0; + } + dm_set_name_mangling_mode(_int_args[MANGLENAME_ARG]); + } if (ind == NAMEPREFIXES_ARG) _switches[NAMEPREFIXES_ARG]++; if (ind == NOFLUSH_ARG)