X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=fish%2Fcmds.c;h=018080d073d945eaac33aac2a6a0974c28c3efe4;hp=e762521aa014defbd066d5727c98feb3353da6b5;hb=ac286b26df1aabceca26dac66c325a3676ace4cc;hpb=0703248d233744047515418893dac05ce013a642 diff --git a/fish/cmds.c b/fish/cmds.c index e762521..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)"); @@ -133,6 +137,7 @@ void list_commands (void) printf ("%-20s %s\n", "vgs", "list the LVM volume groups (VGs)"); 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 (" Use -h / help to show detailed help for a command.\n"); } @@ -442,7 +447,22 @@ void display_command (const char *cmd) pod2text ("get-e2uuid - get the ext2/3/4 filesystem UUID", " get-e2uuid \n\nThis returns the ext2/3/4 filesystem UUID of the filesystem on\nC."); else if (strcasecmp (cmd, "fsck") == 0) - pod2text ("fsck - run the filesystem checker", " fsck \n\nThis runs the filesystem checker (fsck) on C which\nshould have filesystem type C.\n\nThe returned integer is the status. See L for the\nlist of status codes from C, and note that multiple\nstatus codes can be summed together.\n\nIt is entirely equivalent to running C.\nNote that checking or repairing NTFS volumes is not supported\n(by linux-ntfs)."); + pod2text ("fsck - run the filesystem checker", " fsck \n\nThis runs the filesystem checker (fsck) on C which\nshould have filesystem type C.\n\nThe returned integer is the status. See L for the\nlist of status codes from C.\n\nNotes:\n\n=over 4\n\n=item *\n\nMultiple status codes can be summed together.\n\n=item *\n\nA non-zero return code can mean \"success\", for example if\nerrors have been corrected on the filesystem.\n\n=item *\n\nChecking or repairing NTFS volumes is not supported\n(by linux-ntfs).\n\n=back\n\nThis command is entirely equivalent to running C."); + else + 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); } @@ -2164,6 +2184,84 @@ static int run_fsck (const char *cmd, int argc, char *argv[]) return 0; } +static int run_zero (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_zero (g, device); + 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) @@ -2472,6 +2570,21 @@ int run_action (const char *cmd, int argc, char *argv[]) if (strcasecmp (cmd, "fsck") == 0) return run_fsck (cmd, argc, argv); else + 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;