Now the test checks if the kernel supports the NS_GET_NSTYPE ioctl,
but it seems that on some platforms it's implemented but does not work
as expected and returns ENOTTY.
Signed-off-by: Karel Zak <kzak@redhat.com>
#endif
#include "xalloc.h"
+#include "namespace.h"
typedef struct {
const char *name;
static int hlp_get_nstype_ok(void)
{
#ifdef USE_NS_GET_NSTYPE
+ int fd = open("/proc/self/ns/mnt", O_RDONLY);
+
errno = 0;
- ioctl(STDOUT_FILENO, NS_GET_NSTYPE);
+ if (fd >= 0) {
+ int errsv = 0;
+
+ /* Check for actual usability */
+ if (ioctl(fd, NS_GET_NSTYPE) != CLONE_NEWNS)
+ errsv = ENOSYS;
+ close(fd);
+ errno = errsv;
+ } else {
+ /* Generic check for ENOSYS only */
+ ioctl(STDOUT_FILENO, NS_GET_NSTYPE);
+ }
#else
errno = ENOSYS;
#endif