#include <assert.h>
#include <errno.h>
+#include <dirent.h>
#include <fcntl.h>
#include <dlfcn.h>
#include <limits.h>
return _access(p, mode);
}
+
+TS_EXPORT DIR *opendir(const char *path)
+{
+ const char *p;
+ char buf[PATH_MAX * 2];
+ static int (*_opendir)(const char *path);
+
+ if (!get_rootpath(__func__))
+ return NULL;
+
+ _opendir = get_libc_func("opendir");
+
+ p = trap_path(path, buf);
+ if (p == NULL)
+ return NULL;
+
+ return (void *)(long)(*_opendir)(p);
+}
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
+#include <dirent.h>
#include <errno.h>
#include <unistd.h>
#include <sys/stat.h>
.need_spawn = true,
};
+static int testsuite_rootfs_opendir(const struct test *t)
+{
+ DIR *d;
+
+ d = opendir("/testdir");
+ if (d == NULL) {
+ ERR("opendir failed: %m\n");
+ return EXIT_FAILURE;
+ }
+
+ closedir(d);
+ return EXIT_SUCCESS;
+}
+static const struct test stestsuite_rootfs_opendir = {
+ .name = "testsuite_rootfs_opendir",
+ .description = "test if rootfs works - opendir()",
+ .func = testsuite_rootfs_opendir,
+ .config = {
+ [TC_ROOTFS] = TESTSUITE_ROOTFS "test-rootfs/",
+ },
+ .need_spawn = true,
+};
+
static const struct test *tests[] = {
&stestsuite_uname,
&stestsuite_rootfs_fopen,
&stestsuite_rootfs_open,
&stestsuite_rootfs_stat_access,
+ &stestsuite_rootfs_opendir,
NULL,
};