diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2009-05-14 23:47:17 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2009-05-14 23:47:17 +0100 |
commit | d901cc916102f1aaccfb73396b48aa303e5b8cd7 (patch) | |
tree | 7c2fd470088874ab99b5922393327170e653cf01 /fish | |
parent | 4aa4ecc380edc509aba886417c67d9c39ab51c9a (diff) | |
download | libguestfs-d901cc916102f1aaccfb73396b48aa303e5b8cd7.tar.gz libguestfs-d901cc916102f1aaccfb73396b48aa303e5b8cd7.tar.xz libguestfs-d901cc916102f1aaccfb73396b48aa303e5b8cd7.zip |
Add support for zerofree command.
Diffstat (limited to 'fish')
-rw-r--r-- | fish/cmds.c | 21 | ||||
-rw-r--r-- | fish/completion.c | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/fish/cmds.c b/fish/cmds.c index 1e442d82..1f3d9cee 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 <cmd> / help <cmd> 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 <path>\n\nThis runs C<hexdump -C> on the given C<path>. 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 <device>\n\nThis runs the I<zerofree> program on C<device>. 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<not> 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; diff --git a/fish/completion.c b/fish/completion.c index 4db2d5ef..5c7f5e01 100644 --- a/fish/completion.c +++ b/fish/completion.c @@ -160,6 +160,7 @@ static const char *const commands[] = { "vgs-full", "write-file", "zero", + "zerofree", NULL }; |