From: Jim Meyering Date: Mon, 10 Aug 2009 21:07:21 +0000 (+0200) Subject: * src/generator.ml: Change all `String "device"' to `Device "device"'. X-Git-Tag: 1.0.67~25 X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=commitdiff_plain;h=0c07f0d23698798475e0d09491812aca52440328 * src/generator.ml: Change all `String "device"' to `Device "device"'. Then update each affected function, removing each uses of RESOLVE_DEVICE, now that it's generated in caller from stub.c. * daemon/blockdev.c (call_blockdev): Remove use of RESOLVE_DEVICE. * daemon/devsparts.c (do_mkfs): Likewise. * daemon/ext2.c (do_e2fsck_f, do_get_e2label, do_get_e2uuid): Likewise. (do_resize2fs, do_set_e2label, do_set_e2uuid, do_tune2fs_l): Likewise. * daemon/fsck.c (do_fsck): Likewise. * daemon/grub.c (do_grub_install): Likewise. * daemon/lvm.c (do_lvremove, do_pvcreate, do_pvremove): Likewise. (do_pvresize): Likewise. * daemon/mount.c (do_mount_vfs): Likewise. * daemon/ntfs.c (do_ntfs_3g_probe): Likewise. * daemon/scrub.c (do_scrub_device): Likewise. * daemon/sfdisk.c (sfdisk, sfdisk_flag): Likewise. * daemon/swap.c (do_mkswap, do_mkswap_L, do_mkswap_U): Likewise. (do_swapoff_device, do_swapon_device): Likewise. * daemon/zero.c (do_zero): Likewise. * daemon/zerofree.c (do_zerofree): Likewise. --- diff --git a/daemon/blockdev.c b/daemon/blockdev.c index a5f7691..46ee994 100644 --- a/daemon/blockdev.c +++ b/daemon/blockdev.c @@ -46,8 +46,6 @@ call_blockdev (char *device, char *switc, int extraarg, int prints) }; char buf[64]; - RESOLVE_DEVICE (device, return -1); - if (extraarg > 0) { snprintf (buf, sizeof buf, "%d", extraarg); argv[2] = buf; diff --git a/daemon/devsparts.c b/daemon/devsparts.c index c3b9756..04585ed 100644 --- a/daemon/devsparts.c +++ b/daemon/devsparts.c @@ -193,8 +193,6 @@ do_mkfs (char *fstype, char *device) char *err; int r; - RESOLVE_DEVICE (device, return -1); - r = command (NULL, &err, "/sbin/mkfs", "-t", fstype, device, NULL); if (r == -1) { reply_with_error ("mkfs: %s", err); diff --git a/daemon/ext2.c b/daemon/ext2.c index d2304bd..04869da 100644 --- a/daemon/ext2.c +++ b/daemon/ext2.c @@ -36,8 +36,6 @@ do_tune2fs_l (char *device) char **ret = NULL; int size = 0, alloc = 0; - RESOLVE_DEVICE (device, return NULL); - r = command (&out, &err, "/sbin/tune2fs", "-l", device, NULL); if (r == -1) { reply_with_error ("tune2fs: %s", err); @@ -122,8 +120,6 @@ do_set_e2label (char *device, char *label) int r; char *err; - RESOLVE_DEVICE (device, return -1); - r = command (NULL, &err, "/sbin/e2label", device, label, NULL); if (r == -1) { reply_with_error ("e2label: %s", err); @@ -141,8 +137,6 @@ do_get_e2label (char *device) int r, len; char *out, *err; - RESOLVE_DEVICE (device, return NULL); - r = command (&out, &err, "/sbin/e2label", device, NULL); if (r == -1) { reply_with_error ("e2label: %s", err); @@ -167,8 +161,6 @@ do_set_e2uuid (char *device, char *uuid) int r; char *err; - RESOLVE_DEVICE (device, return -1); - r = command (NULL, &err, "/sbin/tune2fs", "-U", uuid, device, NULL); if (r == -1) { reply_with_error ("tune2fs -U: %s", err); @@ -186,8 +178,6 @@ do_get_e2uuid (char *device) int r; char *out, *err, *p, *q; - RESOLVE_DEVICE (device, return NULL); - /* It's not so straightforward to get the volume UUID. We have * to use tune2fs -l and then look for a particular string in * the output. @@ -249,8 +239,6 @@ do_resize2fs (char *device) char *err; int r; - RESOLVE_DEVICE (device, return -1); - r = command (NULL, &err, "/sbin/resize2fs", device, NULL); if (r == -1) { reply_with_error ("resize2fs: %s", err); @@ -268,8 +256,6 @@ do_e2fsck_f (char *device) char *err; int r; - RESOLVE_DEVICE (device, return -1); - r = command (NULL, &err, "/sbin/e2fsck", "-p", "-f", device, NULL); if (r == -1) { reply_with_error ("e2fsck: %s", err); diff --git a/daemon/fsck.c b/daemon/fsck.c index 907c117..825f97e 100644 --- a/daemon/fsck.c +++ b/daemon/fsck.c @@ -32,8 +32,6 @@ do_fsck (char *fstype, char *device) char *err; int r; - RESOLVE_DEVICE (device, return -1); - r = commandr (NULL, &err, "/sbin/fsck", "-a", "-t", fstype, device, NULL); if (r == -1) { reply_with_error ("fsck: %s: %s", device, err); diff --git a/daemon/grub.c b/daemon/grub.c index 8fcd911..0a49c45 100644 --- a/daemon/grub.c +++ b/daemon/grub.c @@ -34,7 +34,6 @@ do_grub_install (char *root, char *device) NEED_ROOT (-1); ABS_PATH (root, return -1); - RESOLVE_DEVICE (device, return -1); if (asprintf_nowarn (&buf, "--root-directory=%R", root) == -1) { reply_with_perror ("asprintf"); diff --git a/daemon/lvm.c b/daemon/lvm.c index 8f575c4..bee62d4 100644 --- a/daemon/lvm.c +++ b/daemon/lvm.c @@ -176,8 +176,6 @@ do_pvcreate (char *device) char *err; int r; - RESOLVE_DEVICE (device, return -1); - r = command (NULL, &err, "/sbin/lvm", "pvcreate", device, NULL); if (r == -1) { @@ -352,8 +350,6 @@ do_lvremove (char *device) char *err; int r; - RESOLVE_DEVICE (device, return -1); - r = command (NULL, &err, "/sbin/lvm", "lvremove", "-f", device, NULL); if (r == -1) { @@ -396,8 +392,6 @@ do_pvremove (char *device) char *err; int r; - RESOLVE_DEVICE (device, return -1); - r = command (NULL, &err, "/sbin/lvm", "pvremove", "-ff", device, NULL); if (r == -1) { @@ -419,8 +413,6 @@ do_pvresize (char *device) char *err; int r; - RESOLVE_DEVICE (device, return -1); - r = command (NULL, &err, "/sbin/lvm", "pvresize", device, NULL); if (r == -1) { diff --git a/daemon/mount.c b/daemon/mount.c index 8cf6874..14e683a 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -48,8 +48,6 @@ do_mount_vfs (char *options, char *vfstype, char *mp; char *error; - RESOLVE_DEVICE (device, return -1); - is_root = strcmp (mountpoint, "/") == 0; if (!root_mounted && !is_root) { diff --git a/daemon/ntfs.c b/daemon/ntfs.c index 8cb4f6f..1d73f2e 100644 --- a/daemon/ntfs.c +++ b/daemon/ntfs.c @@ -33,8 +33,6 @@ do_ntfs_3g_probe (int rw, char *device) int r; const char *rw_flag; - RESOLVE_DEVICE (device, return -1); - rw_flag = rw ? "-w" : "-r"; r = commandr (NULL, &err, "ntfs-3g.probe", rw_flag, device, NULL); diff --git a/daemon/scrub.c b/daemon/scrub.c index f1601f9..2beaea3 100644 --- a/daemon/scrub.c +++ b/daemon/scrub.c @@ -33,8 +33,6 @@ do_scrub_device (char *device) char *err; int r; - RESOLVE_DEVICE (device, return -1); - r = command (NULL, &err, "scrub", device, NULL); if (r == -1) { reply_with_error ("scrub_device: %s: %s", device, err); diff --git a/daemon/sfdisk.c b/daemon/sfdisk.c index a504141..e16e8c9 100644 --- a/daemon/sfdisk.c +++ b/daemon/sfdisk.c @@ -38,8 +38,6 @@ sfdisk (char *device, int n, int cyls, int heads, int sectors, char buf[256]; int i; - RESOLVE_DEVICE (device, return -1); - strcpy (buf, "/sbin/sfdisk"); if (n > 0) @@ -111,8 +109,6 @@ sfdisk_flag (char *device, const char *flag) char *out, *err; int r; - RESOLVE_DEVICE (device, return NULL); - r = command (&out, &err, "/sbin/sfdisk", flag, device, NULL); if (r == -1) { reply_with_error ("sfdisk: %s: %s", device, err); diff --git a/daemon/swap.c b/daemon/swap.c index bb1706f..f7270f8 100644 --- a/daemon/swap.c +++ b/daemon/swap.c @@ -52,24 +52,18 @@ mkswap (char *device, const char *flag, const char *value) int do_mkswap (char *device) { - RESOLVE_DEVICE (device, return -1); - return mkswap (device, NULL, NULL); } int do_mkswap_L (char *label, char *device) { - RESOLVE_DEVICE (device, return -1); - return mkswap (device, "-L", label); } int do_mkswap_U (char *uuid, char *device) { - RESOLVE_DEVICE (device, return -1); - return mkswap (device, "-U", uuid); } @@ -118,16 +112,12 @@ swaponoff (const char *cmd, const char *flag, const char *value) int do_swapon_device (char *device) { - RESOLVE_DEVICE (device, return -1); - return swaponoff ("/sbin/swapon", NULL, device); } int do_swapoff_device (char *device) { - RESOLVE_DEVICE (device, return -1); - return swaponoff ("/sbin/swapoff", NULL, device); } diff --git a/daemon/zero.c b/daemon/zero.c index ba87e68..864e9a6 100644 --- a/daemon/zero.c +++ b/daemon/zero.c @@ -33,8 +33,6 @@ do_zero (char *device) int fd, i; char buf[4096]; - RESOLVE_DEVICE (device, return -1); - fd = open (device, O_WRONLY); if (fd == -1) { reply_with_perror ("%s", device); diff --git a/daemon/zerofree.c b/daemon/zerofree.c index 27ef692..457f8db 100644 --- a/daemon/zerofree.c +++ b/daemon/zerofree.c @@ -33,8 +33,6 @@ do_zerofree (char *device) char *err; int r; - RESOLVE_DEVICE (device, return -1); - r = command (NULL, &err, "/usr/sbin/zerofree", device, NULL); if (r == -1) { reply_with_error ("zerofree: %s: %s", device, err); diff --git a/src/generator.ml b/src/generator.ml index f10d6b0..e3453a3 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -796,7 +796,7 @@ see L."); *) let daemon_functions = [ - ("mount", (RErr, [String "device"; String "mountpoint"]), 1, [], + ("mount", (RErr, [Device "device"; String "mountpoint"]), 1, [], [InitEmpty, Always, TestOutput ( [["sfdiskM"; "/dev/sda"; ","]; ["mkfs"; "ext2"; "/dev/sda1"]; @@ -1292,7 +1292,7 @@ other objects like files. See also C."); - ("pvcreate", (RErr, [String "device"]), 39, [], + ("pvcreate", (RErr, [Device "device"]), 39, [], [InitEmpty, Always, TestOutputListOfDevices ( [["sfdiskM"; "/dev/sda"; ",100 ,200 ,"]; ["pvcreate"; "/dev/sda1"]; @@ -1340,7 +1340,7 @@ from the non-empty list of physical volumes C."); This creates an LVM volume group called C on the volume group C, with C megabytes."); - ("mkfs", (RErr, [String "fstype"; String "device"]), 42, [], + ("mkfs", (RErr, [String "fstype"; Device "device"]), 42, [], [InitEmpty, Always, TestOutput ( [["sfdiskM"; "/dev/sda"; ","]; ["mkfs"; "ext2"; "/dev/sda1"]; @@ -1353,7 +1353,7 @@ This creates a filesystem on C (usually a partition or LVM logical volume). The filesystem type is C, for example C."); - ("sfdisk", (RErr, [String "device"; + ("sfdisk", (RErr, [Device "device"; Int "cyls"; Int "heads"; Int "sectors"; StringList "lines"]), 43, [DangerWillRobinson], [], @@ -1674,7 +1674,7 @@ manpage for more details. The list of fields returned isn't clearly defined, and depends on both the version of C that libguestfs was built against, and the filesystem itself."); - ("blockdev_setro", (RErr, [String "device"]), 56, [], + ("blockdev_setro", (RErr, [Device "device"]), 56, [], [InitEmpty, Always, TestOutputTrue ( [["blockdev_setro"; "/dev/sda"]; ["blockdev_getro"; "/dev/sda"]])], @@ -1684,7 +1684,7 @@ Sets the block device named C to read-only. This uses the L command."); - ("blockdev_setrw", (RErr, [String "device"]), 57, [], + ("blockdev_setrw", (RErr, [Device "device"]), 57, [], [InitEmpty, Always, TestOutputFalse ( [["blockdev_setrw"; "/dev/sda"]; ["blockdev_getro"; "/dev/sda"]])], @@ -1694,7 +1694,7 @@ Sets the block device named C to read-write. This uses the L command."); - ("blockdev_getro", (RBool "ro", [String "device"]), 58, [], + ("blockdev_getro", (RBool "ro", [Device "device"]), 58, [], [InitEmpty, Always, TestOutputTrue ( [["blockdev_setro"; "/dev/sda"]; ["blockdev_getro"; "/dev/sda"]])], @@ -1705,7 +1705,7 @@ Returns a boolean indicating if the block device is read-only This uses the L command."); - ("blockdev_getss", (RInt "sectorsize", [String "device"]), 59, [], + ("blockdev_getss", (RInt "sectorsize", [Device "device"]), 59, [], [InitEmpty, Always, TestOutputInt ( [["blockdev_getss"; "/dev/sda"]], 512)], "get sectorsize of block device", @@ -1718,7 +1718,7 @@ for that). This uses the L command."); - ("blockdev_getbsz", (RInt "blocksize", [String "device"]), 60, [], + ("blockdev_getbsz", (RInt "blocksize", [Device "device"]), 60, [], [InitEmpty, Always, TestOutputInt ( [["blockdev_getbsz"; "/dev/sda"]], 4096)], "get blocksize of block device", @@ -1730,7 +1730,7 @@ I). This uses the L command."); - ("blockdev_setbsz", (RErr, [String "device"; Int "blocksize"]), 61, [], + ("blockdev_setbsz", (RErr, [Device "device"; Int "blocksize"]), 61, [], [], (* XXX test *) "set blocksize of block device", "\ @@ -1741,7 +1741,7 @@ I). This uses the L command."); - ("blockdev_getsz", (RInt64 "sizeinsectors", [String "device"]), 62, [], + ("blockdev_getsz", (RInt64 "sizeinsectors", [Device "device"]), 62, [], [InitEmpty, Always, TestOutputInt ( [["blockdev_getsz"; "/dev/sda"]], 1024000)], "get total size of device in 512-byte sectors", @@ -1755,7 +1755,7 @@ useful I. This uses the L command."); - ("blockdev_getsize64", (RInt64 "sizeinbytes", [String "device"]), 63, [], + ("blockdev_getsize64", (RInt64 "sizeinbytes", [Device "device"]), 63, [], [InitEmpty, Always, TestOutputInt ( [["blockdev_getsize64"; "/dev/sda"]], 524288000)], "get total size of device in bytes", @@ -1766,7 +1766,7 @@ See also C. This uses the L command."); - ("blockdev_flushbufs", (RErr, [String "device"]), 64, [], + ("blockdev_flushbufs", (RErr, [Device "device"]), 64, [], [InitEmpty, Always, TestRun [["blockdev_flushbufs"; "/dev/sda"]]], "flush device buffers", @@ -1776,7 +1776,7 @@ with C. This uses the L command."); - ("blockdev_rereadpt", (RErr, [String "device"]), 65, [], + ("blockdev_rereadpt", (RErr, [Device "device"]), 65, [], [InitEmpty, Always, TestRun [["blockdev_rereadpt"; "/dev/sda"]]], "reread partition table", @@ -1917,7 +1917,7 @@ it to local file C. To download an uncompressed tarball, use C."); - ("mount_ro", (RErr, [String "device"; String "mountpoint"]), 73, [], + ("mount_ro", (RErr, [Device "device"; String "mountpoint"]), 73, [], [InitBasicFS, Always, TestLastFail ( [["umount"; "/"]; ["mount_ro"; "/dev/sda1"; "/"]; @@ -1932,7 +1932,7 @@ To download an uncompressed tarball, use C."); This is the same as the C command, but it mounts the filesystem with the read-only (I<-o ro>) flag."); - ("mount_options", (RErr, [String "options"; String "device"; String "mountpoint"]), 74, [], + ("mount_options", (RErr, [String "options"; Device "device"; String "mountpoint"]), 74, [], [], "mount a guest disk with mount options", "\ @@ -1940,7 +1940,7 @@ This is the same as the C command, but it allows you to set the mount options as for the L I<-o> flag."); - ("mount_vfs", (RErr, [String "options"; String "vfstype"; String "device"; String "mountpoint"]), 75, [], + ("mount_vfs", (RErr, [String "options"; String "vfstype"; Device "device"; String "mountpoint"]), 75, [], [], "mount a guest disk with mount options and vfstype", "\ @@ -1960,7 +1960,7 @@ There is no comprehensive help for this command. You have to look at the file C in the libguestfs source to find out what you can do."); - ("lvremove", (RErr, [String "device"]), 77, [], + ("lvremove", (RErr, [Device "device"]), 77, [], [InitEmpty, Always, TestOutputList ( [["sfdiskM"; "/dev/sda"; ","]; ["pvcreate"; "/dev/sda1"]; @@ -2017,7 +2017,7 @@ Remove an LVM volume group C, (for example C). This also forcibly removes all logical volumes in the volume group (if any)."); - ("pvremove", (RErr, [String "device"]), 79, [], + ("pvremove", (RErr, [Device "device"]), 79, [], [InitEmpty, Always, TestOutputListOfDevices ( [["sfdiskM"; "/dev/sda"; ","]; ["pvcreate"; "/dev/sda1"]; @@ -2054,7 +2054,7 @@ The implementation uses the C command which refuses to wipe physical volumes that contain any volume groups, so you have to remove those first."); - ("set_e2label", (RErr, [String "device"; String "label"]), 80, [], + ("set_e2label", (RErr, [Device "device"; String "label"]), 80, [], [InitBasicFS, Always, TestOutput ( [["set_e2label"; "/dev/sda1"; "testlabel"]; ["get_e2label"; "/dev/sda1"]], "testlabel")], @@ -2067,14 +2067,14 @@ C to C