X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Fstubs.c;h=64d66a9600d289da16e0b1172c26fd6cff5e3b4b;hp=af0f14c3ff176f2c13953d8ce970eaae53a4d95e;hb=9222136ac9b2e404dba128b1ac74dacaa8bf1038;hpb=adefe14e308a0f8cf73f9c60693a3dbbded157b9 diff --git a/daemon/stubs.c b/daemon/stubs.c index af0f14c..64d66a9 100644 --- a/daemon/stubs.c +++ b/daemon/stubs.c @@ -19,7 +19,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE // for strchrnul +#include #include #include @@ -940,228 +940,1319 @@ static void vgcreate_stub (XDR *xdr_in) return; } volgroup = args.volgroup; - args.physvols.physvols_val = realloc (args.physvols.physvols_val, sizeof (char *) * (args.physvols.physvols_len+1)); - args.physvols.physvols_val[args.physvols.physvols_len] = NULL; - physvols = args.physvols.physvols_val; + physvols = realloc (args.physvols.physvols_val, + sizeof (char *) * (args.physvols.physvols_len+1)); + if (physvols == NULL) { + reply_with_perror ("realloc"); + goto done; + } + physvols[args.physvols.physvols_len] = NULL; + args.physvols.physvols_val = physvols; + + r = do_vgcreate (volgroup, physvols); + if (r == -1) + /* do_vgcreate has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_vgcreate_args, (char *) &args); +} + +static void lvcreate_stub (XDR *xdr_in) +{ + int r; + struct guestfs_lvcreate_args args; + const char *logvol; + const char *volgroup; + int mbytes; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_lvcreate_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "lvcreate"); + return; + } + logvol = args.logvol; + volgroup = args.volgroup; + mbytes = args.mbytes; + + r = do_lvcreate (logvol, volgroup, mbytes); + if (r == -1) + /* do_lvcreate has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_lvcreate_args, (char *) &args); +} + +static void mkfs_stub (XDR *xdr_in) +{ + int r; + struct guestfs_mkfs_args args; + const char *fstype; + const char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_mkfs_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "mkfs"); + return; + } + fstype = args.fstype; + device = args.device; + + r = do_mkfs (fstype, device); + if (r == -1) + /* do_mkfs has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_mkfs_args, (char *) &args); +} + +static void sfdisk_stub (XDR *xdr_in) +{ + int r; + struct guestfs_sfdisk_args args; + const char *device; + int cyls; + int heads; + int sectors; + char **lines; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_sfdisk_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "sfdisk"); + return; + } + device = args.device; + cyls = args.cyls; + heads = args.heads; + sectors = args.sectors; + lines = realloc (args.lines.lines_val, + sizeof (char *) * (args.lines.lines_len+1)); + if (lines == NULL) { + reply_with_perror ("realloc"); + goto done; + } + lines[args.lines.lines_len] = NULL; + args.lines.lines_val = lines; + + r = do_sfdisk (device, cyls, heads, sectors, lines); + if (r == -1) + /* do_sfdisk has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_sfdisk_args, (char *) &args); +} + +static void write_file_stub (XDR *xdr_in) +{ + int r; + struct guestfs_write_file_args args; + const char *path; + const char *content; + int size; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_write_file_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "write_file"); + return; + } + path = args.path; + content = args.content; + size = args.size; + + r = do_write_file (path, content, size); + if (r == -1) + /* do_write_file has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_write_file_args, (char *) &args); +} + +static void umount_stub (XDR *xdr_in) +{ + int r; + struct guestfs_umount_args args; + const char *pathordevice; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_umount_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "umount"); + return; + } + pathordevice = args.pathordevice; + + r = do_umount (pathordevice); + if (r == -1) + /* do_umount has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_umount_args, (char *) &args); +} + +static void mounts_stub (XDR *xdr_in) +{ + char **r; + + r = do_mounts (); + if (r == NULL) + /* do_mounts has already called reply_with_error */ + goto done; + + struct guestfs_mounts_ret ret; + ret.devices.devices_len = count_strings (r); + ret.devices.devices_val = r; + reply ((xdrproc_t) &xdr_guestfs_mounts_ret, (char *) &ret); + free_strings (r); +done: ; +} + +static void umount_all_stub (XDR *xdr_in) +{ + int r; + + r = do_umount_all (); + if (r == -1) + /* do_umount_all has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: ; +} + +static void lvm_remove_all_stub (XDR *xdr_in) +{ + int r; + + r = do_lvm_remove_all (); + if (r == -1) + /* do_lvm_remove_all has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: ; +} + +static void file_stub (XDR *xdr_in) +{ + char *r; + struct guestfs_file_args args; + const char *path; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_file_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "file"); + return; + } + path = args.path; + + r = do_file (path); + if (r == NULL) + /* do_file has already called reply_with_error */ + goto done; + + struct guestfs_file_ret ret; + ret.description = r; + reply ((xdrproc_t) &xdr_guestfs_file_ret, (char *) &ret); + free (r); +done: + xdr_free ((xdrproc_t) xdr_guestfs_file_args, (char *) &args); +} + +static void command_stub (XDR *xdr_in) +{ + char *r; + struct guestfs_command_args args; + char **arguments; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_command_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "command"); + return; + } + arguments = realloc (args.arguments.arguments_val, + sizeof (char *) * (args.arguments.arguments_len+1)); + if (arguments == NULL) { + reply_with_perror ("realloc"); + goto done; + } + arguments[args.arguments.arguments_len] = NULL; + args.arguments.arguments_val = arguments; + + r = do_command (arguments); + if (r == NULL) + /* do_command has already called reply_with_error */ + goto done; + + struct guestfs_command_ret ret; + ret.output = r; + reply ((xdrproc_t) &xdr_guestfs_command_ret, (char *) &ret); + free (r); +done: + xdr_free ((xdrproc_t) xdr_guestfs_command_args, (char *) &args); +} + +static void command_lines_stub (XDR *xdr_in) +{ + char **r; + struct guestfs_command_lines_args args; + char **arguments; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_command_lines_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "command_lines"); + return; + } + arguments = realloc (args.arguments.arguments_val, + sizeof (char *) * (args.arguments.arguments_len+1)); + if (arguments == NULL) { + reply_with_perror ("realloc"); + goto done; + } + arguments[args.arguments.arguments_len] = NULL; + args.arguments.arguments_val = arguments; + + r = do_command_lines (arguments); + if (r == NULL) + /* do_command_lines has already called reply_with_error */ + goto done; + + struct guestfs_command_lines_ret ret; + ret.lines.lines_len = count_strings (r); + ret.lines.lines_val = r; + reply ((xdrproc_t) &xdr_guestfs_command_lines_ret, (char *) &ret); + free_strings (r); +done: + xdr_free ((xdrproc_t) xdr_guestfs_command_lines_args, (char *) &args); +} + +static void stat_stub (XDR *xdr_in) +{ + guestfs_int_stat *r; + struct guestfs_stat_args args; + const char *path; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_stat_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "stat"); + return; + } + path = args.path; + + r = do_stat (path); + if (r == NULL) + /* do_stat has already called reply_with_error */ + goto done; + + struct guestfs_stat_ret ret; + ret.statbuf = *r; + reply ((xdrproc_t) xdr_guestfs_stat_ret, (char *) &ret); + xdr_free ((xdrproc_t) xdr_guestfs_stat_ret, (char *) &ret); +done: + xdr_free ((xdrproc_t) xdr_guestfs_stat_args, (char *) &args); +} + +static void lstat_stub (XDR *xdr_in) +{ + guestfs_int_stat *r; + struct guestfs_lstat_args args; + const char *path; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_lstat_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "lstat"); + return; + } + path = args.path; + + r = do_lstat (path); + if (r == NULL) + /* do_lstat has already called reply_with_error */ + goto done; + + struct guestfs_lstat_ret ret; + ret.statbuf = *r; + reply ((xdrproc_t) xdr_guestfs_lstat_ret, (char *) &ret); + xdr_free ((xdrproc_t) xdr_guestfs_lstat_ret, (char *) &ret); +done: + xdr_free ((xdrproc_t) xdr_guestfs_lstat_args, (char *) &args); +} + +static void statvfs_stub (XDR *xdr_in) +{ + guestfs_int_statvfs *r; + struct guestfs_statvfs_args args; + const char *path; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_statvfs_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "statvfs"); + return; + } + path = args.path; + + r = do_statvfs (path); + if (r == NULL) + /* do_statvfs has already called reply_with_error */ + goto done; + + struct guestfs_statvfs_ret ret; + ret.statbuf = *r; + reply ((xdrproc_t) xdr_guestfs_statvfs_ret, (char *) &ret); + xdr_free ((xdrproc_t) xdr_guestfs_statvfs_ret, (char *) &ret); +done: + xdr_free ((xdrproc_t) xdr_guestfs_statvfs_args, (char *) &args); +} + +static void tune2fs_l_stub (XDR *xdr_in) +{ + char **r; + struct guestfs_tune2fs_l_args args; + const char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_tune2fs_l_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "tune2fs_l"); + return; + } + device = args.device; + + r = do_tune2fs_l (device); + if (r == NULL) + /* do_tune2fs_l has already called reply_with_error */ + goto done; + + struct guestfs_tune2fs_l_ret ret; + ret.superblock.superblock_len = count_strings (r); + ret.superblock.superblock_val = r; + reply ((xdrproc_t) &xdr_guestfs_tune2fs_l_ret, (char *) &ret); + free_strings (r); +done: + xdr_free ((xdrproc_t) xdr_guestfs_tune2fs_l_args, (char *) &args); +} + +static void blockdev_setro_stub (XDR *xdr_in) +{ + int r; + struct guestfs_blockdev_setro_args args; + const char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_blockdev_setro_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_setro"); + return; + } + device = args.device; + + r = do_blockdev_setro (device); + if (r == -1) + /* do_blockdev_setro has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_blockdev_setro_args, (char *) &args); +} + +static void blockdev_setrw_stub (XDR *xdr_in) +{ + int r; + struct guestfs_blockdev_setrw_args args; + const char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_blockdev_setrw_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_setrw"); + return; + } + device = args.device; + + r = do_blockdev_setrw (device); + if (r == -1) + /* do_blockdev_setrw has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_blockdev_setrw_args, (char *) &args); +} + +static void blockdev_getro_stub (XDR *xdr_in) +{ + int r; + struct guestfs_blockdev_getro_args args; + const char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_blockdev_getro_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_getro"); + return; + } + device = args.device; + + r = do_blockdev_getro (device); + if (r == -1) + /* do_blockdev_getro has already called reply_with_error */ + goto done; + + struct guestfs_blockdev_getro_ret ret; + ret.ro = r; + reply ((xdrproc_t) &xdr_guestfs_blockdev_getro_ret, (char *) &ret); +done: + xdr_free ((xdrproc_t) xdr_guestfs_blockdev_getro_args, (char *) &args); +} + +static void blockdev_getss_stub (XDR *xdr_in) +{ + int r; + struct guestfs_blockdev_getss_args args; + const char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_blockdev_getss_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_getss"); + return; + } + device = args.device; + + r = do_blockdev_getss (device); + if (r == -1) + /* do_blockdev_getss has already called reply_with_error */ + goto done; + + struct guestfs_blockdev_getss_ret ret; + ret.sectorsize = r; + reply ((xdrproc_t) &xdr_guestfs_blockdev_getss_ret, (char *) &ret); +done: + xdr_free ((xdrproc_t) xdr_guestfs_blockdev_getss_args, (char *) &args); +} + +static void blockdev_getbsz_stub (XDR *xdr_in) +{ + int r; + struct guestfs_blockdev_getbsz_args args; + const char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_blockdev_getbsz_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_getbsz"); + return; + } + device = args.device; + + r = do_blockdev_getbsz (device); + if (r == -1) + /* do_blockdev_getbsz has already called reply_with_error */ + goto done; + + struct guestfs_blockdev_getbsz_ret ret; + ret.blocksize = r; + reply ((xdrproc_t) &xdr_guestfs_blockdev_getbsz_ret, (char *) &ret); +done: + xdr_free ((xdrproc_t) xdr_guestfs_blockdev_getbsz_args, (char *) &args); +} + +static void blockdev_setbsz_stub (XDR *xdr_in) +{ + int r; + struct guestfs_blockdev_setbsz_args args; + const char *device; + int blocksize; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_blockdev_setbsz_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_setbsz"); + return; + } + device = args.device; + blocksize = args.blocksize; + + r = do_blockdev_setbsz (device, blocksize); + if (r == -1) + /* do_blockdev_setbsz has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_blockdev_setbsz_args, (char *) &args); +} + +static void blockdev_getsz_stub (XDR *xdr_in) +{ + int64_t r; + struct guestfs_blockdev_getsz_args args; + const char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_blockdev_getsz_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_getsz"); + return; + } + device = args.device; + + r = do_blockdev_getsz (device); + if (r == -1) + /* do_blockdev_getsz has already called reply_with_error */ + goto done; + + struct guestfs_blockdev_getsz_ret ret; + ret.sizeinsectors = r; + reply ((xdrproc_t) &xdr_guestfs_blockdev_getsz_ret, (char *) &ret); +done: + xdr_free ((xdrproc_t) xdr_guestfs_blockdev_getsz_args, (char *) &args); +} + +static void blockdev_getsize64_stub (XDR *xdr_in) +{ + int64_t r; + struct guestfs_blockdev_getsize64_args args; + const char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_blockdev_getsize64_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_getsize64"); + return; + } + device = args.device; + + r = do_blockdev_getsize64 (device); + if (r == -1) + /* do_blockdev_getsize64 has already called reply_with_error */ + goto done; + + struct guestfs_blockdev_getsize64_ret ret; + ret.sizeinbytes = r; + reply ((xdrproc_t) &xdr_guestfs_blockdev_getsize64_ret, (char *) &ret); +done: + xdr_free ((xdrproc_t) xdr_guestfs_blockdev_getsize64_args, (char *) &args); +} + +static void blockdev_flushbufs_stub (XDR *xdr_in) +{ + int r; + struct guestfs_blockdev_flushbufs_args args; + const char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_blockdev_flushbufs_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_flushbufs"); + return; + } + device = args.device; + + r = do_blockdev_flushbufs (device); + if (r == -1) + /* do_blockdev_flushbufs has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_blockdev_flushbufs_args, (char *) &args); +} + +static void blockdev_rereadpt_stub (XDR *xdr_in) +{ + int r; + struct guestfs_blockdev_rereadpt_args args; + const char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_blockdev_rereadpt_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_rereadpt"); + return; + } + device = args.device; + + r = do_blockdev_rereadpt (device); + if (r == -1) + /* do_blockdev_rereadpt has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +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); +} + +static void checksum_stub (XDR *xdr_in) +{ + char *r; + struct guestfs_checksum_args args; + const char *csumtype; + const char *path; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_checksum_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "checksum"); + return; + } + csumtype = args.csumtype; + path = args.path; + + r = do_checksum (csumtype, path); + if (r == NULL) + /* do_checksum has already called reply_with_error */ + goto done; + + struct guestfs_checksum_ret ret; + ret.checksum = r; + reply ((xdrproc_t) &xdr_guestfs_checksum_ret, (char *) &ret); + free (r); +done: + xdr_free ((xdrproc_t) xdr_guestfs_checksum_args, (char *) &args); +} + +static void tar_in_stub (XDR *xdr_in) +{ + int r; + struct guestfs_tar_in_args args; + const char *directory; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_tar_in_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "tar_in"); + return; + } + directory = args.directory; + + r = do_tar_in (directory); + if (r == -1) + /* do_tar_in has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_tar_in_args, (char *) &args); +} + +static void tar_out_stub (XDR *xdr_in) +{ + int r; + struct guestfs_tar_out_args args; + const char *directory; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_tar_out_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "tar_out"); + return; + } + directory = args.directory; + + r = do_tar_out (directory); + if (r == -1) + /* do_tar_out has already called reply_with_error */ + goto done; + + /* do_tar_out has already sent a reply */ +done: + xdr_free ((xdrproc_t) xdr_guestfs_tar_out_args, (char *) &args); +} + +static void tgz_in_stub (XDR *xdr_in) +{ + int r; + struct guestfs_tgz_in_args args; + const char *directory; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_tgz_in_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "tgz_in"); + return; + } + directory = args.directory; + + r = do_tgz_in (directory); + if (r == -1) + /* do_tgz_in has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_tgz_in_args, (char *) &args); +} + +static void tgz_out_stub (XDR *xdr_in) +{ + int r; + struct guestfs_tgz_out_args args; + const char *directory; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_tgz_out_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "tgz_out"); + return; + } + directory = args.directory; + + r = do_tgz_out (directory); + if (r == -1) + /* do_tgz_out has already called reply_with_error */ + goto done; + + /* do_tgz_out has already sent a reply */ +done: + xdr_free ((xdrproc_t) xdr_guestfs_tgz_out_args, (char *) &args); +} + +static void mount_ro_stub (XDR *xdr_in) +{ + int r; + struct guestfs_mount_ro_args args; + const char *device; + const char *mountpoint; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_mount_ro_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "mount_ro"); + return; + } + device = args.device; + mountpoint = args.mountpoint; + + r = do_mount_ro (device, mountpoint); + if (r == -1) + /* do_mount_ro has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_mount_ro_args, (char *) &args); +} + +static void mount_options_stub (XDR *xdr_in) +{ + int r; + struct guestfs_mount_options_args args; + const char *options; + const char *device; + const char *mountpoint; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_mount_options_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "mount_options"); + return; + } + options = args.options; + device = args.device; + mountpoint = args.mountpoint; + + r = do_mount_options (options, device, mountpoint); + if (r == -1) + /* do_mount_options has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_mount_options_args, (char *) &args); +} + +static void mount_vfs_stub (XDR *xdr_in) +{ + int r; + struct guestfs_mount_vfs_args args; + const char *options; + const char *vfstype; + const char *device; + const char *mountpoint; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_mount_vfs_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "mount_vfs"); + return; + } + options = args.options; + vfstype = args.vfstype; + device = args.device; + mountpoint = args.mountpoint; + + r = do_mount_vfs (options, vfstype, device, mountpoint); + if (r == -1) + /* do_mount_vfs has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_mount_vfs_args, (char *) &args); +} + +static void debug_stub (XDR *xdr_in) +{ + char *r; + struct guestfs_debug_args args; + const char *subcmd; + char **extraargs; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_debug_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "debug"); + return; + } + subcmd = args.subcmd; + extraargs = realloc (args.extraargs.extraargs_val, + sizeof (char *) * (args.extraargs.extraargs_len+1)); + if (extraargs == NULL) { + reply_with_perror ("realloc"); + goto done; + } + extraargs[args.extraargs.extraargs_len] = NULL; + args.extraargs.extraargs_val = extraargs; + + r = do_debug (subcmd, extraargs); + if (r == NULL) + /* do_debug has already called reply_with_error */ + goto done; + + struct guestfs_debug_ret ret; + ret.result = r; + reply ((xdrproc_t) &xdr_guestfs_debug_ret, (char *) &ret); + free (r); +done: + xdr_free ((xdrproc_t) xdr_guestfs_debug_args, (char *) &args); +} + +static void lvremove_stub (XDR *xdr_in) +{ + int r; + struct guestfs_lvremove_args args; + const char *device; - r = do_vgcreate (volgroup, physvols); + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_lvremove_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "lvremove"); + return; + } + device = args.device; + + r = do_lvremove (device); if (r == -1) - /* do_vgcreate has already called reply_with_error */ + /* do_lvremove has already called reply_with_error */ goto done; reply (NULL, NULL); done: - xdr_free ((xdrproc_t) xdr_guestfs_vgcreate_args, (char *) &args); + xdr_free ((xdrproc_t) xdr_guestfs_lvremove_args, (char *) &args); } -static void lvcreate_stub (XDR *xdr_in) +static void vgremove_stub (XDR *xdr_in) { int r; - struct guestfs_lvcreate_args args; - const char *logvol; - const char *volgroup; - int mbytes; + struct guestfs_vgremove_args args; + const char *vgname; memset (&args, 0, sizeof args); - if (!xdr_guestfs_lvcreate_args (xdr_in, &args)) { - reply_with_error ("%s: daemon failed to decode procedure arguments", "lvcreate"); + if (!xdr_guestfs_vgremove_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "vgremove"); return; } - logvol = args.logvol; - volgroup = args.volgroup; - mbytes = args.mbytes; + vgname = args.vgname; - r = do_lvcreate (logvol, volgroup, mbytes); + r = do_vgremove (vgname); if (r == -1) - /* do_lvcreate has already called reply_with_error */ + /* do_vgremove has already called reply_with_error */ goto done; reply (NULL, NULL); done: - xdr_free ((xdrproc_t) xdr_guestfs_lvcreate_args, (char *) &args); + xdr_free ((xdrproc_t) xdr_guestfs_vgremove_args, (char *) &args); } -static void mkfs_stub (XDR *xdr_in) +static void pvremove_stub (XDR *xdr_in) { int r; - struct guestfs_mkfs_args args; - const char *fstype; + struct guestfs_pvremove_args args; const char *device; memset (&args, 0, sizeof args); - if (!xdr_guestfs_mkfs_args (xdr_in, &args)) { - reply_with_error ("%s: daemon failed to decode procedure arguments", "mkfs"); + if (!xdr_guestfs_pvremove_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "pvremove"); return; } - fstype = args.fstype; device = args.device; - r = do_mkfs (fstype, device); + r = do_pvremove (device); if (r == -1) - /* do_mkfs has already called reply_with_error */ + /* do_pvremove has already called reply_with_error */ goto done; reply (NULL, NULL); done: - xdr_free ((xdrproc_t) xdr_guestfs_mkfs_args, (char *) &args); + xdr_free ((xdrproc_t) xdr_guestfs_pvremove_args, (char *) &args); } -static void sfdisk_stub (XDR *xdr_in) +static void set_e2label_stub (XDR *xdr_in) { int r; - struct guestfs_sfdisk_args args; + struct guestfs_set_e2label_args args; const char *device; - int cyls; - int heads; - int sectors; - char **lines; + const char *label; memset (&args, 0, sizeof args); - if (!xdr_guestfs_sfdisk_args (xdr_in, &args)) { - reply_with_error ("%s: daemon failed to decode procedure arguments", "sfdisk"); + 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; - cyls = args.cyls; - heads = args.heads; - sectors = args.sectors; - args.lines.lines_val = realloc (args.lines.lines_val, sizeof (char *) * (args.lines.lines_len+1)); - args.lines.lines_val[args.lines.lines_len] = NULL; - lines = args.lines.lines_val; + label = args.label; - r = do_sfdisk (device, cyls, heads, sectors, lines); + r = do_set_e2label (device, label); if (r == -1) - /* do_sfdisk has already called reply_with_error */ + /* do_set_e2label has already called reply_with_error */ goto done; reply (NULL, NULL); done: - xdr_free ((xdrproc_t) xdr_guestfs_sfdisk_args, (char *) &args); + xdr_free ((xdrproc_t) xdr_guestfs_set_e2label_args, (char *) &args); } -static void write_file_stub (XDR *xdr_in) +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_write_file_args args; - const char *path; - const char *content; - int size; + struct guestfs_set_e2uuid_args args; + const char *device; + const char *uuid; memset (&args, 0, sizeof args); - if (!xdr_guestfs_write_file_args (xdr_in, &args)) { - reply_with_error ("%s: daemon failed to decode procedure arguments", "write_file"); + if (!xdr_guestfs_set_e2uuid_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "set_e2uuid"); return; } - path = args.path; - content = args.content; - size = args.size; + device = args.device; + uuid = args.uuid; - r = do_write_file (path, content, size); + r = do_set_e2uuid (device, uuid); if (r == -1) - /* do_write_file has already called reply_with_error */ + /* do_set_e2uuid has already called reply_with_error */ goto done; reply (NULL, NULL); done: - xdr_free ((xdrproc_t) xdr_guestfs_write_file_args, (char *) &args); + xdr_free ((xdrproc_t) xdr_guestfs_set_e2uuid_args, (char *) &args); } -static void umount_stub (XDR *xdr_in) +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); +} + +static void fsck_stub (XDR *xdr_in) { int r; - struct guestfs_umount_args args; - const char *pathordevice; + struct guestfs_fsck_args args; + const char *fstype; + const char *device; memset (&args, 0, sizeof args); - if (!xdr_guestfs_umount_args (xdr_in, &args)) { - reply_with_error ("%s: daemon failed to decode procedure arguments", "umount"); + if (!xdr_guestfs_fsck_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "fsck"); return; } - pathordevice = args.pathordevice; + fstype = args.fstype; + device = args.device; - r = do_umount (pathordevice); + r = do_fsck (fstype, device); if (r == -1) - /* do_umount has already called reply_with_error */ + /* do_fsck has already called reply_with_error */ + goto done; + + struct guestfs_fsck_ret ret; + ret.status = r; + reply ((xdrproc_t) &xdr_guestfs_fsck_ret, (char *) &ret); +done: + xdr_free ((xdrproc_t) xdr_guestfs_fsck_args, (char *) &args); +} + +static void zero_stub (XDR *xdr_in) +{ + int r; + struct guestfs_zero_args args; + const char *device; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_zero_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "zero"); + return; + } + device = args.device; + + r = do_zero (device); + if (r == -1) + /* do_zero has already called reply_with_error */ goto done; reply (NULL, NULL); done: - xdr_free ((xdrproc_t) xdr_guestfs_umount_args, (char *) &args); + xdr_free ((xdrproc_t) xdr_guestfs_zero_args, (char *) &args); } -static void mounts_stub (XDR *xdr_in) +static void grub_install_stub (XDR *xdr_in) { - char **r; + int r; + struct guestfs_grub_install_args args; + const char *root; + const char *device; - r = do_mounts (); - if (r == NULL) - /* do_mounts has already called reply_with_error */ + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_grub_install_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "grub_install"); + return; + } + root = args.root; + device = args.device; + + r = do_grub_install (root, device); + if (r == -1) + /* do_grub_install has already called reply_with_error */ goto done; - struct guestfs_mounts_ret ret; - ret.devices.devices_len = count_strings (r); - ret.devices.devices_val = r; - reply ((xdrproc_t) &xdr_guestfs_mounts_ret, (char *) &ret); - free_strings (r); -done: ; + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_grub_install_args, (char *) &args); } -static void umount_all_stub (XDR *xdr_in) +static void cp_stub (XDR *xdr_in) { int r; + struct guestfs_cp_args args; + const char *src; + const char *dest; - r = do_umount_all (); + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_cp_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "cp"); + return; + } + src = args.src; + dest = args.dest; + + r = do_cp (src, dest); if (r == -1) - /* do_umount_all has already called reply_with_error */ + /* do_cp has already called reply_with_error */ goto done; reply (NULL, NULL); -done: ; +done: + xdr_free ((xdrproc_t) xdr_guestfs_cp_args, (char *) &args); } -static void lvm_remove_all_stub (XDR *xdr_in) +static void cp_a_stub (XDR *xdr_in) { int r; + struct guestfs_cp_a_args args; + const char *src; + const char *dest; - r = do_lvm_remove_all (); + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_cp_a_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "cp_a"); + return; + } + src = args.src; + dest = args.dest; + + r = do_cp_a (src, dest); if (r == -1) - /* do_lvm_remove_all has already called reply_with_error */ + /* do_cp_a has already called reply_with_error */ goto done; reply (NULL, NULL); -done: ; +done: + xdr_free ((xdrproc_t) xdr_guestfs_cp_a_args, (char *) &args); } -static void file_stub (XDR *xdr_in) +static void mv_stub (XDR *xdr_in) { - char *r; - struct guestfs_file_args args; - const char *path; + int r; + struct guestfs_mv_args args; + const char *src; + const char *dest; memset (&args, 0, sizeof args); - if (!xdr_guestfs_file_args (xdr_in, &args)) { - reply_with_error ("%s: daemon failed to decode procedure arguments", "file"); + if (!xdr_guestfs_mv_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "mv"); return; } - path = args.path; + src = args.src; + dest = args.dest; - r = do_file (path); - if (r == NULL) - /* do_file has already called reply_with_error */ + r = do_mv (src, dest); + if (r == -1) + /* do_mv has already called reply_with_error */ goto done; - struct guestfs_file_ret ret; - ret.description = r; - reply ((xdrproc_t) &xdr_guestfs_file_ret, (char *) &ret); - free (r); + reply (NULL, NULL); done: - xdr_free ((xdrproc_t) xdr_guestfs_file_args, (char *) &args); + xdr_free ((xdrproc_t) xdr_guestfs_mv_args, (char *) &args); +} + +static void drop_caches_stub (XDR *xdr_in) +{ + int r; + struct guestfs_drop_caches_args args; + int whattodrop; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_drop_caches_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "drop_caches"); + return; + } + whattodrop = args.whattodrop; + + r = do_drop_caches (whattodrop); + if (r == -1) + /* do_drop_caches has already called reply_with_error */ + goto done; + + reply (NULL, NULL); +done: + xdr_free ((xdrproc_t) xdr_guestfs_drop_caches_args, (char *) &args); } void dispatch_incoming_message (XDR *xdr_in) @@ -1314,6 +2405,129 @@ void dispatch_incoming_message (XDR *xdr_in) case GUESTFS_PROC_FILE: file_stub (xdr_in); break; + case GUESTFS_PROC_COMMAND: + command_stub (xdr_in); + break; + case GUESTFS_PROC_COMMAND_LINES: + command_lines_stub (xdr_in); + break; + case GUESTFS_PROC_STAT: + stat_stub (xdr_in); + break; + case GUESTFS_PROC_LSTAT: + lstat_stub (xdr_in); + break; + case GUESTFS_PROC_STATVFS: + statvfs_stub (xdr_in); + break; + case GUESTFS_PROC_TUNE2FS_L: + tune2fs_l_stub (xdr_in); + break; + case GUESTFS_PROC_BLOCKDEV_SETRO: + blockdev_setro_stub (xdr_in); + break; + case GUESTFS_PROC_BLOCKDEV_SETRW: + blockdev_setrw_stub (xdr_in); + break; + case GUESTFS_PROC_BLOCKDEV_GETRO: + blockdev_getro_stub (xdr_in); + break; + case GUESTFS_PROC_BLOCKDEV_GETSS: + blockdev_getss_stub (xdr_in); + break; + case GUESTFS_PROC_BLOCKDEV_GETBSZ: + blockdev_getbsz_stub (xdr_in); + break; + case GUESTFS_PROC_BLOCKDEV_SETBSZ: + blockdev_setbsz_stub (xdr_in); + break; + case GUESTFS_PROC_BLOCKDEV_GETSZ: + blockdev_getsz_stub (xdr_in); + break; + case GUESTFS_PROC_BLOCKDEV_GETSIZE64: + blockdev_getsize64_stub (xdr_in); + break; + case GUESTFS_PROC_BLOCKDEV_FLUSHBUFS: + blockdev_flushbufs_stub (xdr_in); + break; + 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; + case GUESTFS_PROC_CHECKSUM: + checksum_stub (xdr_in); + break; + case GUESTFS_PROC_TAR_IN: + tar_in_stub (xdr_in); + break; + case GUESTFS_PROC_TAR_OUT: + tar_out_stub (xdr_in); + break; + case GUESTFS_PROC_TGZ_IN: + tgz_in_stub (xdr_in); + break; + case GUESTFS_PROC_TGZ_OUT: + tgz_out_stub (xdr_in); + break; + case GUESTFS_PROC_MOUNT_RO: + mount_ro_stub (xdr_in); + break; + case GUESTFS_PROC_MOUNT_OPTIONS: + mount_options_stub (xdr_in); + break; + case GUESTFS_PROC_MOUNT_VFS: + mount_vfs_stub (xdr_in); + break; + case GUESTFS_PROC_DEBUG: + debug_stub (xdr_in); + break; + case GUESTFS_PROC_LVREMOVE: + lvremove_stub (xdr_in); + break; + case GUESTFS_PROC_VGREMOVE: + vgremove_stub (xdr_in); + break; + 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; + case GUESTFS_PROC_FSCK: + fsck_stub (xdr_in); + break; + case GUESTFS_PROC_ZERO: + zero_stub (xdr_in); + break; + case GUESTFS_PROC_GRUB_INSTALL: + grub_install_stub (xdr_in); + break; + case GUESTFS_PROC_CP: + cp_stub (xdr_in); + break; + case GUESTFS_PROC_CP_A: + cp_a_stub (xdr_in); + break; + case GUESTFS_PROC_MV: + mv_stub (xdr_in); + break; + case GUESTFS_PROC_DROP_CACHES: + drop_caches_stub (xdr_in); + break; default: reply_with_error ("dispatch_incoming_message: unknown procedure number %d", proc_nr); } @@ -1543,6 +2757,7 @@ parse_command_line_pvs (void) reply_with_error ("%s", err); free (out); free (err); + free (ret); return NULL; } @@ -1882,6 +3097,7 @@ parse_command_line_vgs (void) reply_with_error ("%s", err); free (out); free (err); + free (ret); return NULL; } @@ -2191,6 +3407,7 @@ parse_command_line_lvs (void) reply_with_error ("%s", err); free (out); free (err); + free (ret); return NULL; }