X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Flvm.c;h=8f575c495592f9c03892f6aefca3f09771b9c49f;hb=fc266e5ab8c4f013d0e473029c5e0b4cd32cca92;hp=c30d4e7be8556e8b4a0e42da838c078a51bfd266;hpb=2df2f2854ed2d1f9857ef3c5aaca29810cf3c506;p=libguestfs.git diff --git a/daemon/lvm.c b/daemon/lvm.c index c30d4e7..8f575c4 100644 --- a/daemon/lvm.c +++ b/daemon/lvm.c @@ -1,5 +1,5 @@ /* libguestfs - the guestfsd daemon - * Copyright (C) 2009 Red Hat Inc. + * Copyright (C) 2009 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -93,7 +93,7 @@ do_pvs (void) int r; r = command (&out, &err, - "/sbin/lvm", "pvs", "-o", "pv_name", "--noheadings", NULL); + "/sbin/lvm", "pvs", "-o", "pv_name", "--noheadings", NULL); if (r == -1) { reply_with_error ("%s", err); free (out); @@ -113,7 +113,7 @@ do_vgs (void) int r; r = command (&out, &err, - "/sbin/lvm", "vgs", "-o", "vg_name", "--noheadings", NULL); + "/sbin/lvm", "vgs", "-o", "vg_name", "--noheadings", NULL); if (r == -1) { reply_with_error ("%s", err); free (out); @@ -133,9 +133,9 @@ do_lvs (void) int r; r = command (&out, &err, - "/sbin/lvm", "lvs", - "-o", "vg_name,lv_name", "--noheadings", - "--separator", "/", NULL); + "/sbin/lvm", "lvs", + "-o", "vg_name,lv_name", "--noheadings", + "--separator", "/", NULL); if (r == -1) { reply_with_error ("%s", err); free (out); @@ -152,34 +152,34 @@ do_lvs (void) * the code. That code is in stubs.c, and it is generated as usual * by generator.ml. */ -guestfs_lvm_int_pv_list * +guestfs_int_lvm_pv_list * do_pvs_full (void) { return parse_command_line_pvs (); } -guestfs_lvm_int_vg_list * +guestfs_int_lvm_vg_list * do_vgs_full (void) { return parse_command_line_vgs (); } -guestfs_lvm_int_lv_list * +guestfs_int_lvm_lv_list * do_lvs_full (void) { return parse_command_line_lvs (); } int -do_pvcreate (const char *device) +do_pvcreate (char *device) { char *err; int r; - IS_DEVICE (device, -1); + RESOLVE_DEVICE (device, return -1); r = command (NULL, &err, - "/sbin/lvm", "pvcreate", device, NULL); + "/sbin/lvm", "pvcreate", device, NULL); if (r == -1) { reply_with_error ("%s", err); free (err); @@ -187,17 +187,22 @@ do_pvcreate (const char *device) } free (err); + + udev_settle (); + return 0; } 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; - Xphysvols; + /* Check they are devices and also do device name translation. */ + for (i = 0; physvols[i] != NULL; ++i) + RESOLVE_DEVICE (physvols[i], return -1); argc = count_strings (physvols) + 3; argv = malloc (sizeof (char *) * (argc + 1)); @@ -219,11 +224,14 @@ do_vgcreate (const char *volgroup, char * const* const physvols) } free (err); + + udev_settle (); + return 0; } int -do_lvcreate (const char *logvol, const char *volgroup, int mbytes) +do_lvcreate (char *logvol, char *volgroup, int mbytes) { char *err; int r; @@ -232,8 +240,8 @@ do_lvcreate (const char *logvol, const char *volgroup, int mbytes) snprintf (size, sizeof size, "%d", mbytes); r = command (NULL, &err, - "/sbin/lvm", "lvcreate", - "-L", size, "-n", logvol, volgroup, NULL); + "/sbin/lvm", "lvcreate", + "-L", size, "-n", logvol, volgroup, NULL); if (r == -1) { reply_with_error ("%s", err); free (err); @@ -241,23 +249,26 @@ do_lvcreate (const char *logvol, const char *volgroup, int mbytes) } free (err); + + udev_settle (); + return 0; } int -do_lvresize (const char *logvol, int mbytes) +do_lvresize (char *logvol, int mbytes) { char *err; int r; char size[64]; - IS_DEVICE (logvol, -1); + RESOLVE_DEVICE (logvol, return -1); snprintf (size, sizeof size, "%d", mbytes); r = command (NULL, &err, - "/sbin/lvm", "lvresize", - "-L", size, logvol, NULL); + "/sbin/lvm", "lvresize", + "-L", size, logvol, NULL); if (r == -1) { reply_with_error ("lvresize: %s", err); free (err); @@ -329,20 +340,22 @@ do_lvm_remove_all (void) } free_strings (xs); + udev_settle (); + /* There, that was easy, sorry about your data. */ return 0; } int -do_lvremove (const char *device) +do_lvremove (char *device) { char *err; int r; - IS_DEVICE (device, -1); + RESOLVE_DEVICE (device, return -1); r = command (NULL, &err, - "/sbin/lvm", "lvremove", "-f", device, NULL); + "/sbin/lvm", "lvremove", "-f", device, NULL); if (r == -1) { reply_with_error ("%s", err); free (err); @@ -350,19 +363,20 @@ do_lvremove (const char *device) } free (err); + + udev_settle (); + return 0; } int -do_vgremove (const char *device) +do_vgremove (char *device) { char *err; int r; - IS_DEVICE (device, -1); - r = command (NULL, &err, - "/sbin/lvm", "vgremove", "-f", device, NULL); + "/sbin/lvm", "vgremove", "-f", device, NULL); if (r == -1) { reply_with_error ("%s", err); free (err); @@ -370,19 +384,22 @@ do_vgremove (const char *device) } free (err); + + udev_settle (); + return 0; } int -do_pvremove (const char *device) +do_pvremove (char *device) { char *err; int r; - IS_DEVICE (device, -1); + RESOLVE_DEVICE (device, return -1); r = command (NULL, &err, - "/sbin/lvm", "pvremove", "-ff", device, NULL); + "/sbin/lvm", "pvremove", "-ff", device, NULL); if (r == -1) { reply_with_error ("%s", err); free (err); @@ -390,19 +407,22 @@ do_pvremove (const char *device) } free (err); + + udev_settle (); + return 0; } int -do_pvresize (const char *device) +do_pvresize (char *device) { char *err; int r; - IS_DEVICE (device, -1); + RESOLVE_DEVICE (device, return -1); r = command (NULL, &err, - "/sbin/lvm", "pvresize", device, NULL); + "/sbin/lvm", "pvresize", device, NULL); if (r == -1) { reply_with_error ("pvresize: %s: %s", device, err); free (err); @@ -414,7 +434,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; @@ -442,6 +462,9 @@ do_vg_activate (int activate, char * const* const volgroups) } free (err); + + udev_settle (); + return 0; }