static int columns[ARRAY_SIZE(infos) * 2];
static size_t ncolumns;
-enum {
- LSNS_TYPE_MNT = 0,
+enum lsns_type {
+ LSNS_TYPE_UNKNOWN = -1,
+ LSNS_TYPE_MNT,
LSNS_TYPE_NET,
LSNS_TYPE_PID,
LSNS_TYPE_UTS,
};
static char *ns_names[] = {
+ /* Don't add LSNS_TYPE_UNKNOWN here.
+ * ARRAY_SIZE(ns_names) in struct lsns_process may not work.*/
[LSNS_TYPE_MNT] = "mnt",
[LSNS_TYPE_NET] = "net",
[LSNS_TYPE_PID] = "pid",
struct lsns_namespace {
ino_t id;
- int type; /* LSNS_* */
+ enum lsns_type type;
int nprocs;
int netnsid;
ino_t related_id[MAX_RELA];
__UL_INIT_DEBUG_FROM_ENV(lsns, LSNS_DEBUG_, 0, LSNS_DEBUG);
}
-static int ns_name2type(const char *name)
+static enum lsns_type ns_name2type(const char *name)
{
size_t i;
if (strcmp(ns_names[i], name) == 0)
return i;
}
- return -1;
+ return LSNS_TYPE_UNKNOWN;
}
static int column_name_to_id(const char *name, size_t namesz)
return 0;
}
-static struct lsns_namespace *add_namespace(struct lsns *ls, int type, ino_t ino,
+static struct lsns_namespace *add_namespace(struct lsns *ls, enum lsns_type type, ino_t ino,
ino_t parent_ino, ino_t owner_ino)
{
struct lsns_namespace *ns = xcalloc(1, sizeof(*ns));
}
#ifdef USE_NS_GET_API
-static int clone_type_to_lsns_type(int clone_type)
+static enum lsns_type clone_type_to_lsns_type(int clone_type)
{
switch (clone_type) {
case CLONE_NEWNS:
return LSNS_TYPE_TIME;
#endif
default:
- return -1;
+ return LSNS_TYPE_UNKNOWN;
}
}
struct stat st_owner, st_parent;
ino_t ino_owner = 0, ino_parent = 0;
struct lsns_namespace *ns;
- int clone_type, lsns_type;
+ int clone_type;
+ enum lsns_type lsns_type;
clone_type = lsns_ioctl(fd, NS_GET_NSTYPE);
if (clone_type < 0)
break;
case 't':
{
- int type = ns_name2type(optarg);
+ enum lsns_type type = ns_name2type(optarg);
if (type < 0)
errx(EXIT_FAILURE, _("unknown namespace type: %s"), optarg);
ls.fltr_types[type] = 1;