X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Flvm.c;h=143c5a810447fe5e468ee655b6a1f5c76137ef30;hb=e395d7db8fd3fe3d1b121258fe2f401d6b3e64c8;hp=63a3e7e59b35423aea1720a14d41e0b7b90c1266;hpb=85ed8cef99c19b4143844991d14e0b848fecc5da;p=libguestfs.git diff --git a/daemon/lvm.c b/daemon/lvm.c index 63a3e7e..143c5a8 100644 --- a/daemon/lvm.c +++ b/daemon/lvm.c @@ -171,11 +171,13 @@ do_lvs_full (void) } int -do_pvcreate (const char *device) +do_pvcreate (char *device) { char *err; int r; + IS_DEVICE (device, -1); + r = command (NULL, &err, "/sbin/lvm", "pvcreate", device, NULL); if (r == -1) { @@ -189,12 +191,16 @@ do_pvcreate (const char *device) } int -do_vgcreate (const char *volgroup, char * const* const physvols) +do_vgcreate (char *volgroup, char **physvols) { char *err; int r, argc, i; const char **argv; + /* Check they are devices and also do device name translation. */ + for (i = 0; physvols[i] != NULL; ++i) + IS_DEVICE (physvols[i], -1); + argc = count_strings (physvols) + 3; argv = malloc (sizeof (char *) * (argc + 1)); if (argv == NULL) { @@ -219,7 +225,7 @@ do_vgcreate (const char *volgroup, char * const* const physvols) } int -do_lvcreate (const char *logvol, const char *volgroup, int mbytes) +do_lvcreate (char *logvol, char *volgroup, int mbytes) { char *err; int r; @@ -240,6 +246,30 @@ do_lvcreate (const char *logvol, const char *volgroup, int mbytes) return 0; } +int +do_lvresize (char *logvol, int mbytes) +{ + char *err; + int r; + char size[64]; + + IS_DEVICE (logvol, -1); + + snprintf (size, sizeof size, "%d", mbytes); + + r = command (NULL, &err, + "/sbin/lvm", "lvresize", + "-L", size, logvol, NULL); + if (r == -1) { + reply_with_error ("lvresize: %s", err); + free (err); + return -1; + } + + free (err); + return 0; +} + /* Super-dangerous command used for testing. It removes all * LVs, VGs and PVs permanently. */ @@ -306,11 +336,13 @@ do_lvm_remove_all (void) } int -do_lvremove (const char *device) +do_lvremove (char *device) { char *err; int r; + IS_DEVICE (device, -1); + r = command (NULL, &err, "/sbin/lvm", "lvremove", "-f", device, NULL); if (r == -1) { @@ -324,7 +356,7 @@ do_lvremove (const char *device) } int -do_vgremove (const char *device) +do_vgremove (char *device) { char *err; int r; @@ -342,11 +374,13 @@ do_vgremove (const char *device) } int -do_pvremove (const char *device) +do_pvremove (char *device) { char *err; int r; + IS_DEVICE (device, -1); + r = command (NULL, &err, "/sbin/lvm", "pvremove", "-ff", device, NULL); if (r == -1) { @@ -360,11 +394,13 @@ do_pvremove (const char *device) } int -do_pvresize (const char *device) +do_pvresize (char *device) { char *err; int r; + IS_DEVICE (device, -1); + r = command (NULL, &err, "/sbin/lvm", "pvresize", device, NULL); if (r == -1) { @@ -378,7 +414,7 @@ do_pvresize (const char *device) } int -do_vg_activate (int activate, char * const* const volgroups) +do_vg_activate (int activate, char **volgroups) { char *err; int r, i, argc;