diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2009-06-29 12:47:20 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2009-06-29 12:47:20 +0100 |
commit | e492608f2f3809a824cb70ee03ff305964b69dd7 (patch) | |
tree | 953ec56c34431549dab177eec9e0fe979606e5eb /fish | |
parent | 9a92446bcad09b492dee42dd5950bac67073fbea (diff) | |
download | libguestfs-e492608f2f3809a824cb70ee03ff305964b69dd7.tar.gz libguestfs-e492608f2f3809a824cb70ee03ff305964b69dd7.tar.xz libguestfs-e492608f2f3809a824cb70ee03ff305964b69dd7.zip |
Generated code for 'du' command.
Diffstat (limited to 'fish')
-rw-r--r-- | fish/cmds.c | 23 | ||||
-rw-r--r-- | fish/completion.c | 1 |
2 files changed, 24 insertions, 0 deletions
diff --git a/fish/cmds.c b/fish/cmds.c index 6067eed9..c802f90b 100644 --- a/fish/cmds.c +++ b/fish/cmds.c @@ -72,6 +72,7 @@ void list_commands (void) printf ("%-20s %s\n", "dmesg", "return kernel messages"); printf ("%-20s %s\n", "download", "download a file to the local machine"); printf ("%-20s %s\n", "drop-caches", "drop kernel page cache, dentries and inodes"); + printf ("%-20s %s\n", "du", "estimate file space usage"); printf ("%-20s %s\n", "e2fsck-f", "check an ext2/ext3 filesystem"); printf ("%-20s %s\n", "equal", "test if two files have equal contents"); printf ("%-20s %s\n", "exists", "test if file or directory exists"); @@ -624,6 +625,9 @@ void display_command (const char *cmd) if (strcasecmp (cmd, "df_h") == 0 || strcasecmp (cmd, "df-h") == 0) pod2text ("df-h - report file system disk space usage (human readable)", " df-h\n\nThis command runs the C<df -h> command to report disk space used\nin human-readable format.\n\nThis command is mostly useful for interactive sessions. It\nis I<not> intended that you try to parse the output string.\nUse C<statvfs> from programs."); else + if (strcasecmp (cmd, "du") == 0) + pod2text ("du - estimate file space usage", " du <path>\n\nThis command runs the C<du -s> command to estimate file space\nusage for C<path>.\n\nC<path> can be a file or a directory. If C<path> is a directory\nthen the estimate includes the contents of the directory and all\nsubdirectories (recursively).\n\nThe result is the estimated size in I<kilobytes>\n(ie. units of 1024 bytes)."); + else display_builtin_command (cmd); } @@ -3062,6 +3066,22 @@ static int run_df_h (const char *cmd, int argc, char *argv[]) return 0; } +static int run_du (const char *cmd, int argc, char *argv[]) +{ + int64_t r; + const char *path; + 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; + } + path = argv[0]; + r = guestfs_du (g, path); + if (r == -1) return -1; + printf ("%" PRIi64 "\n", r); + return 0; +} + int run_action (const char *cmd, int argc, char *argv[]) { if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0) @@ -3505,6 +3525,9 @@ int run_action (const char *cmd, int argc, char *argv[]) if (strcasecmp (cmd, "df_h") == 0 || strcasecmp (cmd, "df-h") == 0) return run_df_h (cmd, argc, argv); else + if (strcasecmp (cmd, "du") == 0) + return run_du (cmd, argc, argv); + else { fprintf (stderr, "%s: unknown command\n", cmd); return -1; diff --git a/fish/completion.c b/fish/completion.c index 6b58bd2c..5254a373 100644 --- a/fish/completion.c +++ b/fish/completion.c @@ -193,6 +193,7 @@ static const char *const commands[] = { "tail-n", "df", "df-h", + "du", NULL }; |