#include "mount-api-utils.h"
+#ifdef HAVE_LINUX_NSFS_H
+# include <linux/nsfs.h>
+# if defined(NS_GET_NSTYPE) && defined(NS_GET_OWNER_UID)
+# define USE_NS_GET_API 1
+# endif
+#endif
+
typedef struct {
const char *name;
int (*fnc)(void);
return 0;
}
+static int hlp_get_nstype_ok(void)
+{
+#ifdef USE_NS_GET_API
+ errno = 0;
+ ioctl(STDOUT_FILENO, NS_GET_NSTYPE);
+#else
+ errno = ENOSYS;
+#endif
+ printf("%d\n", errno != ENOSYS);
+ return 0;
+}
+
static const mntHlpfnc hlps[] =
{
{ "WORDSIZE", hlp_wordsize },
{ "enotty-ok", hlp_enotty_ok },
{ "fsopen-ok", hlp_fsopen_ok },
{ "sz(time_t)", hlp_sz_time },
+ { "ns-gettype-ok", hlp_get_nstype_ok },
{ NULL, NULL }
};
exit(re ? EXIT_FAILURE : EXIT_SUCCESS);
}
-
ts_check_test_command "$TS_CMD_LSNS"
ts_check_test_command "$TS_CMD_LSFD"
ts_check_test_command "$TS_HELPER_MKFDS"
+ts_check_test_command "$TS_HELPER_SYSINFO"
ts_check_prog "ip"
ts_skip_nonroot
+if [ "$($TS_HELPER_SYSINFO ns-gettype-ok)" == "0" ]; then
+ ts_skip "NS_GET_NSTYPE ioctl cmd not available"
+fi
+
FD=4
NS=LSNS-TEST-FILEDESC-NS
FILE=/run/netns/$NS