[PATCH] daemon/Win32: use gnulib modules connect, socket and symlinkat (for readlinkat).
We should try to replace readlinkat with {a,x}readlinkat, but I'll leave that to a future change. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
This now calls WSAStartup via the Gnulib gl_sockets_startup function. (Thanks Dan Berrange and Jim Meyering). Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
Richard W.M. Jones wrote:
This now calls WSAStartup via the Gnulib gl_sockets_startup function. ... Subject: [PATCH] daemon/Win32: use gnulib modules connect, socket and symlinkat (for readlinkat).
--- daemon/.gitignore | 1 + daemon/Makefile.am | 9 ++++++++- daemon/guestfsd.c | 26 ++++++++++++++++++++++++++ daemon/m4/gnulib-cache.m4 | 5 ++++-
+#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 +137,11 @@ main (int argc, char *argv[]) char *cmdline; char *vmchannel = NULL;
+ if (winsock_init () == -1) { + fprintf (stderr, "winsock initialization failed\n");
It would be nice to include strerror info. (as long as you're using gnulib's error module, might as well use it; added advantage: this diagnostic is now inconsistent with all others in that it prints the customary "program_name: " prefix) error (0, 0, "winsock initialization failed");
On Thu, Nov 26, 2009 at 02:57:04PM +0100, Jim Meyering wrote:
Richard W.M. Jones wrote:
+ if (winsock_init () == -1) { + fprintf (stderr, "winsock initialization failed\n");
It would be nice to include strerror info. (as long as you're using gnulib's error module, might as well use it; added advantage: this diagnostic is now inconsistent with all others in that it prints the customary "program_name: " prefix)
error (0, 0, "winsock initialization failed");
OK, I'll make this change when I push it. Actually, first parameter will be EXIT_FAILURE ... Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
Richard W.M. Jones wrote:
On Thu, Nov 26, 2009 at 02:57:04PM +0100, Jim Meyering wrote:
Richard W.M. Jones wrote:
+ if (winsock_init () == -1) { + fprintf (stderr, "winsock initialization failed\n");
It would be nice to include strerror info. (as long as you're using gnulib's error module, might as well use it; added advantage: this diagnostic is now inconsistent with all others in that it prints the customary "program_name: " prefix)
error (0, 0, "winsock initialization failed");
OK, I'll make this change when I push it.
Actually, first parameter will be EXIT_FAILURE ...
Sounds good. I would have suggested that, but kept with the existing code's style of returning -1 rather than looking at the caller.
participants (2)
-
Jim Meyering -
Richard W.M. Jones