]> sourceware.org Git - dm.git/commitdiff
Add major arg
authorAlasdair Kergon <agk@redhat.com>
Fri, 4 Apr 2003 13:22:58 +0000 (13:22 +0000)
committerAlasdair Kergon <agk@redhat.com>
Fri, 4 Apr 2003 13:22:58 +0000 (13:22 +0000)
dmsetup/dmsetup.c

index 8249cf7852b71809582812a3fee1c4eba431d405..e89e0cec57963c2429fca5087e73dd1673086a75 100644 (file)
@@ -22,6 +22,7 @@
  */
 enum {
        READ_ONLY = 0,
+       MAJOR_ARG,
        MINOR_ARG,
        VERBOSE_ARG,
        NUM_SWITCHES
@@ -103,6 +104,9 @@ static int _load(int task, const char *name, const char *file, const char *uuid)
        if (_switches[READ_ONLY] && !dm_task_set_ro(dmt))
                goto out;
 
+       if (_switches[MAJOR_ARG] && !dm_task_set_major(dmt, _values[MAJOR_ARG]))
+               goto out;
+
        if (_switches[MINOR_ARG] && !dm_task_set_minor(dmt, _values[MINOR_ARG]))
                goto out;
 
@@ -255,7 +259,7 @@ static int _status(int argc, char **argv)
                next = dm_get_next_target(dmt, next, &start, &length,
                                          &target_type, &params);
                if (target_type) {
-                       printf("%"PRIu64" %"PRIu64" %s %s\n",
+                       printf("%" PRIu64 " %" PRIu64 " %s %s\n",
                               start, length, target_type, params);
                }
        } while (next);
@@ -394,7 +398,7 @@ static struct command _commands[] = {
        {NULL, NULL, 0, 0, NULL}
 };
 
-static void _usage(FILE * out)
+static void _usage(FILE *out)
 {
        int i;
 
@@ -422,6 +426,7 @@ static int _process_switches(int *argc, char ***argv)
 
        static struct option long_options[] = {
                {"read-only", 0, NULL, READ_ONLY},
+               {"major", 1, NULL, MAJOR_ARG},
                {"minor", 1, NULL, MINOR_ARG},
                {"verbose", 1, NULL, VERBOSE_ARG},
                {"", 0, NULL, 0}
@@ -433,10 +438,14 @@ static int _process_switches(int *argc, char ***argv)
        memset(&_switches, 0, sizeof(_switches));
        memset(&_values, 0, sizeof(_values));
 
-       while ((c = getopt_long(*argc, *argv, "m:rv",
+       while ((c = getopt_long(*argc, *argv, "j:m:rv",
                                long_options, &ind)) != -1) {
                if (c == 'r' || ind == READ_ONLY)
                        _switches[READ_ONLY]++;
+               if (c == 'j' || ind == MAJOR_ARG) {
+                       _switches[MAJOR_ARG]++;
+                       _values[MAJOR_ARG] = atoi(optarg);
+               }
                if (c == 'm' || ind == MINOR_ARG) {
                        _switches[MINOR_ARG]++;
                        _values[MINOR_ARG] = atoi(optarg);
This page took 0.034056 seconds and 5 git commands to generate.