Added README file for examples directory.
[libguestfs.git] / daemon / guestfsd.c
index c27d1b6..6fc8b19 100644 (file)
 #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;
@@ -198,8 +204,43 @@ xwrite (int sock, const void *buf, size_t len)
   }
 }
 
+void
+xread (int sock, void *buf, size_t len)
+{
+  int r;
+
+  while (len > 0) {
+    r = read (sock, buf, len);
+    if (r == -1) {
+      perror ("read");
+      exit (1);
+    }
+    if (r == 0) {
+      fprintf (stderr, "read: unexpected end of file on comms socket\n");
+      exit (1);
+    }
+    buf += r;
+    len -= r;
+  }
+}
+
 static void
 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;
+}