Re: [Libguestfs] [PATCH nbdkit 1/4] common: Move get_current_dir_name(3) compatibility function.

Eric Blake
2018-10-30T13:37:31Z

On 10/28/18 5:13 AM, Richard W.M. Jones wrote:
> So that it can be used in plugins.
> ---
>   common/include/Makefile.am            |  1 +
>   common/include/get-current-dir-name.h | 62 +++++++++++++++++++++++++++
>   src/Makefile.am                       |  4 +-
>   src/utils.c                           | 14 +-----
>   4 files changed, 68 insertions(+), 13 deletions(-)
>

> +static inline char *
> +get_current_dir_name (void)
> +{
> +  char *ret;
> +
> +  ret = malloc (PATH_MAX);

Doesn't work on GNU Hurd, which intentionally doesn't define PATH_MAX
(on the grounds that it would be an arbitrary limit), but...

> +++ b/src/utils.c
> @@ -44,20 +44,10 @@
>   #include <termios.h>
>   #include <errno.h>
>
> +#include "get-current-dir-name.h"
> +
>   #include "internal.h"
>
> -#ifndef HAVE_GET_CURRENT_DIR_NAME
> -static char *
> -get_current_dir_name (void)
> -{
> -  char *ret = malloc (PATH_MAX);
> -
> -  ret = getcwd (ret, PATH_MAX);

...not really a problem, since no one has ported nbdkit to GNU Hurd in
the first place.

LGTM


--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org