Merge pull request #16301 from poettering/firstboot-image

Add --image= switch to firstboot, similar to --root= but with support for operating on disk image
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2020-07-07 19:44:12 +02:00
committed by GitHub
10 changed files with 189 additions and 27 deletions
+14
View File
@@ -2,6 +2,7 @@
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#include "fd-util.h"
#include "missing_fs.h"
@@ -169,3 +170,16 @@ int fd_is_network_ns(int fd) {
return r == CLONE_NEWNET;
}
int detach_mount_namespace(void) {
/* Detaches the mount namespace, disabling propagation from our namespace to the host */
if (unshare(CLONE_NEWNS) < 0)
return -errno;
if (mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) < 0)
return -errno;
return 0;
}
+2
View File
@@ -7,3 +7,5 @@ int namespace_open(pid_t pid, int *pidns_fd, int *mntns_fd, int *netns_fd, int *
int namespace_enter(int pidns_fd, int mntns_fd, int netns_fd, int userns_fd, int root_fd);
int fd_is_network_ns(int fd);
int detach_mount_namespace(void);