"List the VGs that are currently open\n");
printf("'vgs': "
"List all VGs known to the system\n");
+ printf("'vg_extend vgname device: "
+ "Issue a lvm_vg_extend() API call on VG 'vgname'\n");
+ printf("'vg_reduce vgname device: "
+ "Issue a lvm_vg_reduce() API call on VG 'vgname'\n");
printf("'vg_open vgname ['r' | 'w']': "
"Issue a lvm_vg_open() API call on VG 'vgname'\n");
printf("'vg_close vgname': "
}
}
+static void _remove_device_from_pvname_hash(struct dm_list *pvs, const char *name)
+{
+ struct lvm_pv_list *pvl;
+ dm_list_iterate_items(pvl, pvs) {
+ if (!strncmp(lvm_pv_get_name(pvl->pv), name, strlen(name)))
+ dm_hash_remove(_pvname_hash, name);
+ }
+}
+static void _add_device_to_pvname_hash(struct dm_list *pvs, const char *name)
+{
+ struct lvm_pv_list *pvl;
+ dm_list_iterate_items(pvl, pvs) {
+ if (!strncmp(lvm_pv_get_name(pvl->pv), name, strlen(name)))
+ dm_hash_insert(_pvname_hash, name, pvl->pv);
+ }
+}
+static void _vg_reduce(char **argv, int argc, lvm_t libh)
+{
+ vg_t *vg;
+ struct dm_list *pvs;
+
+ if (argc < 2) {
+ printf ("Please enter vg_name\n");
+ return;
+ }
+ if (!(vg = dm_hash_lookup(_vgid_hash, argv[1])) &&
+ !(vg = dm_hash_lookup(_vgname_hash, argv[1]))) {
+ printf ("VG not open\n");
+ return;
+ }
+ if (lvm_vg_reduce(vg, argv[2])) {
+ printf("Error reducing %s by %s\n", argv[1], argv[2]);
+ return;
+ }
+
+ printf("Success reducing vg %s by %s\n", argv[1], argv[2]);
+
+ /*
+ * Add the device into the hashes for lookups
+ */
+ pvs = lvm_vg_list_pvs(vg);
+ if (pvs && !dm_list_empty(pvs))
+ _remove_device_from_pvname_hash(pvs, argv[2]);
+}
+
+static void _vg_extend(char **argv, int argc, lvm_t libh)
+{
+ vg_t *vg;
+ struct dm_list *pvs;
+
+ if (argc < 2) {
+ printf ("Please enter vg_name\n");
+ return;
+ }
+ if (!(vg = dm_hash_lookup(_vgid_hash, argv[1])) &&
+ !(vg = dm_hash_lookup(_vgname_hash, argv[1]))) {
+ printf ("VG not open\n");
+ return;
+ }
+ if (lvm_vg_extend(vg, argv[2])) {
+ printf("Error extending %s with %s\n", argv[1], argv[2]);
+ return;
+ }
+
+ printf("Success extending vg %s with %s\n", argv[1], argv[2]);
+
+ /*
+ * Add the device into the hashes for lookups
+ */
+ pvs = lvm_vg_list_pvs(vg);
+ if (pvs && !dm_list_empty(pvs))
+ _add_device_to_pvname_hash(pvs, argv[2]);
+}
+
static void _vg_open(char **argv, int argc, lvm_t libh)
{
vg_t *vg;
break;
} else if (!strcmp(argv[0], "?") || !strcmp(argv[0], "help")) {
_show_help();
+ } else if (!strcmp(argv[0], "vg_extend")) {
+ _vg_extend(argv, argc, libh);
+ } else if (!strcmp(argv[0], "vg_reduce")) {
+ _vg_reduce(argv, argc, libh);
} else if (!strcmp(argv[0], "vg_open")) {
_vg_open(argv, argc, libh);
} else if (!strcmp(argv[0], "vg_close")) {