[Libguestfs] [PATCH VERSION 2] daemon/Win32: use gnulib modules connect, socket and symlinkat (for readlinkat).

Jim Meyering jim at meyering.net
Thu Nov 26 13:57:04 UTC 2009


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");




More information about the Libguestfs mailing list