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:
@@ -58,8 +58,8 @@ int umount_recursive(const char *prefix, int flags) {
|
||||
if (!path_startswith(path, prefix))
|
||||
continue;
|
||||
|
||||
if (umount2(path, flags) < 0) {
|
||||
r = log_debug_errno(errno, "Failed to umount %s: %m", path);
|
||||
if (umount2(path, flags | UMOUNT_NOFOLLOW) < 0) {
|
||||
log_debug_errno(errno, "Failed to umount %s, ignoring: %m", path);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,6 @@ int umount_recursive(const char *prefix, int flags) {
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
} while (again);
|
||||
|
||||
return n;
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
#include <mntent.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "errno-util.h"
|
||||
#include "macro.h"
|
||||
|
||||
/* 4MB for contents of regular files, 64k inodes for directories, symbolic links and device specials,
|
||||
@@ -53,3 +55,12 @@ int mount_option_mangle(
|
||||
char **ret_remaining_options);
|
||||
|
||||
int mode_to_inaccessible_node(const char *runtime_dir, mode_t mode, char **dest);
|
||||
|
||||
/* Useful for usage with _cleanup_(), unmounts, removes a directory and frees the pointer */
|
||||
static inline void umount_and_rmdir_and_free(char *p) {
|
||||
PROTECT_ERRNO;
|
||||
(void) umount_recursive(p, 0);
|
||||
(void) rmdir(p);
|
||||
free(p);
|
||||
}
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, umount_and_rmdir_and_free);
|
||||
|
||||
+2
-4
@@ -21,6 +21,7 @@
|
||||
#include "env-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "log.h"
|
||||
#include "namespace-util.h"
|
||||
#include "path-util.h"
|
||||
#include "random-util.h"
|
||||
#include "strv.h"
|
||||
@@ -137,10 +138,7 @@ bool have_namespaces(void) {
|
||||
|
||||
if (pid == 0) {
|
||||
/* child */
|
||||
if (unshare(CLONE_NEWNS) < 0)
|
||||
_exit(EXIT_FAILURE);
|
||||
|
||||
if (mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL) < 0)
|
||||
if (detach_mount_namespace() < 0)
|
||||
_exit(EXIT_FAILURE);
|
||||
|
||||
_exit(EXIT_SUCCESS);
|
||||
|
||||
Reference in New Issue
Block a user