X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=fish%2Fcmds.c;h=0f5b65dfc7eae2264293d707d2b3c28bf4a234eb;hb=d70248333edf8a5b5f509609cf2c8f7fd77d5e05;hp=5680bfa354ed3b2d8107262c61684e320fb4415d;hpb=5cd39c83e23eb300d1bdfa806902a31b409ff420;p=libguestfs.git diff --git a/fish/cmds.c b/fish/cmds.c index 5680bfa..0f5b65d 100644 --- a/fish/cmds.c +++ b/fish/cmds.c @@ -72,6 +72,7 @@ void list_commands (void) printf ("%-20s %s\n", "equal", "test if two files have equal contents"); printf ("%-20s %s\n", "exists", "test if file or directory exists"); printf ("%-20s %s\n", "file", "determine file type"); + printf ("%-20s %s\n", "find", "find all files and directories"); printf ("%-20s %s\n", "fsck", "run the filesystem checker"); printf ("%-20s %s\n", "get-append", "get the additional kernel options"); printf ("%-20s %s\n", "get-autosync", "get autosync mode"); @@ -99,6 +100,7 @@ void list_commands (void) printf ("%-20s %s\n", "lvcreate", "create an LVM volume group"); printf ("%-20s %s\n", "lvm-remove-all", "remove all LVM LVs, VGs and PVs"); printf ("%-20s %s\n", "lvremove", "remove an LVM logical volume"); + printf ("%-20s %s\n", "lvresize", "resize an LVM logical volume"); printf ("%-20s %s\n", "lvs", "list the LVM logical volumes (LVs)"); printf ("%-20s %s\n", "lvs-full", "list the LVM logical volumes (LVs)"); printf ("%-20s %s\n", "mkdir", "create a directory"); @@ -117,6 +119,7 @@ void list_commands (void) printf ("%-20s %s\n", "pvs", "list the LVM physical volumes (PVs)"); printf ("%-20s %s\n", "pvs-full", "list the LVM physical volumes (PVs)"); printf ("%-20s %s\n", "read-lines", "read file as lines"); + printf ("%-20s %s\n", "resize2fs", "resize an ext2/ext3 filesystem"); printf ("%-20s %s\n", "rm", "remove a file"); printf ("%-20s %s\n", "rm-rf", "remove a file or directory recursively"); printf ("%-20s %s\n", "rmdir", "remove a directory"); @@ -146,6 +149,8 @@ void list_commands (void) printf ("%-20s %s\n", "umount", "unmount a filesystem"); printf ("%-20s %s\n", "umount-all", "unmount all filesystems"); printf ("%-20s %s\n", "upload", "upload a file from the local machine"); + printf ("%-20s %s\n", "vg-activate", "activate or deactivate some volume groups"); + printf ("%-20s %s\n", "vg-activate-all", "activate or deactivate all volume groups"); printf ("%-20s %s\n", "vgcreate", "create an LVM volume group"); printf ("%-20s %s\n", "vgremove", "remove an LVM volume group"); printf ("%-20s %s\n", "vgs", "list the LVM volume groups (VGs)"); @@ -524,6 +529,21 @@ void display_command (const char *cmd) if (strcasecmp (cmd, "sfdisk_disk_geometry") == 0 || strcasecmp (cmd, "sfdisk-disk-geometry") == 0) pod2text ("sfdisk-disk-geometry - display the disk geometry from the partition table", " sfdisk-disk-geometry \n\nThis displays the disk geometry of C read from the\npartition table. Especially in the case where the underlying\nblock device has been resized, this can be different from the\nkernel's idea of the geometry (see C).\n\nThe result is in human-readable format, and not designed to\nbe parsed."); else + if (strcasecmp (cmd, "vg_activate_all") == 0 || strcasecmp (cmd, "vg-activate-all") == 0) + pod2text ("vg-activate-all - activate or deactivate all volume groups", " vg-activate-all \n\nThis command activates or (if C is false) deactivates\nall logical volumes in all volume groups.\nIf activated, then they are made known to the\nkernel, ie. they appear as C devices. If deactivated,\nthen those devices disappear.\n\nThis command is the same as running C"); + else + if (strcasecmp (cmd, "vg_activate") == 0 || strcasecmp (cmd, "vg-activate") == 0) + pod2text ("vg-activate - activate or deactivate some volume groups", " vg-activate \n\nThis command activates or (if C is false) deactivates\nall logical volumes in the listed volume groups C.\nIf activated, then they are made known to the\nkernel, ie. they appear as C devices. If deactivated,\nthen those devices disappear.\n\nThis command is the same as running C\n\nNote that if C is an empty list then B volume groups\nare activated or deactivated."); + else + if (strcasecmp (cmd, "lvresize") == 0) + pod2text ("lvresize - resize an LVM logical volume", " lvresize \n\nThis resizes (expands or shrinks) an existing LVM logical\nvolume to C. When reducing, data in the reduced part\nis lost."); + else + if (strcasecmp (cmd, "resize2fs") == 0) + pod2text ("resize2fs - resize an ext2/ext3 filesystem", " resize2fs \n\nThis resizes an ext2 or ext3 filesystem to match the size of\nthe underlying device."); + else + if (strcasecmp (cmd, "find") == 0) + pod2text ("find - find all files and directories", " find \n\nThis command lists out all files and directories, recursively,\nstarting at C. It is essentially equivalent to\nrunning the shell command C but some\npost-processing happens on the output, described below.\n\nThis returns a list of strings I. Thus\nif the directory structure was:\n\n /tmp/a\n /tmp/b\n /tmp/c/d\n\nthen the returned list from C C would be\n4 elements:\n\n a\n b\n c\n c/d\n\nIf C is not a directory, then this command returns\nan error.\n\nThe returned list is sorted."); + else display_builtin_command (cmd); } @@ -2565,6 +2585,83 @@ static int run_sfdisk_disk_geometry (const char *cmd, int argc, char *argv[]) return 0; } +static int run_vg_activate_all (const char *cmd, int argc, char *argv[]) +{ + int r; + int activate; + if (argc != 1) { + fprintf (stderr, "%s should have 1 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + activate = is_true (argv[0]) ? 1 : 0; + r = guestfs_vg_activate_all (g, activate); + return r; +} + +static int run_vg_activate (const char *cmd, int argc, char *argv[]) +{ + int r; + int activate; + char **volgroups; + if (argc != 2) { + fprintf (stderr, "%s should have 2 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + activate = is_true (argv[0]) ? 1 : 0; + volgroups = parse_string_list (argv[1]); + r = guestfs_vg_activate (g, activate, volgroups); + return r; +} + +static int run_lvresize (const char *cmd, int argc, char *argv[]) +{ + int r; + const char *device; + int mbytes; + if (argc != 2) { + fprintf (stderr, "%s should have 2 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + device = argv[0]; + mbytes = atoi (argv[1]); + r = guestfs_lvresize (g, device, mbytes); + return r; +} + +static int run_resize2fs (const char *cmd, int argc, char *argv[]) +{ + int r; + const char *device; + if (argc != 1) { + fprintf (stderr, "%s should have 1 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + device = argv[0]; + r = guestfs_resize2fs (g, device); + return r; +} + +static int run_find (const char *cmd, int argc, char *argv[]) +{ + char **r; + const char *directory; + if (argc != 1) { + fprintf (stderr, "%s should have 1 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + directory = argv[0]; + r = guestfs_find (g, directory); + if (r == NULL) return -1; + print_strings (r); + free_strings (r); + return 0; +} + int run_action (const char *cmd, int argc, char *argv[]) { if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0) @@ -2933,6 +3030,21 @@ int run_action (const char *cmd, int argc, char *argv[]) if (strcasecmp (cmd, "sfdisk_disk_geometry") == 0 || strcasecmp (cmd, "sfdisk-disk-geometry") == 0) return run_sfdisk_disk_geometry (cmd, argc, argv); else + if (strcasecmp (cmd, "vg_activate_all") == 0 || strcasecmp (cmd, "vg-activate-all") == 0) + return run_vg_activate_all (cmd, argc, argv); + else + if (strcasecmp (cmd, "vg_activate") == 0 || strcasecmp (cmd, "vg-activate") == 0) + return run_vg_activate (cmd, argc, argv); + else + if (strcasecmp (cmd, "lvresize") == 0) + return run_lvresize (cmd, argc, argv); + else + if (strcasecmp (cmd, "resize2fs") == 0) + return run_resize2fs (cmd, argc, argv); + else + if (strcasecmp (cmd, "find") == 0) + return run_find (cmd, argc, argv); + else { fprintf (stderr, "%s: unknown command\n", cmd); return -1;