log_debug("Wiping fully visible API FS");
- r = namespace_open(0,
- /* ret_pidns_fd = */ NULL,
- &orig_mntns_fd,
- /* ret_netns_fd = */ NULL,
- /* ret_userns_fd = */ NULL,
- /* ret_root_fd = */ NULL);
- if (r < 0)
- return log_error_errno(r, "Failed to pin originating mount namespace: %m");
+ orig_mntns_fd = namespace_open_by_type(NAMESPACE_MOUNT);
+ if (orig_mntns_fd < 0)
+ return log_error_errno(orig_mntns_fd, "Failed to pin originating mount namespace: %m");
r = namespace_enter(/* pidns_fd = */ -EBADF,
mntns_fd,
assert(netns_fd >= 0);
if (ret_original_netns_fd) {
- r = namespace_open(0,
- /* ret_pidns_fd = */ NULL,
- /* ret_mntns_fd = */ NULL,
- &original_netns_fd,
- /* ret_userns_fd = */ NULL,
- /* ret_root_fd = */ NULL);
- if (r < 0)
- return log_error_errno(r, "Failed to open original network namespace: %m");
+ original_netns_fd = namespace_open_by_type(NAMESPACE_NET);
+ if (original_netns_fd < 0)
+ return log_error_errno(original_netns_fd, "Failed to open original network namespace: %m");
}
r = namespace_enter(/* pidns_fd = */ -EBADF,
return r;
if (arg_userns_mode != USER_NAMESPACE_NO) {
- r = namespace_open(0,
- /* ret_pidns_fd = */ NULL,
- &mntns_fd,
- /* ret_netns_fd = */ NULL,
- /* ret_userns_fd = */ NULL,
- /* ret_root_fd = */ NULL);
- if (r < 0)
- return log_error_errno(r, "Failed to pin outer mount namespace: %m");
+ mntns_fd = namespace_open_by_type(NAMESPACE_MOUNT);
+ if (mntns_fd < 0)
+ return log_error_errno(mntns_fd, "Failed to pin outer mount namespace: %m");
l = send_one_fd(fd_outer_socket, mntns_fd, 0);
if (l < 0)
fd = safe_close(fd);
/* Store current mount namespace */
- r = namespace_open(0,
- /* ret_pidns_fd = */ NULL,
- &initial_mntns_fd,
- /* ret_netns_fd = */ NULL,
- /* ret_userns_fd = */ NULL,
- /* ret_root_fd = */ NULL);
- if (r < 0)
- return log_error_errno(r, "Can't fetch current mount namespace: %m");
+ initial_mntns_fd = namespace_open_by_type(NAMESPACE_MOUNT);
+ if (initial_mntns_fd < 0)
+ return log_error_errno(initial_mntns_fd, "Can't fetch current mount namespace: %m");
/* Switch to a new mount namespace, isolate ourself and unmount etc_machine_id in our new namespace */
r = detach_mount_namespace();
int r;
if (netnsfd < 0) {
- r = namespace_open(
- 0,
- /* ret_pidns_fd = */ NULL,
- /* ret_mntns_fd = */ NULL,
- &_netns_fd,
- /* ret_userns_fd = */ NULL,
- /* ret_root_fd = */ NULL);
- if (r < 0)
- return r;
+ _netns_fd = namespace_open_by_type(NAMESPACE_NET);
+ if (_netns_fd < 0)
+ return _netns_fd;
netnsfd = _netns_fd;
}