summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-18 13:17:12 +0100
committerRichard Jones <rjones@redhat.com>2009-04-18 13:17:12 +0100
commit1765330e07a48dc6f7bdef7007f69ebe606fa731 (patch)
tree659ce188bbe1a0568fc4b58504c6de025b9b2e3d /daemon
parent92804dec7c4982d2039f81586bc4a5cacb46217b (diff)
downloadlibguestfs-1765330e07a48dc6f7bdef7007f69ebe606fa731.tar.gz
libguestfs-1765330e07a48dc6f7bdef7007f69ebe606fa731.tar.xz
libguestfs-1765330e07a48dc6f7bdef7007f69ebe606fa731.zip
Rewrite of main loop impl, start of FileIn/FileOut support.
Diffstat (limited to 'daemon')
-rw-r--r--daemon/Makefile.am1
-rw-r--r--daemon/daemon.h25
-rw-r--r--daemon/upload.c40
3 files changed, 61 insertions, 5 deletions
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 75de0663..1c1609dd 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -36,6 +36,7 @@ guestfsd_SOURCES = \
stubs.c \
sync.c \
tune2fs.c \
+ upload.c \
../src/guestfs_protocol.h \
../src/guestfs_protocol.c
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 27d86c9b..ca712657 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -30,7 +30,7 @@
#include "../src/guestfs_protocol.h"
-/* in guestfsd.c */
+/*-- in guestfsd.c --*/
extern int xwrite (int sock, const void *buf, size_t len);
extern int xread (int sock, void *buf, size_t len);
@@ -44,25 +44,37 @@ extern int command (char **stdoutput, char **stderror, const char *name, ...);
extern int commandv (char **stdoutput, char **stderror,
char * const* const argv);
-/* in proto.c */
+/*-- in proto.c --*/
extern int proc_nr;
extern int serial;
-/* in mount.c */
+/*-- in mount.c --*/
extern int root_mounted;
-/* in stubs.c (auto-generated) */
+/*-- in stubs.c (auto-generated) --*/
extern void dispatch_incoming_message (XDR *);
extern guestfs_lvm_int_pv_list *parse_command_line_pvs (void);
extern guestfs_lvm_int_vg_list *parse_command_line_vgs (void);
extern guestfs_lvm_int_lv_list *parse_command_line_lvs (void);
-/* in proto.c */
+/*-- in proto.c --*/
extern void main_loop (int sock);
+
+/* ordinary daemon functions use these to indicate errors */
extern void reply_with_error (const char *fs, ...);
extern void reply_with_perror (const char *fs, ...);
+
+/* daemon functions that return files (FileOut) should call
+ * reply, then send_file for each FileOut parameter.
+ */
+#if 0
+extern void send_file ();
+#endif
+
+/* only call this if there is a FileOut parameter */
extern void reply (xdrproc_t xdrp, char *ret);
+/* Helper for functions that need a root filesystem mounted. */
#define NEED_ROOT(errcode) \
do { \
if (!root_mounted) { \
@@ -72,6 +84,7 @@ extern void reply (xdrproc_t xdrp, char *ret);
} \
while (0)
+/* Helper for functions that need an argument ("path") that is absolute. */
#define ABS_PATH(path,errcode) \
do { \
if ((path)[0] != '/') { \
@@ -80,6 +93,7 @@ extern void reply (xdrproc_t xdrp, char *ret);
} \
} while (0)
+/* Helper for functions that need an argument ("path") that is a device. */
#define IS_DEVICE(path,errcode) \
do { \
struct stat statbuf; \
@@ -104,6 +118,7 @@ extern void reply (xdrproc_t xdrp, char *ret);
#define CHROOT_OUT \
do { int old_errno = errno; chroot ("."); errno = old_errno; } while (0)
+/* Marks functions which are not implemented. */
#define XXX_NOT_IMPL(errcode) \
do { \
reply_with_error ("%s: function not implemented", __func__); \
diff --git a/daemon/upload.c b/daemon/upload.c
new file mode 100644
index 00000000..d2feb028
--- /dev/null
+++ b/daemon/upload.c
@@ -0,0 +1,40 @@
+/* libguestfs - the guestfsd daemon
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include "../src/guestfs_protocol.h"
+#include "daemon.h"
+#include "actions.h"
+
+int
+do_upload (const char *remote_filename)
+{
+ XXX_NOT_IMPL (-1);
+}
+
+int
+do_download (const char *remote_filename)
+{
+ XXX_NOT_IMPL (-1);
+}