diff options
author | Richard Jones <rjones@redhat.com> | 2009-04-18 22:33:15 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-04-18 22:33:15 +0100 |
commit | bb07a7f858da5d07c57360e62c0ddfd24ce6be45 (patch) | |
tree | 56201f1c514d8d79a56251b104c3d8a135fcbd39 /daemon | |
parent | 7bf3e1a43512293b1a3f78f880b57e7bbd372eae (diff) | |
download | libguestfs-bb07a7f858da5d07c57360e62c0ddfd24ce6be45.tar.gz libguestfs-bb07a7f858da5d07c57360e62c0ddfd24ce6be45.tar.xz libguestfs-bb07a7f858da5d07c57360e62c0ddfd24ce6be45.zip |
Begin to add the upload and download commands.
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/actions.h | 2 | ||||
-rw-r--r-- | daemon/stubs.c | 54 |
2 files changed, 56 insertions, 0 deletions
diff --git a/daemon/actions.h b/daemon/actions.h index 76ce8fcb..01ef882a 100644 --- a/daemon/actions.h +++ b/daemon/actions.h @@ -86,3 +86,5 @@ extern int64_t do_blockdev_getsz (const char *device); extern int64_t do_blockdev_getsize64 (const char *device); extern int do_blockdev_flushbufs (const char *device); extern int do_blockdev_rereadpt (const char *device); +extern int do_upload (const char *remotefilename); +extern int do_download (const char *remotefilename); diff --git a/daemon/stubs.c b/daemon/stubs.c index dfadb838..df067ccc 100644 --- a/daemon/stubs.c +++ b/daemon/stubs.c @@ -1584,6 +1584,54 @@ done: xdr_free ((xdrproc_t) xdr_guestfs_blockdev_rereadpt_args, (char *) &args); } +static void upload_stub (XDR *xdr_in) +{ + int r; + struct guestfs_upload_args args; + const char *remotefilename; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_upload_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "upload"); + return; + } + remotefilename = args.remotefilename; + + r = do_upload (remotefilename); + if (r == -1) + /* do_upload has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_upload_args, (char *) &args); +} + +static void download_stub (XDR *xdr_in) +{ + int r; + struct guestfs_download_args args; + const char *remotefilename; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_download_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "download"); + return; + } + remotefilename = args.remotefilename; + + r = do_download (remotefilename); + if (r == -1) + /* do_download has already called reply_with_error */ + goto done; + + /* do_download has already sent a reply */ +done: + xdr_free ((xdrproc_t) xdr_guestfs_download_args, (char *) &args); +} + void dispatch_incoming_message (XDR *xdr_in) { switch (proc_nr) { @@ -1782,6 +1830,12 @@ void dispatch_incoming_message (XDR *xdr_in) case GUESTFS_PROC_BLOCKDEV_REREADPT: blockdev_rereadpt_stub (xdr_in); break; + case GUESTFS_PROC_UPLOAD: + upload_stub (xdr_in); + break; + case GUESTFS_PROC_DOWNLOAD: + download_stub (xdr_in); + break; default: reply_with_error ("dispatch_incoming_message: unknown procedure number %d", proc_nr); } |