From b03ee3675bed8d739ae722ed8c030ae02b3cb0ed Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Mon, 27 Apr 2009 13:41:59 +0100 Subject: [PATCH] Generated code for ext2 UUID and label functions. --- daemon/actions.h | 4 + daemon/stubs.c | 118 ++++++++++ fish/cmds.c | 94 ++++++++ fish/completion.c | 4 + guestfish-actions.pod | 37 +++ guestfs-actions.pod | 53 +++++ java/com/redhat/et/libguestfs/GuestFS.java | 81 +++++++ java/com_redhat_et_libguestfs_GuestFS.c | 82 +++++++ make-recipes.sh | 9 +- ocaml/guestfs.ml | 4 + ocaml/guestfs.mli | 12 + ocaml/guestfs_c_actions.c | 96 ++++++++ perl/Guestfs.xs | 54 +++++ perl/lib/Sys/Guestfs.pm | 29 +++ python/guestfs-py.c | 106 +++++++++ python/guestfs.py | 33 +++ ruby/ext/guestfs/_guestfs.c | 104 +++++++++ src/guestfs-actions.c | 358 +++++++++++++++++++++++++++++ src/guestfs-actions.h | 4 + src/guestfs_protocol.c | 64 ++++++ src/guestfs_protocol.h | 50 +++- src/guestfs_protocol.x | 30 +++ tests.c | 335 ++++++++++++++++++++++++++- 23 files changed, 1758 insertions(+), 3 deletions(-) diff --git a/daemon/actions.h b/daemon/actions.h index 8e79f7b..373e513 100644 --- a/daemon/actions.h +++ b/daemon/actions.h @@ -100,3 +100,7 @@ extern char *do_debug (const char *subcmd, char * const* const extraargs); extern int do_lvremove (const char *device); extern int do_vgremove (const char *vgname); extern int do_pvremove (const char *device); +extern int do_set_e2label (const char *device, const char *label); +extern char *do_get_e2label (const char *device); +extern int do_set_e2uuid (const char *device, const char *uuid); +extern char *do_get_e2uuid (const char *device); diff --git a/daemon/stubs.c b/daemon/stubs.c index 02c76f1..cafadbe 100644 --- a/daemon/stubs.c +++ b/daemon/stubs.c @@ -1944,6 +1944,112 @@ done: xdr_free ((xdrproc_t) xdr_guestfs_pvremove_args, (char *) &args); } +static void set_e2label_stub (XDR *xdr_in) +{ + int r; + struct guestfs_set_e2label_args args; + const char *device; + const char *label; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_set_e2label_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "set_e2label"); + return; + } + device = args.device; + label = args.label; + + r = do_set_e2label (device, label); + if (r == -1) + /* do_set_e2label has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_set_e2label_args, (char *) &args); +} + +static void get_e2label_stub (XDR *xdr_in) +{ + char *r; + struct guestfs_get_e2label_args args; + const char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_get_e2label_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "get_e2label"); + return; + } + device = args.device; + + r = do_get_e2label (device); + if (r == NULL) + /* do_get_e2label has already called reply_with_error */ + goto done; + + struct guestfs_get_e2label_ret ret; + ret.label = r; + reply ((xdrproc_t) &xdr_guestfs_get_e2label_ret, (char *) &ret); + free (r); +done: + xdr_free ((xdrproc_t) xdr_guestfs_get_e2label_args, (char *) &args); +} + +static void set_e2uuid_stub (XDR *xdr_in) +{ + int r; + struct guestfs_set_e2uuid_args args; + const char *device; + const char *uuid; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_set_e2uuid_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "set_e2uuid"); + return; + } + device = args.device; + uuid = args.uuid; + + r = do_set_e2uuid (device, uuid); + if (r == -1) + /* do_set_e2uuid has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_set_e2uuid_args, (char *) &args); +} + +static void get_e2uuid_stub (XDR *xdr_in) +{ + char *r; + struct guestfs_get_e2uuid_args args; + const char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_get_e2uuid_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "get_e2uuid"); + return; + } + device = args.device; + + r = do_get_e2uuid (device); + if (r == NULL) + /* do_get_e2uuid has already called reply_with_error */ + goto done; + + struct guestfs_get_e2uuid_ret ret; + ret.uuid = r; + reply ((xdrproc_t) &xdr_guestfs_get_e2uuid_ret, (char *) &ret); + free (r); +done: + xdr_free ((xdrproc_t) xdr_guestfs_get_e2uuid_args, (char *) &args); +} + void dispatch_incoming_message (XDR *xdr_in) { switch (proc_nr) { @@ -2184,6 +2290,18 @@ void dispatch_incoming_message (XDR *xdr_in) case GUESTFS_PROC_PVREMOVE: pvremove_stub (xdr_in); break; + case GUESTFS_PROC_SET_E2LABEL: + set_e2label_stub (xdr_in); + break; + case GUESTFS_PROC_GET_E2LABEL: + get_e2label_stub (xdr_in); + break; + case GUESTFS_PROC_SET_E2UUID: + set_e2uuid_stub (xdr_in); + break; + case GUESTFS_PROC_GET_E2UUID: + get_e2uuid_stub (xdr_in); + break; default: reply_with_error ("dispatch_incoming_message: unknown procedure number %d", proc_nr); } diff --git a/fish/cmds.c b/fish/cmds.c index 411c6f7..f0da329 100644 --- a/fish/cmds.c +++ b/fish/cmds.c @@ -68,6 +68,8 @@ void list_commands (void) printf ("%-20s %s\n", "exists", "test if file or directory exists"); printf ("%-20s %s\n", "file", "determine file type"); printf ("%-20s %s\n", "get-autosync", "get autosync mode"); + printf ("%-20s %s\n", "get-e2label", "get the ext2/3/4 filesystem label"); + printf ("%-20s %s\n", "get-e2uuid", "get the ext2/3/4 filesystem UUID"); printf ("%-20s %s\n", "get-path", "get the search path"); printf ("%-20s %s\n", "get-qemu", "get the qemu binary"); printf ("%-20s %s\n", "get-state", "get the current state"); @@ -107,6 +109,8 @@ void list_commands (void) printf ("%-20s %s\n", "rm-rf", "remove a file or directory recursively"); printf ("%-20s %s\n", "rmdir", "remove a directory"); printf ("%-20s %s\n", "set-autosync", "set autosync mode"); + printf ("%-20s %s\n", "set-e2label", "set the ext2/3/4 filesystem label"); + printf ("%-20s %s\n", "set-e2uuid", "set the ext2/3/4 filesystem UUID"); printf ("%-20s %s\n", "set-path", "set the search path"); printf ("%-20s %s\n", "set-qemu", "set the qemu binary"); printf ("%-20s %s\n", "set-verbose", "set verbose mode"); @@ -424,6 +428,18 @@ void display_command (const char *cmd) if (strcasecmp (cmd, "pvremove") == 0) pod2text ("pvremove - remove an LVM physical volume", " pvremove \n\nThis wipes a physical volume C so that LVM will no longer\nrecognise it.\n\nThe implementation uses the C command which refuses to\nwipe physical volumes that contain any volume groups, so you have\nto remove those first."); else + if (strcasecmp (cmd, "set_e2label") == 0 || strcasecmp (cmd, "set-e2label") == 0) + pod2text ("set-e2label - set the ext2/3/4 filesystem label", " set-e2label