Blame SOURCES/0002-guestfs_readdir-rewrite-with-FileOut-transfer-to-lif.patch

65aaff
From b97b90779d5ea261d5e737f073bb4ec5dc546511 Mon Sep 17 00:00:00 2001
65aaff
From: Laszlo Ersek <lersek@redhat.com>
65aaff
Date: Mon, 2 May 2022 10:56:00 +0200
65aaff
Subject: [PATCH] guestfs_readdir(): rewrite with FileOut transfer, to lift
65aaff
 protocol limit
65aaff
65aaff
Currently the guestfs_readdir() API can not list long directories, due to
65aaff
it sending back the whole directory listing in a single guestfs protocol
65aaff
response, which is limited to GUESTFS_MESSAGE_MAX (approx. 4MB) in size.
65aaff
65aaff
Introduce the "internal_readdir" action, for transferring the directory
65aaff
listing from the daemon to the library through a FileOut parameter.
65aaff
Rewrite guestfs_readdir() on top of this new internal function:
65aaff
65aaff
- The new "internal_readdir" action is a daemon action. Do not repurpose
65aaff
  the "readdir" proc_nr (138) for "internal_readdir", as some distros ship
65aaff
  the binary appliance to their users, and reusing the proc_nr could
65aaff
  create a mismatch between library & appliance with obscure symptoms.
65aaff
  Replace the old proc_nr (138) with a new proc_nr (511) instead; a
65aaff
  mismatch would then produce a clear error message. Assume the new action
65aaff
  will first be released in libguestfs-1.48.2.
65aaff
65aaff
- Turn "readdir" from a daemon action into a non-daemon one. Call the
65aaff
  daemon action guestfs_internal_readdir() manually, receive the FileOut
65aaff
  parameter into a temp file, then deserialize the dirents array from the
65aaff
  temp file.
65aaff
65aaff
This patch sneakily fixes an independent bug, too. In the pre-patch
65aaff
do_readdir() function [daemon/readdir.c], when readdir() returns NULL, we
65aaff
don't distinguish "end of directory stream" from "readdir() failed". This
65aaff
rewrite fixes this problem -- I didn't see much value separating out the
65aaff
fix for the original do_readdir().
65aaff
65aaff
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1674392
65aaff
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
65aaff
Message-Id: <20220502085601.15012-2-lersek@redhat.com>
65aaff
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
65aaff
(cherry picked from commit 45b7f1736b64e9f0741e21e5a9d83a837bd863bf)
65aaff
---
65aaff
 TODO                      |   8 ---
65aaff
 daemon/readdir.c          | 132 +++++++++++++++++++-------------------
65aaff
 generator/actions_core.ml | 127 +++++++++++++++++++-----------------
65aaff
 generator/proc_nr.ml      |   2 +-
65aaff
 lib/MAX_PROC_NR           |   2 +-
65aaff
 lib/Makefile.am           |   1 +
65aaff
 lib/readdir.c             | 131 +++++++++++++++++++++++++++++++++++++
65aaff
 7 files changed, 267 insertions(+), 136 deletions(-)
65aaff
 create mode 100644 lib/readdir.c
65aaff
65aaff
diff --git a/TODO b/TODO
65aaff
index a50f7d73c..513e55f92 100644
65aaff
--- a/TODO
65aaff
+++ b/TODO
65aaff
@@ -484,14 +484,6 @@ this approach works, it doesn't solve the MBR problem, so likely we'd
65aaff
 have to write a library for that (or perhaps go back to sfdisk but
65aaff
 using a very abstracted interface over sfdisk).
65aaff
 
65aaff
-Reimplement some APIs to avoid protocol limits
65aaff
-----------------------------------------------
65aaff
-
65aaff
-Mostly this item was done (eg. commits a69f44f56f and before).  The
65aaff
-most notable API with a protocol limit remaining is:
65aaff
-
65aaff
- - guestfs_readdir
65aaff
-
65aaff
 hivex
65aaff
 -----
65aaff
 
65aaff
diff --git a/daemon/readdir.c b/daemon/readdir.c
65aaff
index e488f93e7..9ab0b0aec 100644
65aaff
--- a/daemon/readdir.c
65aaff
+++ b/daemon/readdir.c
65aaff
@@ -16,77 +16,67 @@
65aaff
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
65aaff
  */
