X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=fish%2Fcmds.c;fp=fish%2Fcmds.c;h=ed59804b8ae248c5010562007107d23d6d6a7d80;hp=c802f90bc03b3281b3d67264e3a3a3a158ffd124;hb=c6d6f5ae1b76ec9aa5c540906aeed73d25d13eb9;hpb=4dff42aa13dd726fb6b02843d0f4db4b4b330fe3 diff --git a/fish/cmds.c b/fish/cmds.c index c802f90..ed59804 100644 --- a/fish/cmds.c +++ b/fish/cmds.c @@ -92,6 +92,7 @@ void list_commands (void) printf ("%-20s %s\n", "head", "return first 10 lines of a file"); printf ("%-20s %s\n", "head-n", "return first N lines of a file"); printf ("%-20s %s\n", "hexdump", "dump a file in hexadecimal"); + printf ("%-20s %s\n", "initrd-list", "list files in an initrd"); printf ("%-20s %s\n", "is-busy", "is busy processing a command"); printf ("%-20s %s\n", "is-config", "is in configuration state"); printf ("%-20s %s\n", "is-dir", "test if file exists"); @@ -628,6 +629,9 @@ void display_command (const char *cmd) if (strcasecmp (cmd, "du") == 0) pod2text ("du - estimate file space usage", " du \n\nThis command runs the C command to estimate file space\nusage for C.\n\nC can be a file or a directory. If C 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\n(ie. units of 1024 bytes)."); else + if (strcasecmp (cmd, "initrd_list") == 0 || strcasecmp (cmd, "initrd-list") == 0) + pod2text ("initrd-list - list files in an initrd", " initrd-list \n\nThis command lists out files contained in an initrd.\n\nThe files are listed without any initial C character. The\nfiles are listed in the order they appear (not necessarily\nalphabetical). Directory names are listed as separate items.\n\nOld Linux kernels (2.4 and earlier) used a compressed ext2\nfilesystem as initrd. We I support the newer initramfs\nformat (compressed cpio files)."); + else display_builtin_command (cmd); } @@ -3082,6 +3086,23 @@ static int run_du (const char *cmd, int argc, char *argv[]) return 0; } +static int run_initrd_list (const char *cmd, int argc, char *argv[]) +{ + char **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_initrd_list (g, path); + 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) @@ -3528,6 +3549,9 @@ int run_action (const char *cmd, int argc, char *argv[]) if (strcasecmp (cmd, "du") == 0) return run_du (cmd, argc, argv); else + if (strcasecmp (cmd, "initrd_list") == 0 || strcasecmp (cmd, "initrd-list") == 0) + return run_initrd_list (cmd, argc, argv); + else { fprintf (stderr, "%s: unknown command\n", cmd); return -1;