summaryrefslogtreecommitdiffstats
path: root/fish
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-04 09:40:44 +0100
committerRichard Jones <rjones@redhat.com>2009-04-04 09:40:44 +0100
commit6d37b7698c1e2add43f0e8908e1bc30700f95f7e (patch)
tree3ab9c0ffd5eb33831631a975ccd7ccc1795cab40 /fish
parentb4c040d30e2677313a892ffe4cde0d53e446da7d (diff)
downloadlibguestfs-6d37b7698c1e2add43f0e8908e1bc30700f95f7e.tar.gz
libguestfs-6d37b7698c1e2add43f0e8908e1bc30700f95f7e.tar.xz
libguestfs-6d37b7698c1e2add43f0e8908e1bc30700f95f7e.zip
Implemented running actions in guestfish.
Diffstat (limited to 'fish')
-rw-r--r--fish/cmds.c48
1 files changed, 45 insertions, 3 deletions
diff --git a/fish/cmds.c b/fish/cmds.c
index a181b875..bc9d5a9c 100644
--- a/fish/cmds.c
+++ b/fish/cmds.c
@@ -49,16 +49,58 @@ void display_command (const char *cmd)
display_builtin_command (cmd);
}
+static int run_mount (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *device;
+ const char *mountpoint;
+ 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;
+ }
+ device = argv[0];
+ mountpoint = argv[1];
+ r = guestfs_mount (g, device, mountpoint);
+ return r;
+}
+
+static int run_sync (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_sync (g);
+ return r;
+}
+
+static int run_touch (const char *cmd, int argc, char *argv[])
+{
+ int 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_touch (g, path);
+ return r;
+}
+
int run_action (const char *cmd, int argc, char *argv[])
{
if (strcasecmp (cmd, "mount") == 0)
- printf ("running mount ...\n");
+ return run_mount (cmd, argc, argv);
else
if (strcasecmp (cmd, "sync") == 0)
- printf ("running sync ...\n");
+ return run_sync (cmd, argc, argv);
else
if (strcasecmp (cmd, "touch") == 0)
- printf ("running touch ...\n");
+ return run_touch (cmd, argc, argv);
else
{
fprintf (stderr, "%s: unknown command\n", cmd);