X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=fish%2Fcmds.c;h=018080d073d945eaac33aac2a6a0974c28c3efe4;hp=142b595c32bcd17946717f9ca8cf3bfccc88a1a4;hb=ac286b26df1aabceca26dac66c325a3676ace4cc;hpb=36f9dac1a2530b575dab9226f6ddd85e6e8c8590 diff --git a/fish/cmds.c b/fish/cmds.c index 142b595..018080d 100644 --- a/fish/cmds.c +++ b/fish/cmds.c @@ -63,6 +63,8 @@ void list_commands (void) printf ("%-20s %s\n", "command", "run a command from the guest filesystem"); printf ("%-20s %s\n", "command-lines", "run a command, returning lines"); printf ("%-20s %s\n", "config", "add qemu parameters"); + printf ("%-20s %s\n", "cp", "copy a file"); + printf ("%-20s %s\n", "cp-a", "copy a file or directory recursively"); printf ("%-20s %s\n", "debug", "debugging and internals"); printf ("%-20s %s\n", "download", "download a file to the local machine"); printf ("%-20s %s\n", "exists", "test if file or directory exists"); @@ -75,6 +77,7 @@ void list_commands (void) printf ("%-20s %s\n", "get-qemu", "get the qemu binary"); printf ("%-20s %s\n", "get-state", "get the current state"); printf ("%-20s %s\n", "get-verbose", "get verbose mode"); + printf ("%-20s %s\n", "grub-install", "install GRUB"); 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"); @@ -101,6 +104,7 @@ void list_commands (void) printf ("%-20s %s\n", "mount-ro", "mount a guest disk, read-only"); printf ("%-20s %s\n", "mount-vfs", "mount a guest disk with mount options and vfstype"); printf ("%-20s %s\n", "mounts", "show mounted filesystems"); + printf ("%-20s %s\n", "mv", "move a file"); printf ("%-20s %s\n", "pvcreate", "create an LVM physical volume"); printf ("%-20s %s\n", "pvremove", "remove an LVM physical volume"); printf ("%-20s %s\n", "pvs", "list the LVM physical volumes (PVs)"); @@ -448,6 +452,18 @@ void display_command (const char *cmd) if (strcasecmp (cmd, "zero") == 0) pod2text ("zero - write zeroes to the device", " zero \n\nThis command writes zeroes over the first few blocks of C.\n\nHow many blocks are zeroed isn't specified (but it's I enough\nto securely wipe the device). It should be sufficient to remove\nany partition tables, filesystem superblocks and so on."); else + if (strcasecmp (cmd, "grub_install") == 0 || strcasecmp (cmd, "grub-install") == 0) + pod2text ("grub-install - install GRUB", " grub-install \n\nThis command installs GRUB (the Grand Unified Bootloader) on\nC, with the root directory being C."); + else + if (strcasecmp (cmd, "cp") == 0) + pod2text ("cp - copy a file", " cp \n\nThis copies a file from C to C where C is\neither a destination filename or destination directory."); + else + if (strcasecmp (cmd, "cp_a") == 0 || strcasecmp (cmd, "cp-a") == 0) + pod2text ("cp-a - copy a file or directory recursively", " cp-a \n\nThis copies a file or directory from C to C\nrecursively using the C command."); + else + if (strcasecmp (cmd, "mv") == 0) + pod2text ("mv - move a file", " mv \n\nThis moves a file from C to C where C is\neither a destination filename or destination directory."); + else display_builtin_command (cmd); } @@ -2182,6 +2198,70 @@ static int run_zero (const char *cmd, int argc, char *argv[]) return r; } +static int run_grub_install (const char *cmd, int argc, char *argv[]) +{ + int r; + const char *root; + const char *device; + 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; + } + root = argv[0]; + device = argv[1]; + r = guestfs_grub_install (g, root, device); + return r; +} + +static int run_cp (const char *cmd, int argc, char *argv[]) +{ + int r; + const char *src; + const char *dest; + 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; + } + src = argv[0]; + dest = argv[1]; + r = guestfs_cp (g, src, dest); + return r; +} + +static int run_cp_a (const char *cmd, int argc, char *argv[]) +{ + int r; + const char *src; + const char *dest; + 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; + } + src = argv[0]; + dest = argv[1]; + r = guestfs_cp_a (g, src, dest); + return r; +} + +static int run_mv (const char *cmd, int argc, char *argv[]) +{ + int r; + const char *src; + const char *dest; + 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; + } + src = argv[0]; + dest = argv[1]; + r = guestfs_mv (g, src, dest); + return r; +} + int run_action (const char *cmd, int argc, char *argv[]) { if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0) @@ -2493,6 +2573,18 @@ int run_action (const char *cmd, int argc, char *argv[]) if (strcasecmp (cmd, "zero") == 0) return run_zero (cmd, argc, argv); else + if (strcasecmp (cmd, "grub_install") == 0 || strcasecmp (cmd, "grub-install") == 0) + return run_grub_install (cmd, argc, argv); + else + if (strcasecmp (cmd, "cp") == 0) + return run_cp (cmd, argc, argv); + else + if (strcasecmp (cmd, "cp_a") == 0 || strcasecmp (cmd, "cp-a") == 0) + return run_cp_a (cmd, argc, argv); + else + if (strcasecmp (cmd, "mv") == 0) + return run_mv (cmd, argc, argv); + else { fprintf (stderr, "%s: unknown command\n", cmd); return -1;