X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=fish%2Fcmds.c;h=1f3d9cee4a250b4ec5371f0cbd6a084c13799dec;hb=d901cc916102f1aaccfb73396b48aa303e5b8cd7;hp=1e442d82d5ac2a74dff005817cfb55727e9fc0fc;hpb=4aa4ecc380edc509aba886417c67d9c39ab51c9a;p=libguestfs.git diff --git a/fish/cmds.c b/fish/cmds.c index 1e442d8..1f3d9ce 100644 --- a/fish/cmds.c +++ b/fish/cmds.c @@ -147,6 +147,7 @@ void list_commands (void) printf ("%-20s %s\n", "vgs-full", "list the LVM volume groups (VGs)"); printf ("%-20s %s\n", "write-file", "create a file"); printf ("%-20s %s\n", "zero", "write zeroes to the device"); + printf ("%-20s %s\n", "zerofree", "zero unused inodes and disk blocks on ext2/3 filesystem"); printf (" Use -h / help to show detailed help for a command.\n"); } @@ -500,6 +501,9 @@ void display_command (const char *cmd) if (strcasecmp (cmd, "hexdump") == 0) pod2text ("hexdump - dump a file in hexadecimal", " hexdump \n\nThis runs C on the given C. The result is\nthe human-readable, canonical hex dump of the file.\n\nBecause of the message protocol, there is a transfer limit \nof somewhere between 2MB and 4MB. To transfer large files you should use\nFTP."); else + if (strcasecmp (cmd, "zerofree") == 0) + pod2text ("zerofree - zero unused inodes and disk blocks on ext2/3 filesystem", " zerofree \n\nThis runs the I program on C. This program\nclaims to zero unused inodes and disk blocks on an ext2/3\nfilesystem, thus making it possible to compress the filesystem\nmore effectively.\n\nYou should B run this program if the filesystem is\nmounted.\n\nIt is possible that using this program can damage the filesystem\nor data on the filesystem."); + else display_builtin_command (cmd); } @@ -2438,6 +2442,20 @@ static int run_hexdump (const char *cmd, int argc, char *argv[]) return 0; } +static int run_zerofree (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_zerofree (g, device); + return r; +} + int run_action (const char *cmd, int argc, char *argv[]) { if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0) @@ -2788,6 +2806,9 @@ int run_action (const char *cmd, int argc, char *argv[]) if (strcasecmp (cmd, "hexdump") == 0) return run_hexdump (cmd, argc, argv); else + if (strcasecmp (cmd, "zerofree") == 0) + return run_zerofree (cmd, argc, argv); + else { fprintf (stderr, "%s: unknown command\n", cmd); return -1;