+2025-11-02 Collin Funk <collin.funk1@gmail.com>
+
+ fts tests: Add a test for FTS_MOUNT.
+ * modules/fts-tests (Files): Add tests/macros.h.
+ * tests/test-fts.c: Include macros.h.
+ (test_fts_mount): New function.
+ (main): Call test_fts_mount.
+
2025-11-02 Lukáš Zaoral <lzaoral@redhat.com>
fts: Introduce the FTS_MOUNT flag.
#include <sys/stat.h>
#include <unistd.h>
+#include "macros.h"
+
#define BASE "t-fts.tmp"
static char base[] = BASE; /* Not const, since argv needs non-const. */
static char const base_d[] = BASE "/d";
perror_exit (base, 3);
}
+static void
+test_fts_mount (void)
+{
+ FTSENT *ent;
+ char *const root[] = { "/", NULL };
+ FTS *ftsp = fts_open (root, FTS_PHYSICAL | FTS_MOUNT | FTS_CWDFD, NULL);
+ dev_t root_dev;
+
+ ASSERT (ftsp != NULL);
+
+ /* Make sure each directory directly below the root directory has the same
+ device ID when we use FTS_MOUNT. */
+ while ((ent = fts_read (ftsp)))
+ {
+ switch (ent->fts_info)
+ {
+ case FTS_D:
+ if (ent->fts_level == FTS_ROOTLEVEL)
+ root_dev = ent->fts_statp->st_dev;
+ else
+ {
+ ASSERT (ent->fts_statp->st_dev == root_dev);
+ ASSERT (fts_set (ftsp, ent, FTS_SKIP) == 0);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ ASSERT (fts_close (ftsp) == 0);
+}
+
int
main (void)
{
fts_dealloc ();
+ test_fts_mount ();
+
return 0;
}