65aaff
 
65aaff
-#include <config.h>
65aaff
+#include <config.h> /* HAVE_STRUCT_DIRENT_D_TYPE */
65aaff
 
65aaff
-#include <stdio.h>
65aaff
-#include <stdlib.h>
65aaff
-#include <string.h>
65aaff
-#include <unistd.h>
65aaff
-#include <dirent.h>
65aaff
+#include <dirent.h>    /* readdir() */
65aaff
+#include <errno.h>     /* errno */
65aaff
+#include <rpc/xdr.h>   /* xdrmem_create() */
65aaff
+#include <stdio.h>     /* perror() */
65aaff
+#include <stdlib.h>    /* malloc() */
65aaff
+#include <sys/types.h> /* opendir() */
65aaff
 
65aaff
-#include "daemon.h"
65aaff
-#include "actions.h"
65aaff
+#include "daemon.h" /* reply_with_perror() */
65aaff
 
65aaff
-static void
65aaff
-free_int_dirent_list (guestfs_int_dirent *p, size_t len)
65aaff
+/* Has one FileOut parameter. */
65aaff
+int
65aaff
+do_internal_readdir (const char *dir)
65aaff
 {
65aaff
-  size_t i;
65aaff
+  int ret;
65aaff
+  DIR *dirstream;
65aaff
+  void *xdr_buf;
65aaff
+  XDR xdr;
65aaff
 
65aaff
-  for (i = 0; i < len; ++i) {
65aaff
-    free (p[i].name);
65aaff
-  }
65aaff
-  free (p);
65aaff
-}
65aaff
-
65aaff
-guestfs_int_dirent_list *
65aaff
-do_readdir (const char *path)
65aaff
-{
65aaff
-  guestfs_int_dirent_list *ret;
65aaff
-  guestfs_int_dirent v;
65aaff
-  DIR *dir;
65aaff
-  struct dirent *d;
65aaff
-  size_t i;
65aaff
-
65aaff
-  ret = malloc (sizeof *ret);
65aaff
-  if (ret == NULL) {
65aaff
-    reply_with_perror ("malloc");
65aaff
-    return NULL;
65aaff
-  }
65aaff
-
65aaff
-  ret->guestfs_int_dirent_list_len = 0;
65aaff
-  ret->guestfs_int_dirent_list_val = NULL;
65aaff
+  /* Prepare to fail. */
65aaff
+  ret = -1;
65aaff
 
65aaff
   CHROOT_IN;
65aaff
-  dir = opendir (path);
65aaff
+  dirstream = opendir (dir);
65aaff
   CHROOT_OUT;
65aaff
 
65aaff
-  if (dir == NULL) {
65aaff
-    reply_with_perror ("opendir: %s", path);
65aaff
-    free (ret);
65aaff
-    return NULL;
65aaff
+  if (dirstream == NULL) {
65aaff
+    reply_with_perror ("opendir: %s", dir);
65aaff
+    return ret;
65aaff
   }
65aaff
 
65aaff
-  i = 0;
65aaff
-  while ((d = readdir (dir)) != NULL) {
65aaff
-    guestfs_int_dirent *p;
65aaff
+  xdr_buf = malloc (GUESTFS_MAX_CHUNK_SIZE);
65aaff
+  if (xdr_buf == NULL) {
65aaff
+    reply_with_perror ("malloc");
65aaff
+    goto close_dir;
65aaff
+  }
65aaff
+  xdrmem_create (&xdr, xdr_buf, GUESTFS_MAX_CHUNK_SIZE, XDR_ENCODE);
65aaff
+
65aaff
+  /* Send an "OK" reply, before starting the file transfer. */
65aaff
+  reply (NULL, NULL);
65aaff
+
65aaff
+  /* From this point on, we can only report errors by canceling the file
65aaff
+   * transfer.
65aaff
+   */
65aaff
+  for (;;) {
65aaff
+    struct dirent *d;
65aaff
+    guestfs_int_dirent v;
65aaff
+
65aaff
+    errno = 0;
65aaff
+    d = readdir (dirstream);
65aaff
+    if (d == NULL) {
65aaff
+      if (errno == 0)
65aaff
+        ret = 0;
65aaff
+      else
65aaff
+        perror ("readdir");
65aaff
 
65aaff
-    p = realloc (ret->guestfs_int_dirent_list_val,
65aaff
-                 sizeof (guestfs_int_dirent) * (i+1));
65aaff
-    v.name = strdup (d->d_name);
65aaff
-    if (!p || !v.name) {
65aaff
-      reply_with_perror ("allocate");
65aaff
-      if (p) {
65aaff
-        free_int_dirent_list (p, i);
65aaff
-      } else {
65aaff
-        free_int_dirent_list (ret->guestfs_int_dirent_list_val, i);
65aaff
-      }
65aaff
-      free (v.name);
65aaff
-      free (ret);
65aaff
-      closedir (dir);
65aaff
-      return NULL;
65aaff
+      break;
65aaff
     }
65aaff
-    ret->guestfs_int_dirent_list_val = p;
65aaff
 
65aaff
+    v.name = d->d_name;
65aaff
     v.ino = d->d_ino;
65aaff
 #ifdef HAVE_STRUCT_DIRENT_D_TYPE
65aaff
     switch (d->d_type) {
65aaff
@@ -104,19 +94,29 @@ do_readdir (const char *path)
65aaff
     v.ftyp = 'u';
65aaff
 #endif
65aaff
 
65aaff
-    ret->guestfs_int_dirent_list_val[i] = v;
65aaff
+    if (!xdr_guestfs_int_dirent (&xdr, &v)) {
65aaff
+      fprintf (stderr, "xdr_guestfs_int_dirent failed\n");
65aaff
+      break;
65aaff
+    }
65aaff
 
65aaff
-    i++;
65aaff
+    if (send_file_write (xdr_buf, xdr_getpos (&xdr)) != 0)
65aaff
+      break;
65aaff
+
65aaff
+    xdr_setpos (&xdr, 0);
65aaff
   }
65aaff
 
65aaff
-  ret->guestfs_int_dirent_list_len = i;
65aaff
+  /* Finish or cancel the transfer. Note that if (ret == -1) because the library
65aaff
+   * canceled, we still need to cancel back!
65aaff
+   */
65aaff
+  send_file_end (ret == -1);
65aaff
 
65aaff
-  if (closedir (dir) == -1) {
65aaff
-    reply_with_perror ("closedir");
65aaff
-    free (ret->guestfs_int_dirent_list_val);
65aaff
-    free (ret);
65aaff
-    return NULL;
65aaff
-  }
65aaff
+  xdr_destroy (&xdr;;
65aaff
+  free (xdr_buf);
65aaff
+
65aaff
+close_dir:
65aaff
+  if (closedir (dirstream) == -1)
65aaff
+    /* Best we can do here is log an error. */
65aaff
+    perror ("closedir");
65aaff
 
65aaff
   return ret;
65aaff
 }
65aaff
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
65aaff
index dc12fdc33..807150615 100644
65aaff
--- a/generator/actions_core.ml
65aaff
+++ b/generator/actions_core.ml
65aaff
@@ -141,6 +141,66 @@ only useful for printing debug and internal error messages.
65aaff
 
65aaff
 For more information on states, see L<guestfs(3)>." };
65aaff
 
65aaff
+  { defaults with
65aaff
+    name = "readdir"; added = (1, 0, 55);
65aaff
+    style = RStructList ("entries", "dirent"), [String (Pathname, "dir")], [];
65aaff
+    progress = true; cancellable = true;
65aaff
+    shortdesc = "read directories entries";
65aaff
+    longdesc = "\
65aaff
+This returns the list of directory entries in directory C<dir>.
65aaff
+
65aaff
+All entries in the directory are returned, including C<.> and
65aaff
+C<..>.  The entries are I<not> sorted, but returned in the same
65aaff
+order as the underlying filesystem.
65aaff
+
65aaff
+Also this call returns basic file type information about each
65aaff
+file.  The C<ftyp> field will contain one of the following characters:
65aaff
+
65aaff
+=over 4
65aaff
+
65aaff
+=item 'b'
65aaff
+
65aaff
+Block special
65aaff
+
65aaff
+=item 'c'
65aaff
+
65aaff
+Char special
65aaff
+
65aaff
+=item 'd'
65aaff
+
65aaff
+Directory
65aaff
+
65aaff
+=item 'f'
65aaff
+
65aaff
+FIFO (named pipe)
65aaff
+
65aaff
+=item 'l'
65aaff
+
65aaff
+Symbolic link
65aaff
+
65aaff
+=item 'r'
65aaff
+
65aaff
+Regular file
65aaff
+
65aaff
+=item 's'
65aaff
+
65aaff
+Socket
65aaff
+
65aaff
+=item 'u'
65aaff
+
65aaff
+Unknown file type
65aaff
+
65aaff
+=item '?'
65aaff
+
65aaff
+The L<readdir(3)> call returned a C<d_type> field with an
65aaff
+unexpected value
65aaff
+
65aaff
+=back
65aaff
+
65aaff
+This function is primarily intended for use by programs.  To
65aaff
+get a simple list of names, use C<guestfs_ls>.  To get a printable
65aaff
+directory for human consumption, use C<guestfs_ll>." };
65aaff
+
65aaff
   { defaults with
65aaff
     name = "version"; added = (1, 0, 58);
65aaff
     style = RStruct ("version", "version"), [], [];
65aaff
@@ -3939,66 +3999,6 @@ L<umask(2)>, C<guestfs_mknod>, C<guestfs_mkdir>.
65aaff
 
65aaff
 This call returns the previous umask." };
65aaff
 
65aaff
-  { defaults with
65aaff
-    name = "readdir"; added = (1, 0, 55);
65aaff
-    style = RStructList ("entries", "dirent"), [String (Pathname, "dir")], [];
65aaff
-    protocol_limit_warning = true;
65aaff
-    shortdesc = "read directories entries";
65aaff
-    longdesc = "\
65aaff
-This returns the list of directory entries in directory C<dir>.
65aaff
-
65aaff
-All entries in the directory are returned, including C<.> and
65aaff
-C<..>.  The entries are I<not> sorted, but returned in the same
65aaff
-order as the underlying filesystem.
65aaff
-
65aaff
-Also this call returns basic file type information about each
65aaff
-file.  The C<ftyp> field will contain one of the following characters:
65aaff
-
65aaff
-=over 4
65aaff
-
65aaff
-=item 'b'
65aaff
-
65aaff
-Block special
65aaff
-
65aaff
-=item 'c'
65aaff
-
65aaff
-Char special
65aaff
-
65aaff
-=item 'd'
65aaff
-
65aaff
-Directory
65aaff
-
65aaff
-=item 'f'
65aaff
-
65aaff
-FIFO (named pipe)
65aaff
-
65aaff
-=item 'l'
65aaff
-
65aaff
-Symbolic link
65aaff
-
65aaff
-=item 'r'
65aaff
-
65aaff
-Regular file
65aaff
-
65aaff
-=item 's'
65aaff
-
65aaff
-Socket
65aaff
-
65aaff
-=item 'u'
65aaff
-
65aaff
-Unknown file type
65aaff
-
65aaff
-=item '?'
65aaff
-
65aaff
-The L<readdir(3)> call returned a C<d_type> field with an
65aaff
-unexpected value
65aaff
-
65aaff
-=back
65aaff
-
65aaff
-This function is primarily intended for use by programs.  To
65aaff
-get a simple list of names, use C<guestfs_ls>.  To get a printable
65aaff
-directory for human consumption, use C<guestfs_ll>." };
65aaff
-
65aaff
   { defaults with
65aaff
     name = "getxattrs"; added = (1, 0, 59);
65aaff
     style = RStructList ("xattrs", "xattr"), [String (Pathname, "path")], [];
65aaff
@@ -9713,4 +9713,11 @@ C<guestfs_cryptsetup_open>.  The C<device> parameter must be
65aaff
 the name of the mapping device (ie. F</dev/mapper/mapname>)
65aaff
 and I<not> the name of the underlying block device." };
65aaff
 
65aaff
+  { defaults with
65aaff
+    name = "internal_readdir"; added = (1, 48, 2);
65aaff
+    style = RErr, [String (Pathname, "dir"); String (FileOut, "filename")], [];
65aaff
+    visibility = VInternal;
65aaff
+    shortdesc = "read directories entries";
65aaff
+    longdesc = "Internal function for readdir." };
65aaff
+
65aaff
 ]
65aaff
diff --git a/generator/proc_nr.ml b/generator/proc_nr.ml
65aaff
index b20672ff0..bdced51c9 100644
65aaff
--- a/generator/proc_nr.ml
65aaff
+++ b/generator/proc_nr.ml
65aaff
@@ -152,7 +152,6 @@ let proc_nr = [
65aaff
 135, "mknod_b";
65aaff
 136, "mknod_c";
65aaff
 137, "umask";
65aaff
-138, "readdir";
65aaff
 139, "sfdiskM";
65aaff
 140, "zfile";
65aaff
 141, "getxattrs";
65aaff
@@ -514,6 +513,7 @@ let proc_nr = [
65aaff
 508, "cryptsetup_open";
65aaff
 509, "cryptsetup_close";
65aaff
 510, "internal_list_rpm_applications";
65aaff
+511, "internal_readdir";
65aaff
 ]
65aaff
 
65aaff
 (* End of list.  If adding a new entry, add it at the end of the list
65aaff
diff --git a/lib/MAX_PROC_NR b/lib/MAX_PROC_NR
65aaff
index 2bc4cd64b..c0556fb20 100644
65aaff
--- a/lib/MAX_PROC_NR
65aaff
+++ b/lib/MAX_PROC_NR
65aaff
@@ -1 +1 @@
65aaff
-510
65aaff
+511
65aaff
diff --git a/lib/Makefile.am b/lib/Makefile.am
65aaff
index 144c45588..212bcb94a 100644
65aaff
--- a/lib/Makefile.am
65aaff
+++ b/lib/Makefile.am
65aaff
@@ -105,6 +105,7 @@ libguestfs_la_SOURCES = \
65aaff
 	private-data.c \
65aaff
 	proto.c \
65aaff
 	qemu.c \
65aaff
+	readdir.c \
65aaff
 	rescue.c \
65aaff
 	stringsbuf.c \
65aaff
 	structs-compare.c \
65aaff
diff --git a/lib/readdir.c b/lib/readdir.c
65aaff
new file mode 100644
65aaff
index 000000000..9cb0d7cf6
65aaff
--- /dev/null
65aaff
+++ b/lib/readdir.c
65aaff
@@ -0,0 +1,131 @@
65aaff
+/* libguestfs
65aaff
+ * Copyright (C) 2016-2022 Red Hat Inc.
65aaff
+ *
65aaff
+ * This library is free software; you can redistribute it and/or
65aaff
+ * modify it under the terms of the GNU Lesser General Public
65aaff
+ * License as published by the Free Software Foundation; either
65aaff
+ * version 2 of the License, or (at your option) any later version.
65aaff
+ *
65aaff
+ * This library is distributed in the hope that it will be useful,
65aaff
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
65aaff
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
65aaff
+ * Lesser General Public License for more details.
65aaff
+ *
65aaff
+ * You should have received a copy of the GNU Lesser General Public
65aaff
+ * License along with this library; if not, write to the Free Software
65aaff
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
65aaff
+ */
65aaff
+
65aaff
+#include <config.h> /* UNIX_PATH_MAX, needed by "guestfs-internal.h" */
65aaff
+
65aaff
+#include <rpc/xdr.h> /* xdrstdio_create() */
65aaff
+#include <stdint.h>  /* UINT32_MAX */
65aaff
+#include <stdio.h>   /* fopen() */
65aaff
+#include <string.h>  /* memset() */
65aaff
+
65aaff
+#include "guestfs.h"                  /* guestfs_internal_readdir() */
65aaff
+#include "guestfs_protocol.h"         /* guestfs_int_dirent */
65aaff
+#include "guestfs-internal.h"         /* guestfs_int_make_temp_path() */
65aaff
+#include "guestfs-internal-actions.h" /* guestfs_impl_readdir */
65aaff
+
65aaff
+struct guestfs_dirent_list *
65aaff
+guestfs_impl_readdir (guestfs_h *g, const char *dir)
65aaff
+{
65aaff
+  struct guestfs_dirent_list *ret;
65aaff
+  char *tmpfn;
65aaff
+  FILE *f;
65aaff
+  off_t fsize;
65aaff
+  XDR xdr;
65aaff
+  struct guestfs_dirent_list *dirents;
65aaff
+  uint32_t alloc_entries;
65aaff
+  size_t alloc_bytes;
65aaff
+
65aaff
+  /* Prepare to fail. */
65aaff
+  ret = NULL;
65aaff
+
65aaff
+  tmpfn = guestfs_int_make_temp_path (g, "readdir", NULL);
65aaff
+  if (tmpfn == NULL)
65aaff
+    return ret;
65aaff
+
65aaff
+  if (guestfs_internal_readdir (g, dir, tmpfn) == -1)
65aaff
+    goto drop_tmpfile;
65aaff
+
65aaff
+  f = fopen (tmpfn, "r");
65aaff
+  if (f == NULL) {
65aaff
+    perrorf (g, "fopen: %s", tmpfn);
65aaff
+    goto drop_tmpfile;
65aaff
+  }
65aaff
+
65aaff
+  if (fseeko (f, 0, SEEK_END) == -1) {
65aaff
+    perrorf (g, "fseeko");
65aaff
+    goto close_tmpfile;
65aaff
+  }
65aaff
+  fsize = ftello (f);
65aaff
+  if (fsize == -1) {
65aaff
+    perrorf (g, "ftello");
65aaff
+    goto close_tmpfile;
65aaff
+  }
65aaff
+  if (fseeko (f, 0, SEEK_SET) == -1) {
65aaff
+    perrorf (g, "fseeko");
65aaff
+    goto close_tmpfile;
65aaff
+  }
65aaff
+
65aaff
+  xdrstdio_create (&xdr, f, XDR_DECODE);
65aaff
+
65aaff
+  dirents = safe_malloc (g, sizeof *dirents);
65aaff
+  dirents->len = 0;
65aaff
+  alloc_entries = 8;
65aaff
+  alloc_bytes = alloc_entries * sizeof *dirents->val;
65aaff
+  dirents->val = safe_malloc (g, alloc_bytes);
65aaff
+
65aaff
+  while (xdr_getpos (&xdr) < fsize) {
65aaff
+    guestfs_int_dirent v;
65aaff
+    struct guestfs_dirent *d;
65aaff
+
65aaff
+    if (dirents->len == alloc_entries) {
65aaff
+      if (alloc_entries > UINT32_MAX / 2 || alloc_bytes > (size_t)-1 / 2) {
65aaff
+        error (g, "integer overflow");
65aaff
+        goto free_dirents;
65aaff
+      }
65aaff
+      alloc_entries *= 2u;
65aaff
+      alloc_bytes *= 2u;
65aaff
+      dirents->val = safe_realloc (g, dirents->val, alloc_bytes);
65aaff
+    }
65aaff
+
65aaff
+    /* Decoding does not work unless the target buffer is zero-initialized. */
65aaff
+    memset (&v, 0, sizeof v);
65aaff
+    if (!xdr_guestfs_int_dirent (&xdr, &v)) {
65aaff
+      error (g, "xdr_guestfs_int_dirent failed");
65aaff
+      goto free_dirents;
65aaff
+    }
65aaff
+
65aaff
+    d = &dirents->val[dirents->len];
65aaff
+    d->ino = v.ino;
65aaff
+    d->ftyp = v.ftyp;
65aaff
+    d->name = v.name; /* transfer malloc'd string to "d" */
65aaff
+
65aaff
+    dirents->len++;
65aaff
+  }
65aaff
+
65aaff
+  /* Success; transfer "dirents" to "ret". */
65aaff
+  ret = dirents;
65aaff
+  dirents = NULL;
65aaff
+
65aaff
+  /* Clean up. */
65aaff
+  xdr_destroy (&xdr;;
65aaff
+
65aaff
+free_dirents:
65aaff
+  guestfs_free_dirent_list (dirents);
65aaff
+
65aaff
+close_tmpfile:
65aaff
+  fclose (f);
65aaff
+
65aaff
+drop_tmpfile:
65aaff
+  /* In case guestfs_internal_readdir() failed, it may or may not have created
65aaff
+   * the temporary file.
65aaff
+   */
65aaff
+  unlink (tmpfn);
65aaff
+  free (tmpfn);
65aaff
+
65aaff
+  return ret;
65aaff
+}
65aaff
-- 
65aaff
2.31.1
65aaff