From ca49c50e06834bbc68e21630a5552c57494f2b53 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Mon, 18 May 2009 20:22:53 +0100 Subject: Generated code for lvresize, resize2fs. --- fish/cmds.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ fish/completion.c | 2 ++ 2 files changed, 46 insertions(+) (limited to 'fish') diff --git a/fish/cmds.c b/fish/cmds.c index 8d50021e..77b5d43f 100644 --- a/fish/cmds.c +++ b/fish/cmds.c @@ -99,6 +99,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 +118,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"); @@ -531,6 +533,12 @@ void display_command (const char *cmd) 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 display_builtin_command (cmd); } @@ -2603,6 +2611,36 @@ static int run_vg_activate (const char *cmd, int argc, char *argv[]) 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; +} + int run_action (const char *cmd, int argc, char *argv[]) { if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0) @@ -2976,6 +3014,12 @@ int run_action (const char *cmd, int argc, char *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 { fprintf (stderr, "%s: unknown command\n", cmd); diff --git a/fish/completion.c b/fish/completion.c index a072ce36..33a56638 100644 --- a/fish/completion.c +++ b/fish/completion.c @@ -106,6 +106,7 @@ static const char *const commands[] = { "lvcreate", "lvm-remove-all", "lvremove", + "lvresize", "lvs", "lvs-full", "mkdir", @@ -126,6 +127,7 @@ static const char *const commands[] = { "pvs-full", "qemu", "read-lines", + "resize2fs", "rm", "rm-rf", "rmdir", -- cgit