summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-09 19:36:07 +0100
committerRichard Jones <rjones@redhat.com>2009-04-09 19:36:07 +0100
commit01c26253a12ed1e6b1199f8c85f049a7fc4aef28 (patch)
tree02a9f655430a8e7cf282b7dd9bf042640654f599 /src
parent0677b12f2273ed266da9dd276c129342d6a939a2 (diff)
downloadlibguestfs-01c26253a12ed1e6b1199f8c85f049a7fc4aef28.tar.gz
libguestfs-01c26253a12ed1e6b1199f8c85f049a7fc4aef28.tar.xz
libguestfs-01c26253a12ed1e6b1199f8c85f049a7fc4aef28.zip
Added aug-ls (generated code).
Diffstat (limited to 'src')
-rw-r--r--src/guestfs-actions.c78
-rw-r--r--src/guestfs-actions.h1
-rw-r--r--src/guestfs_protocol.c21
-rw-r--r--src/guestfs_protocol.h20
-rw-r--r--src/guestfs_protocol.x9
5 files changed, 128 insertions, 1 deletions
diff --git a/src/guestfs-actions.c b/src/guestfs-actions.c
index 0bb868ca..9b9749a1 100644
--- a/src/guestfs-actions.c
+++ b/src/guestfs-actions.c
@@ -1973,3 +1973,81 @@ int guestfs_aug_load (guestfs_h *g)
return 0;
}
+struct aug_ls_rv {
+ int cb_done; /* flag to indicate callback was called */
+ struct guestfs_message_header hdr;
+ struct guestfs_message_error err;
+ struct guestfs_aug_ls_ret ret;
+};
+
+static void aug_ls_cb (guestfs_h *g, void *data, XDR *xdr)
+{
+ struct aug_ls_rv *rv = (struct aug_ls_rv *) data;
+
+ if (!xdr_guestfs_message_header (xdr, &rv->hdr)) {
+ error (g, "guestfs_aug_ls: failed to parse reply header");
+ return;
+ }
+ if (rv->hdr.status == GUESTFS_STATUS_ERROR) {
+ if (!xdr_guestfs_message_error (xdr, &rv->err)) {
+ error (g, "guestfs_aug_ls: failed to parse reply error");
+ return;
+ }
+ goto done;
+ }
+ if (!xdr_guestfs_aug_ls_ret (xdr, &rv->ret)) {
+ error (g, "guestfs_aug_ls: failed to parse reply");
+ return;
+ }
+ done:
+ rv->cb_done = 1;
+ main_loop.main_loop_quit (g);
+}
+
+char **guestfs_aug_ls (guestfs_h *g,
+ const char *path)
+{
+ struct guestfs_aug_ls_args args;
+ struct aug_ls_rv rv;
+ int serial;
+
+ if (g->state != READY) {
+ error (g, "guestfs_aug_ls called from the wrong state, %d != READY",
+ g->state);
+ return NULL;
+ }
+
+ memset (&rv, 0, sizeof rv);
+
+ args.path = (char *) path;
+ serial = dispatch (g, GUESTFS_PROC_AUG_LS,
+ (xdrproc_t) xdr_guestfs_aug_ls_args, (char *) &args);
+ if (serial == -1)
+ return NULL;
+
+ rv.cb_done = 0;
+ g->reply_cb_internal = aug_ls_cb;
+ g->reply_cb_internal_data = &rv;
+ main_loop.main_loop_run (g);
+ g->reply_cb_internal = NULL;
+ g->reply_cb_internal_data = NULL;
+ if (!rv.cb_done) {
+ error (g, "guestfs_aug_ls failed, see earlier error messages");
+ return NULL;
+ }
+
+ if (check_reply_header (g, &rv.hdr, GUESTFS_PROC_AUG_LS, serial) == -1)
+ return NULL;
+
+ if (rv.hdr.status == GUESTFS_STATUS_ERROR) {
+ error (g, "%s", rv.err.error);
+ return NULL;
+ }
+
+ /* caller will free this, but we need to add a NULL entry */
+ rv.ret.matches.matches_val = safe_realloc (g, rv.ret.matches.matches_val,
+ sizeof (char *) * (rv.ret.matches.matches_len + 1));
+ rv.ret.matches.matches_val[rv.ret.matches.matches_len] = NULL;
+ return rv.ret.matches.matches_val;
+}
+
diff --git a/src/guestfs-actions.h b/src/guestfs-actions.h
index eeb69035..497e36bb 100644
--- a/src/guestfs-actions.h
+++ b/src/guestfs-actions.h
@@ -58,3 +58,4 @@ extern int guestfs_aug_mv (guestfs_h *handle, const char *src, const char *dest)
extern char **guestfs_aug_match (guestfs_h *handle, const char *path);
extern int guestfs_aug_save (guestfs_h *handle);
extern int guestfs_aug_load (guestfs_h *handle);
+extern char **guestfs_aug_ls (guestfs_h *handle, const char *path);
diff --git a/src/guestfs_protocol.c b/src/guestfs_protocol.c
index a5737288..ed38a8d2 100644
--- a/src/guestfs_protocol.c
+++ b/src/guestfs_protocol.c
@@ -522,6 +522,27 @@ xdr_guestfs_aug_match_ret (XDR *xdrs, guestfs_aug_match_ret *objp)
}
bool_t
+xdr_guestfs_aug_ls_args (XDR *xdrs, guestfs_aug_ls_args *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_string (xdrs, &objp->path, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_guestfs_aug_ls_ret (XDR *xdrs, guestfs_aug_ls_ret *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_array (xdrs, (char **)&objp->matches.matches_val, (u_int *) &objp->matches.matches_len, ~0,
+ sizeof (str), (xdrproc_t) xdr_str))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
xdr_guestfs_procedure (XDR *xdrs, guestfs_procedure *objp)
{
register int32_t *buf;
diff --git a/src/guestfs_protocol.h b/src/guestfs_protocol.h
index 94129864..a0943554 100644
--- a/src/guestfs_protocol.h
+++ b/src/guestfs_protocol.h
@@ -286,6 +286,19 @@ struct guestfs_aug_match_ret {
};
typedef struct guestfs_aug_match_ret guestfs_aug_match_ret;
+struct guestfs_aug_ls_args {
+ char *path;
+};
+typedef struct guestfs_aug_ls_args guestfs_aug_ls_args;
+
+struct guestfs_aug_ls_ret {
+ struct {
+ u_int matches_len;
+ str *matches_val;
+ } matches;
+};
+typedef struct guestfs_aug_ls_ret guestfs_aug_ls_ret;
+
enum guestfs_procedure {
GUESTFS_PROC_MOUNT = 1,
GUESTFS_PROC_SYNC = 2,
@@ -314,7 +327,8 @@ enum guestfs_procedure {
GUESTFS_PROC_AUG_MATCH = 24,
GUESTFS_PROC_AUG_SAVE = 25,
GUESTFS_PROC_AUG_LOAD = 27,
- GUESTFS_PROC_dummy = 27 + 1,
+ GUESTFS_PROC_AUG_LS = 28,
+ GUESTFS_PROC_dummy = 28 + 1,
};
typedef enum guestfs_procedure guestfs_procedure;
#define GUESTFS_MESSAGE_MAX 4194304
@@ -391,6 +405,8 @@ extern bool_t xdr_guestfs_aug_rm_ret (XDR *, guestfs_aug_rm_ret*);
extern bool_t xdr_guestfs_aug_mv_args (XDR *, guestfs_aug_mv_args*);
extern bool_t xdr_guestfs_aug_match_args (XDR *, guestfs_aug_match_args*);
extern bool_t xdr_guestfs_aug_match_ret (XDR *, guestfs_aug_match_ret*);
+extern bool_t xdr_guestfs_aug_ls_args (XDR *, guestfs_aug_ls_args*);
+extern bool_t xdr_guestfs_aug_ls_ret (XDR *, guestfs_aug_ls_ret*);
extern bool_t xdr_guestfs_procedure (XDR *, guestfs_procedure*);
extern bool_t xdr_guestfs_message_direction (XDR *, guestfs_message_direction*);
extern bool_t xdr_guestfs_message_status (XDR *, guestfs_message_status*);
@@ -437,6 +453,8 @@ extern bool_t xdr_guestfs_aug_rm_ret ();
extern bool_t xdr_guestfs_aug_mv_args ();
extern bool_t xdr_guestfs_aug_match_args ();
extern bool_t xdr_guestfs_aug_match_ret ();
+extern bool_t xdr_guestfs_aug_ls_args ();
+extern bool_t xdr_guestfs_aug_ls_ret ();
extern bool_t xdr_guestfs_procedure ();
extern bool_t xdr_guestfs_message_direction ();
extern bool_t xdr_guestfs_message_status ();
diff --git a/src/guestfs_protocol.x b/src/guestfs_protocol.x
index eb3045e0..8e3d2a95 100644
--- a/src/guestfs_protocol.x
+++ b/src/guestfs_protocol.x
@@ -223,6 +223,14 @@ struct guestfs_aug_match_ret {
str matches<>;
};
+struct guestfs_aug_ls_args {
+ string path<>;
+};
+
+struct guestfs_aug_ls_ret {
+ str matches<>;
+};
+
enum guestfs_procedure {
GUESTFS_PROC_MOUNT = 1,
GUESTFS_PROC_SYNC = 2,
@@ -251,6 +259,7 @@ enum guestfs_procedure {
GUESTFS_PROC_AUG_MATCH = 24,
GUESTFS_PROC_AUG_SAVE = 25,
GUESTFS_PROC_AUG_LOAD = 27,
+ GUESTFS_PROC_AUG_LS = 28,
GUESTFS_PROC_dummy
};