diff options
author | Richard Jones <rjones@redhat.com> | 2009-04-30 18:57:07 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-04-30 18:57:07 +0100 |
commit | 0703248d233744047515418893dac05ce013a642 (patch) | |
tree | ead0b718136e64b179b9d46f3fc314cdd49f2149 /src | |
parent | c69c3695303d5a660ad093a076c2e364ae6061de (diff) | |
download | libguestfs-0703248d233744047515418893dac05ce013a642.tar.gz libguestfs-0703248d233744047515418893dac05ce013a642.tar.xz libguestfs-0703248d233744047515418893dac05ce013a642.zip |
Add generated code for 'fsck' command.
Diffstat (limited to 'src')
-rw-r--r-- | src/guestfs-actions.c | 93 | ||||
-rw-r--r-- | src/guestfs-actions.h | 1 | ||||
-rw-r--r-- | src/guestfs_protocol.c | 22 | ||||
-rw-r--r-- | src/guestfs_protocol.h | 18 | ||||
-rw-r--r-- | src/guestfs_protocol.x | 10 |
5 files changed, 143 insertions, 1 deletions
diff --git a/src/guestfs-actions.c b/src/guestfs-actions.c index f39aa75e..a075b802 100644 --- a/src/guestfs-actions.c +++ b/src/guestfs-actions.c @@ -7549,3 +7549,96 @@ char *guestfs_get_e2uuid (guestfs_h *g, return ctx.ret.uuid; /* caller will free */ } +struct fsck_ctx { + /* This flag is set by the callbacks, so we know we've done + * the callbacks as expected, and in the right sequence. + * 0 = not called, 1 = reply_cb called. + */ + int cb_sequence; + struct guestfs_message_header hdr; + struct guestfs_message_error err; + struct guestfs_fsck_ret ret; +}; + +static void fsck_reply_cb (guestfs_h *g, void *data, XDR *xdr) +{ + guestfs_main_loop *ml = guestfs_get_main_loop (g); + struct fsck_ctx *ctx = (struct fsck_ctx *) data; + + /* This should definitely not happen. */ + if (ctx->cb_sequence != 0) { + ctx->cb_sequence = 9999; + error (g, "%s: internal error: reply callback called twice", "guestfs_fsck"); + return; + } + + ml->main_loop_quit (ml, g); + + if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) { + error (g, "%s: failed to parse reply header", "guestfs_fsck"); + return; + } + if (ctx->hdr.status == GUESTFS_STATUS_ERROR) { + if (!xdr_guestfs_message_error (xdr, &ctx->err)) { + error (g, "%s: failed to parse reply error", "guestfs_fsck"); + return; + } + goto done; + } + if (!xdr_guestfs_fsck_ret (xdr, &ctx->ret)) { + error (g, "%s: failed to parse reply", "guestfs_fsck"); + return; + } + done: + ctx->cb_sequence = 1; +} + +int guestfs_fsck (guestfs_h *g, + const char *fstype, + const char *device) +{ + struct guestfs_fsck_args args; + struct fsck_ctx ctx; + guestfs_main_loop *ml = guestfs_get_main_loop (g); + int serial; + + if (check_state (g, "guestfs_fsck") == -1) return -1; + guestfs_set_busy (g); + + memset (&ctx, 0, sizeof ctx); + + args.fstype = (char *) fstype; + args.device = (char *) device; + serial = guestfs__send_sync (g, GUESTFS_PROC_FSCK, + (xdrproc_t) xdr_guestfs_fsck_args, (char *) &args); + if (serial == -1) { + guestfs_set_ready (g); + return -1; + } + + guestfs__switch_to_receiving (g); + ctx.cb_sequence = 0; + guestfs_set_reply_callback (g, fsck_reply_cb, &ctx); + (void) ml->main_loop_run (ml, g); + guestfs_set_reply_callback (g, NULL, NULL); + if (ctx.cb_sequence != 1) { + error (g, "%s reply failed, see earlier error messages", "guestfs_fsck"); + guestfs_set_ready (g); + return -1; + } + + if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_FSCK, serial) == -1) { + guestfs_set_ready (g); + return -1; + } + + if (ctx.hdr.status == GUESTFS_STATUS_ERROR) { + error (g, "%s", ctx.err.error_message); + guestfs_set_ready (g); + return -1; + } + + guestfs_set_ready (g); + return ctx.ret.status; +} + diff --git a/src/guestfs-actions.h b/src/guestfs-actions.h index c8570b01..6e56099a 100644 --- a/src/guestfs-actions.h +++ b/src/guestfs-actions.h @@ -123,3 +123,4 @@ extern int guestfs_set_e2label (guestfs_h *handle, const char *device, const cha extern char *guestfs_get_e2label (guestfs_h *handle, const char *device); extern int guestfs_set_e2uuid (guestfs_h *handle, const char *device, const char *uuid); extern char *guestfs_get_e2uuid (guestfs_h *handle, const char *device); +extern int guestfs_fsck (guestfs_h *handle, const char *fstype, const char *device); diff --git a/src/guestfs_protocol.c b/src/guestfs_protocol.c index c26d5398..16e80f17 100644 --- a/src/guestfs_protocol.c +++ b/src/guestfs_protocol.c @@ -1428,6 +1428,28 @@ xdr_guestfs_get_e2uuid_ret (XDR *xdrs, guestfs_get_e2uuid_ret *objp) } bool_t +xdr_guestfs_fsck_args (XDR *xdrs, guestfs_fsck_args *objp) +{ + register int32_t *buf; + + if (!xdr_string (xdrs, &objp->fstype, ~0)) + return FALSE; + if (!xdr_string (xdrs, &objp->device, ~0)) + return FALSE; + return TRUE; +} + +bool_t +xdr_guestfs_fsck_ret (XDR *xdrs, guestfs_fsck_ret *objp) +{ + register int32_t *buf; + + if (!xdr_int (xdrs, &objp->status)) + 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 90b0ede9..64e4b4db 100644 --- a/src/guestfs_protocol.h +++ b/src/guestfs_protocol.h @@ -739,6 +739,17 @@ struct guestfs_get_e2uuid_ret { }; typedef struct guestfs_get_e2uuid_ret guestfs_get_e2uuid_ret; +struct guestfs_fsck_args { + char *fstype; + char *device; +}; +typedef struct guestfs_fsck_args guestfs_fsck_args; + +struct guestfs_fsck_ret { + int status; +}; +typedef struct guestfs_fsck_ret guestfs_fsck_ret; + enum guestfs_procedure { GUESTFS_PROC_MOUNT = 1, GUESTFS_PROC_SYNC = 2, @@ -823,7 +834,8 @@ enum guestfs_procedure { GUESTFS_PROC_GET_E2LABEL = 81, GUESTFS_PROC_SET_E2UUID = 82, GUESTFS_PROC_GET_E2UUID = 83, - GUESTFS_PROC_NR_PROCS = 83 + 1, + GUESTFS_PROC_FSCK = 84, + GUESTFS_PROC_NR_PROCS = 84 + 1, }; typedef enum guestfs_procedure guestfs_procedure; #define GUESTFS_MESSAGE_MAX 4194304 @@ -988,6 +1000,8 @@ extern bool_t xdr_guestfs_get_e2label_ret (XDR *, guestfs_get_e2label_ret*); extern bool_t xdr_guestfs_set_e2uuid_args (XDR *, guestfs_set_e2uuid_args*); extern bool_t xdr_guestfs_get_e2uuid_args (XDR *, guestfs_get_e2uuid_args*); extern bool_t xdr_guestfs_get_e2uuid_ret (XDR *, guestfs_get_e2uuid_ret*); +extern bool_t xdr_guestfs_fsck_args (XDR *, guestfs_fsck_args*); +extern bool_t xdr_guestfs_fsck_ret (XDR *, guestfs_fsck_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*); @@ -1111,6 +1125,8 @@ extern bool_t xdr_guestfs_get_e2label_ret (); extern bool_t xdr_guestfs_set_e2uuid_args (); extern bool_t xdr_guestfs_get_e2uuid_args (); extern bool_t xdr_guestfs_get_e2uuid_ret (); +extern bool_t xdr_guestfs_fsck_args (); +extern bool_t xdr_guestfs_fsck_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 0cfb8ee2..92dc8eac 100644 --- a/src/guestfs_protocol.x +++ b/src/guestfs_protocol.x @@ -573,6 +573,15 @@ struct guestfs_get_e2uuid_ret { string uuid<>; }; +struct guestfs_fsck_args { + string fstype<>; + string device<>; +}; + +struct guestfs_fsck_ret { + int status; +}; + enum guestfs_procedure { GUESTFS_PROC_MOUNT = 1, GUESTFS_PROC_SYNC = 2, @@ -657,6 +666,7 @@ enum guestfs_procedure { GUESTFS_PROC_GET_E2LABEL = 81, GUESTFS_PROC_SET_E2UUID = 82, GUESTFS_PROC_GET_E2UUID = 83, + GUESTFS_PROC_FSCK = 84, GUESTFS_PROC_NR_PROCS }; |