return NULL;
}
-static bool nic_exists(char *nic)
-{
- char path[MAXPATHLEN];
- int ret;
- struct stat sb;
-
- if (!strcmp(nic, "none"))
- return true;
-
- ret = snprintf(path, MAXPATHLEN, "/sys/class/net/%s", nic);
- if (ret < 0 || (size_t)ret >= MAXPATHLEN)
- return false;
-
- ret = stat(path, &sb);
- if (ret < 0)
- return false;
-
- return true;
-}
-
static int instantiate_veth(char *n1, char **n2)
{
int err;
continue;
if (nic[0] != '\0')
- exists = nic_exists(nic);
+ exists = lxc_nic_exists(nic);
if (!exists)
entry_lines[n - 1].keep = false;
return has_type;
}
+
+bool lxc_nic_exists(char *nic)
+{
+#define __LXC_SYS_CLASS_NET_LEN 15 + IFNAMSIZ + 1
+ char path[__LXC_SYS_CLASS_NET_LEN];
+ int ret;
+ struct stat sb;
+
+ if (!strcmp(nic, "none"))
+ return true;
+
+ ret = snprintf(path, __LXC_SYS_CLASS_NET_LEN, "/sys/class/net/%s", nic);
+ if (ret < 0 || (size_t)ret >= __LXC_SYS_CLASS_NET_LEN)
+ return false;
+
+ ret = stat(path, &sb);
+ if (ret < 0)
+ return false;
+
+ return true;
+}
typedef __typeof__(((struct statfs *)NULL)->f_type) fs_type_magic;
extern bool has_fs_type(const char *path, fs_type_magic magic_val);
extern bool is_fs_type(const struct statfs *fs, fs_type_magic magic_val);
+extern bool lxc_nic_exists(char *nic);
#endif /* __LXC_UTILS_H */