diff options
author | Richard Jones <rjones@redhat.com> | 2009-04-03 17:24:35 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-04-03 17:24:35 +0100 |
commit | 40ca9a57829f2e82362e391d7d998bf33c8bd671 (patch) | |
tree | 39990f925b9ae363af6d219a985a70adec9af016 /daemon | |
parent | cd2fd58da3f5648a62f3fb7586cdc910c09a31af (diff) | |
download | libguestfs-40ca9a57829f2e82362e391d7d998bf33c8bd671.tar.gz libguestfs-40ca9a57829f2e82362e391d7d998bf33c8bd671.tar.xz libguestfs-40ca9a57829f2e82362e391d7d998bf33c8bd671.zip |
Daemon and library are mostly talking to each other now.
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/Makefile.am | 12 | ||||
-rw-r--r-- | daemon/actions.h | 6 | ||||
-rw-r--r-- | daemon/daemon.h | 41 | ||||
-rw-r--r-- | daemon/guestfsd.c | 27 | ||||
-rw-r--r-- | daemon/proto.c | 59 | ||||
-rw-r--r-- | daemon/stubs.c | 18 | ||||
-rw-r--r-- | daemon/sync.c | 32 |
7 files changed, 186 insertions, 9 deletions
diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 6a5a4eef..cf552504 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -18,6 +18,14 @@ ACLOCAL_AMFLAGS = -I m4 noinst_PROGRAMS = guestfsd -guestfsd_SOURCES = guestfsd.c +guestfsd_SOURCES = \ + actions.h \ + daemon.h \ + guestfsd.c \ + proto.c \ + stubs.c \ + sync.c \ + ../src/guestfs_protocol.h \ + ../src/guestfs_protocol.c -guestfsd_CFLAGS = -Wall -Werror
\ No newline at end of file +guestfsd_CFLAGS = -Wall
\ No newline at end of file diff --git a/daemon/actions.h b/daemon/actions.h index c7d64df8..61b583cb 100644 --- a/daemon/actions.h +++ b/daemon/actions.h @@ -19,6 +19,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -extern int do_mount (guestfs_h *handle, const char *device, const char *mountpoint); -extern int do_sync (guestfs_h *handle); -extern int do_touch (guestfs_h *handle, const char *path); +extern int do_mount (const char *device, const char *mountpoint); +extern int do_sync (); +extern int do_touch (const char *path); diff --git a/daemon/daemon.h b/daemon/daemon.h new file mode 100644 index 00000000..b8a9001f --- /dev/null +++ b/daemon/daemon.h @@ -0,0 +1,41 @@ +/* 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef GUESTFSD_DAEMON_H +#define GUESTFSD_DAEMON_H + +#include <stdarg.h> +#include <rpc/types.h> +#include <rpc/xdr.h> + +/* in guestfsd.c */ +extern void xwrite (int sock, const void *buf, size_t len); + +/* in proto.c */ +extern int proc_nr; +extern int serial; + +/* in stubs.c (auto-generated) */ +extern void dispatch_incoming_message (XDR *); + +/* in proto.c */ +extern void main_loop (int sock); +extern void reply_with_error (const char *fs, ...); +extern void reply (xdrproc_t, XDR *); + +#endif /* GUESTFSD_DAEMON_H */ diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index c27d1b6e..eaba7f04 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -27,7 +27,10 @@ #include <getopt.h> #include <netdb.h> -static void xwrite (int sock, const void *buf, size_t len); +#include "daemon.h" + +void xwrite (int sock, const void *buf, size_t len); + static void usage (void); /* Also in guestfs.c */ @@ -177,12 +180,15 @@ main (int argc, char *argv[]) - sleep (1000000); + + + + main_loop (sock); exit (0); } -static void +void xwrite (int sock, const void *buf, size_t len) { int r; @@ -203,3 +209,18 @@ usage (void) { fprintf (stderr, "guestfsd [-f] [-h host -p port]\n"); } + +/* Some unimplemented actions. */ +int +do_mount (const char *device, const char *mountpoint) +{ + reply_with_error ("mount not implemented"); + return -1; +} + +int +do_touch (const char *path) +{ + reply_with_error ("touch not implemented"); + return -1; +} diff --git a/daemon/proto.c b/daemon/proto.c new file mode 100644 index 00000000..f045751f --- /dev/null +++ b/daemon/proto.c @@ -0,0 +1,59 @@ +/* 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 <stdarg.h> +#include <string.h> +#include <unistd.h> +#include <rpc/types.h> +#include <rpc/xdr.h> + +#include "daemon.h" + +/* The message currently being processed. */ +int proc_nr; +int serial; + +/* The daemon communications socket. */ +static int sock; + +void +main_loop (int _sock) +{ + sock = _sock; + + + + +} + +void +reply_with_error (const char *fs, ...) +{ + + + +} + +void +reply (xdrproc_t xdrp, XDR *xdr) +{ +} diff --git a/daemon/stubs.c b/daemon/stubs.c index 81c5b724..22fd5755 100644 --- a/daemon/stubs.c +++ b/daemon/stubs.c @@ -22,7 +22,7 @@ #include <rpc/types.h> #include <rpc/xdr.h> #include "daemon.h" -#include "../src/guest_protocol.h" +#include "../src/guestfs_protocol.h" #include "actions.h" static void mount_stub (XDR *xdr_in) @@ -79,3 +79,19 @@ static void touch_stub (XDR *xdr_in) reply (NULL, NULL); } +void dispatch_incoming_message (XDR *xdr_in) +{ + switch (proc_nr) { + case GUESTFS_PROC_MOUNT: + mount_stub (xdr_in); + break; + case GUESTFS_PROC_SYNC: + sync_stub (xdr_in); + break; + case GUESTFS_PROC_TOUCH: + touch_stub (xdr_in); + break; + default: + reply_with_error ("dispatch_incoming_message: unknown procedure number %d", proc_nr); + } +} diff --git a/daemon/sync.c b/daemon/sync.c new file mode 100644 index 00000000..9ade8403 --- /dev/null +++ b/daemon/sync.c @@ -0,0 +1,32 @@ +/* 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 <unistd.h> + +#include "actions.h" + +int +do_sync () +{ + sync (); + fprintf (stderr, "guestfsd: disk synched\n"); + return 0; +} |