]> TLD Linux GIT Repositories - packages/lvm2.git/blob - device-mapper-dmsetup-export.patch
- updated to 2.03.02
[packages/lvm2.git] / device-mapper-dmsetup-export.patch
1 diff -ur LVM2.2.03.02.orig/libdm/dm-tools/dmsetup.c LVM2.2.03.02/libdm/dm-tools/dmsetup.c
2 --- LVM2.2.03.02.orig/libdm/dm-tools/dmsetup.c  2019-03-22 16:55:55.393000000 +0100
3 +++ LVM2.2.03.02/libdm/dm-tools/dmsetup.c       2019-03-22 17:00:55.046000000 +0100
4 @@ -2551,6 +2551,93 @@
5         return r;
6  }
7  
8 +static int _export(CMD_ARGS)
9 +{
10 +       int r = 0;
11 +       struct dm_task *dmt = NULL;
12 +       void *next = NULL;
13 +       uint64_t start, length;
14 +       char *target_type = NULL;
15 +       char *params;
16 +       const char *name = NULL;
17 +       const char *uuid = NULL;
18 +       struct dm_info info;
19 +
20 +       if (names)
21 +               name = names->name;
22 +       else if (argc == 2)
23 +               name = argv[1];
24 +
25 +       if (!(dmt = dm_task_create(DM_DEVICE_STATUS)))
26 +               goto out;
27 +
28 +       if (!_set_task_device(dmt, name, 0))
29 +               goto out;
30 +
31 +       if (!dm_task_run(dmt))
32 +               goto out;
33 +
34 +       if (!dm_task_get_info(dmt, &info) || !info.exists)
35 +               goto out;
36 +
37 +       if (!name)
38 +               name = dm_task_get_name(dmt);
39 +
40 +       uuid = dm_task_get_uuid(dmt);
41 +       printf("DM_NAME=%s\n", name);
42 +
43 +       if ((uuid = dm_task_get_uuid(dmt)) && *uuid)
44 +               printf("DM_UUID=%s\n", uuid);
45 +
46 +       if (!info.exists) {
47 +               printf("DM_STATE=NOTPRESENT\n");
48 +               goto out;
49 +       }
50 +
51 +       printf("DM_STATE=%s\n",
52 +              info.suspended ? "SUSPENDED" :
53 +              (info.read_only ? "READONLY" : "ACTIVE"));
54 +
55 +       if (!info.live_table && !info.inactive_table)
56 +               printf("DM_TABLE_STATE=NONE\n");
57 +       else
58 +               printf("DM_TABLE_STATE=%s%s%s\n",
59 +                      info.live_table ? "LIVE" : "",
60 +                      info.live_table && info.inactive_table ? "/" : "",
61 +                      info.inactive_table ? "INACTIVE" : "");
62 +
63 +       if (info.open_count != -1)
64 +               printf("DM_OPENCOUNT=%d\n", info.open_count);
65 +
66 +       printf("DM_LAST_EVENT_NR=%" PRIu32 "\n", info.event_nr);
67 +
68 +       printf("DM_MAJOR=%d\n", info.major);
69 +       printf("DM_MINOR=%d\n", info.minor);
70 +
71 +       if (info.target_count != -1)
72 +               printf("DM_TARGET_COUNT=%d\n", info.target_count);
73 +
74 +       /* export all table types */
75 +       next = dm_get_next_target(dmt, next, &start, &length,
76 +                                 &target_type, &params);
77 +       if (target_type) {
78 +               printf("DM_TARGET_TYPES=%s", target_type);
79 +               while (next) {
80 +                       next = dm_get_next_target(dmt, next, &start, &length,
81 +                                                 &target_type, &params);
82 +                       if (target_type)
83 +                               printf(",%s", target_type);
84 +               }
85 +               printf("\n");
86 +       }
87 +
88 +       r = 1;
89 +      out:
90 +       if (dmt)
91 +               dm_task_destroy(dmt);
92 +       return r;
93 +}
94 +
95  /* Show target names and their version numbers */
96  static int _targets(CMD_ARGS)
97  {
98 @@ -6230,6 +6317,7 @@
99         {"stats", "<command> [<options>] [<device>...]", 1, -1, 1, 1, _stats},
100         {"status", "[<device>...] [--noflush] [--target <target_type>]", 0, -1, 2, 0, _status},
101         {"table", "[<device>...] [--concise] [--target <target_type>] [--showkeys]", 0, -1, 2, 0, _status},
102 +       {"export", "[<device>]", 0, 1, 1, 0, _export},
103         {"wait", "<device> [<event_nr>] [--noflush]", 0, 2, 0, 0, _wait},
104         {"mknodes", "[<device>...]", 0, -1, 1, 0, _mknodes},
105         {"mangle", "[<device>...]", 0, -1, 1, 0, _mangle},
106 diff -ur LVM2.2.03.02.orig/man/dmsetup.8_main LVM2.2.03.02/man/dmsetup.8_main
107 --- LVM2.2.03.02.orig/man/dmsetup.8_main        2019-03-22 16:55:55.394000000 +0100
108 +++ LVM2.2.03.02/man/dmsetup.8_main     2019-03-22 17:00:55.047000000 +0100
109 @@ -59,6 +59,14 @@
110  .
111  .HP
112  .B dmsetup
113 +.de CMD_EXPORT
114 +.  BR export
115 +.  RI [ device_name ]
116 +..
117 +.CMD_EXPORT
118 +.
119 +.HP
120 +.B dmsetup
121  .de CMD_HELP
122  .  BR help
123  .  RB [ -c | -C | --columns ]
124 @@ -651,6 +659,9 @@
125  \fBdevname\fP (map name for device-mapper devices, equal to blkdevname otherwise).
126  .
127  .HP
128 +.CMD_EXPORT
129 +Outputs information in key/value format to be imported by other programs.
130 +.HP
131  .CMD_HELP
132  .br
133  Outputs a summary of the commands available, optionally including