summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-11-26 11:52:28 +0000
committerRichard Jones <rjones@redhat.com>2009-11-26 14:11:43 +0000
commit15ebf328911fb6376376889c99029bcf2dbe0033 (patch)
treefc99bef5ec098a25095607d4b2e8ffe33591cfc3 /daemon
parentfd84feb8229f792e22e3cbfa9bf7e8156947eb2f (diff)
downloadlibguestfs-15ebf328911fb6376376889c99029bcf2dbe0033.tar.gz
libguestfs-15ebf328911fb6376376889c99029bcf2dbe0033.tar.xz
libguestfs-15ebf328911fb6376376889c99029bcf2dbe0033.zip
daemon/Win32: use gnulib modules connect, socket and symlinkat (for readlinkat).
Diffstat (limited to 'daemon')
-rw-r--r--daemon/.gitignore1
-rw-r--r--daemon/Makefile.am9
-rw-r--r--daemon/guestfsd.c25
-rw-r--r--daemon/m4/gnulib-cache.m45
4 files changed, 38 insertions, 2 deletions
diff --git a/daemon/.gitignore b/daemon/.gitignore
index 0d9dac70..df14433d 100644
--- a/daemon/.gitignore
+++ b/daemon/.gitignore
@@ -123,6 +123,7 @@ m4/string_h.m4
m4/strndup.m4
m4/strnlen.m4
m4/symlink.m4
+m4/symlinkat.m4
m4/sys_ioctl_h.m4
m4/sys_select_h.m4
m4/sys_socket_h.m4
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 2f434487..04d50eb7 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -131,7 +131,14 @@ guestfsd_SOURCES = \
zerofree.c
guestfsd_LDADD = \
libprotocol.a \
- lib/libgnu.a $(LIB_CLOCK_GETTIME)
+ lib/libgnu.a \
+ $(GETADDRINFO_LIB) \
+ $(HOSTENT_LIB) \
+ $(INET_NTOP_LIB) \
+ $(LIBSOCKET) \
+ $(LIB_CLOCK_GETTIME) \
+ $(LIBINTL) \
+ $(SERVENT_LIB)
AM_CPPFLAGS = -I$(srcdir)/lib -Ilib
guestfsd_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index acb44f99..8d0154a3 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -39,13 +39,17 @@
#include <netdb.h>
#include <sys/select.h>
#include <sys/wait.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
#ifdef HAVE_PRINTF_H
# include <printf.h>
#endif
+#include "sockets.h"
#include "c-ctype.h"
#include "ignore-value.h"
+#include "error.h"
#include "daemon.h"
@@ -89,6 +93,24 @@ daemon (int nochdir, int noclose)
}
#endif /* WIN32 */
+#ifdef WIN32
+static int
+winsock_init (void)
+{
+ int r;
+
+ /* http://msdn2.microsoft.com/en-us/library/ms742213.aspx */
+ r = gl_sockets_startup (SOCKETS_2_2);
+ return r == 0 ? 0 : -1;
+}
+#else /* !WIN32 */
+static int
+winsock_init (void)
+{
+ return 0;
+}
+#endif /* !WIN32 */
+
/* Location to mount root device. */
const char *sysroot = "/sysroot"; /* No trailing slash. */
int sysroot_len = 8;
@@ -116,6 +138,9 @@ main (int argc, char *argv[])
char *cmdline;
char *vmchannel = NULL;
+ if (winsock_init () == -1)
+ error (EXIT_FAILURE, 0, "winsock initialization failed");
+
#ifdef HAVE_REGISTER_PRINTF_SPECIFIER
/* http://udrepper.livejournal.com/20948.html */
register_printf_specifier ('Q', print_shell_quote, print_arginfo);
diff --git a/daemon/m4/gnulib-cache.m4 b/daemon/m4/gnulib-cache.m4
index e8b9edf1..1e0fd175 100644
--- a/daemon/m4/gnulib-cache.m4
+++ b/daemon/m4/gnulib-cache.m4
@@ -15,13 +15,14 @@
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=gl byteswap c-ctype fsusage futimens getaddrinfo getline glob hash ignore-value manywarnings mkdtemp netdb openat perror pread readlink select sleep strchrnul strndup sys_select sys_wait vasprintf warnings
+# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=gl byteswap c-ctype connect fsusage futimens getaddrinfo getline glob hash ignore-value manywarnings mkdtemp netdb openat perror pread readlink select sleep socket strchrnul strndup symlinkat sys_select sys_wait vasprintf warnings
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
gl_MODULES([
byteswap
c-ctype
+ connect
fsusage
futimens
getaddrinfo
@@ -38,8 +39,10 @@ gl_MODULES([
readlink
select
sleep
+ socket
strchrnul
strndup
+ symlinkat
sys_select
sys_wait
vasprintf