mirror of
https://github.com/systemd/systemd.git
synced 2025-01-12 13:18:14 +03:00
fstab-generator: simplify add_root_mount
This commit is contained in:
parent
9fcdf32294
commit
75a59316ea
@ -402,7 +402,8 @@ static int parse_fstab(bool initrd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int add_root_mount(void) {
|
static int add_root_mount(void) {
|
||||||
_cleanup_free_ char *o = NULL, *what = NULL;
|
_cleanup_free_ char *what = NULL;
|
||||||
|
const char *opts;
|
||||||
|
|
||||||
if (isempty(arg_root_what)) {
|
if (isempty(arg_root_what)) {
|
||||||
log_debug("Could not find a root= entry on the kernel commandline.");
|
log_debug("Could not find a root= entry on the kernel commandline.");
|
||||||
@ -416,23 +417,19 @@ static int add_root_mount(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!arg_root_options)
|
if (!arg_root_options)
|
||||||
o = strdup(arg_root_rw > 0 ? "rw" : "ro");
|
opts = arg_root_rw > 0 ? "rw" : "ro";
|
||||||
else {
|
else if (arg_root_rw >= 0 ||
|
||||||
if (arg_root_rw >= 0 ||
|
|
||||||
(!mount_test_option(arg_root_options, "ro") &&
|
(!mount_test_option(arg_root_options, "ro") &&
|
||||||
!mount_test_option(arg_root_options, "rw")))
|
!mount_test_option(arg_root_options, "rw")))
|
||||||
o = strjoin(arg_root_options, ",", arg_root_rw > 0 ? "rw" : "ro", NULL);
|
opts = strappenda3(arg_root_options, ",", arg_root_rw > 0 ? "rw" : "ro");
|
||||||
else
|
else
|
||||||
o = strdup(arg_root_options);
|
opts = arg_root_options;
|
||||||
}
|
|
||||||
if (!o)
|
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
log_debug("Found entry what=%s where=/sysroot type=%s", what, strna(arg_root_fstype));
|
log_debug("Found entry what=%s where=/sysroot type=%s", what, strna(arg_root_fstype));
|
||||||
return add_mount(what,
|
return add_mount(what,
|
||||||
"/sysroot",
|
"/sysroot",
|
||||||
arg_root_fstype,
|
arg_root_fstype,
|
||||||
o,
|
opts,
|
||||||
1,
|
1,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
@ -518,6 +515,8 @@ int main(int argc, char *argv[]) {
|
|||||||
if (arg_fstab_enabled) {
|
if (arg_fstab_enabled) {
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
|
log_debug("Parsing /etc/fstab");
|
||||||
|
|
||||||
/* Parse the local /etc/fstab, possibly from the initrd */
|
/* Parse the local /etc/fstab, possibly from the initrd */
|
||||||
k = parse_fstab(false);
|
k = parse_fstab(false);
|
||||||
if (k < 0)
|
if (k < 0)
|
||||||
@ -525,6 +524,8 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
/* If running in the initrd also parse the /etc/fstab from the host */
|
/* If running in the initrd also parse the /etc/fstab from the host */
|
||||||
if (in_initrd()) {
|
if (in_initrd()) {
|
||||||
|
log_debug("Parsing /sysroot/etc/fstab");
|
||||||
|
|
||||||
k = parse_fstab(true);
|
k = parse_fstab(true);
|
||||||
if (k < 0)
|
if (k < 0)
|
||||||
r = k;
|
r = k;
|
||||||
|
Loading…
Reference in New Issue
Block a user