systemd/0157-generators-rename-add_-root-usr-_mount-to-add_-sysro.patch
Zbigniew Jędrzejewski-Szmek a48f80c6e3 More patches
2015-05-20 01:34:58 -04:00

161 lines
5.6 KiB
Diff

From 312596e3f42fd488b652c6234d085c32459e4552 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sat, 2 May 2015 12:01:29 -0500
Subject: [PATCH] generators: rename add_{root,usr}_mount to
add_{sysroot,sysroot_usr}_mount
This makes it obvious that those functions are only usable in the
initramfs.
Also, add a warning when noauto, nofail, or automount is used for the
root fs, instead of silently ignoring. Using those options would be a
sign of significant misconfiguration, and if we bother to check for
them, than let's go all the way and complain.
Other various small cleanups and reformattings elsewhere.
(cherry picked from commit 2e8522767e27d5686206794c69e0aa95da6e798b)
---
src/fstab-generator/fstab-generator.c | 20 ++++++++++++--------
src/shared/generator.c | 21 ++++++++++++---------
src/shared/generator.h | 17 +++++++++++++----
3 files changed, 37 insertions(+), 21 deletions(-)
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 8e2f522bd0..9fa2d860df 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -192,10 +192,14 @@ static int add_mount(
return 0;
if (path_equal(where, "/")) {
- /* The root disk is not an option */
- automount = false;
- noauto = false;
- nofail = false;
+ if (noauto)
+ log_warning("Ignoring \"noauto\" for root device");
+ if (nofail)
+ log_warning("Ignoring \"nofail\" for root device");
+ if (automount)
+ log_warning("Ignoring automount option for root device");
+
+ noauto = nofail = automount = false;
}
name = unit_name_from_path(where, ".mount");
@@ -394,7 +398,7 @@ static int parse_fstab(bool initrd) {
return r;
}
-static int add_root_mount(void) {
+static int add_sysroot_mount(void) {
_cleanup_free_ char *what = NULL;
const char *opts;
@@ -430,7 +434,7 @@ static int add_root_mount(void) {
"/proc/cmdline");
}
-static int add_usr_mount(void) {
+static int add_sysroot_usr_mount(void) {
_cleanup_free_ char *what = NULL;
const char *opts;
@@ -577,9 +581,9 @@ int main(int argc, char *argv[]) {
/* Always honour root= and usr= in the kernel command line if we are in an initrd */
if (in_initrd()) {
- r = add_root_mount();
+ r = add_sysroot_mount();
if (r == 0)
- r = add_usr_mount();
+ r = add_sysroot_usr_mount();
}
/* Honour /etc/fstab only when that's enabled */
diff --git a/src/shared/generator.c b/src/shared/generator.c
index 7f16d5cbef..cd37812f86 100644
--- a/src/shared/generator.c
+++ b/src/shared/generator.c
@@ -33,13 +33,13 @@
int generator_write_fsck_deps(
FILE *f,
- const char *dest,
+ const char *dir,
const char *what,
const char *where,
const char *fstype) {
assert(f);
- assert(dest);
+ assert(dir);
assert(what);
assert(where);
@@ -59,10 +59,10 @@ int generator_write_fsck_deps(
return log_warning_errno(r, "Checking was requested for %s, but fsck.%s cannot be used: %m", what, fstype);
}
- if (streq(where, "/")) {
+ if (path_equal(where, "/")) {
char *lnk;
- lnk = strjoina(dest, "/" SPECIAL_LOCAL_FS_TARGET ".wants/systemd-fsck-root.service");
+ lnk = strjoina(dir, "/" SPECIAL_LOCAL_FS_TARGET ".wants/systemd-fsck-root.service");
mkdir_parents(lnk, 0755);
if (symlink(SYSTEM_DATA_UNIT_PATH "/systemd-fsck-root.service", lnk) < 0)
@@ -76,17 +76,20 @@ int generator_write_fsck_deps(
return log_oom();
fprintf(f,
- "RequiresOverridable=%s\n"
- "After=%s\n",
- fsck,
+ "RequiresOverridable=%1$s\n"
+ "After=%1$s\n",
fsck);
}
return 0;
}
-int generator_write_timeouts(const char *dir, const char *what, const char *where,
- const char *opts, char **filtered) {
+int generator_write_timeouts(
+ const char *dir,
+ const char *what,
+ const char *where,
+ const char *opts,
+ char **filtered) {
/* Allow configuration how long we wait for a device that
* backs a mount point to show up. This is useful to support
diff --git a/src/shared/generator.h b/src/shared/generator.h
index 64bd28f596..6c3f38abba 100644
--- a/src/shared/generator.h
+++ b/src/shared/generator.h
@@ -23,7 +23,16 @@
#include <stdio.h>
-int generator_write_fsck_deps(FILE *f, const char *dest, const char *what, const char *where, const char *type);
-
-int generator_write_timeouts(const char *dir, const char *what, const char *where,
- const char *opts, char **filtered);
+int generator_write_fsck_deps(
+ FILE *f,
+ const char *dir,
+ const char *what,
+ const char *where,
+ const char *type);
+
+int generator_write_timeouts(
+ const char *dir,
+ const char *what,
+ const char *where,
+ const char *opts,
+ char **filtered);