summaryrefslogtreecommitdiffstats
path: root/src/fstab-generator/fstab-generator.c
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2020-06-11 11:27:41 +0200
committerFranck Bui <fbui@suse.com>2020-07-01 16:35:13 +0200
commit6371e69b498ee40204f6f7a75951b7eb04746873 (patch)
tree44261b64d4731116b03440fce3804f3e7dbfbcff /src/fstab-generator/fstab-generator.c
parentfstab-generator: extra dependencies specified in fstab should be applied to t... (diff)
downloadsystemd-6371e69b498ee40204f6f7a75951b7eb04746873.tar.xz
systemd-6371e69b498ee40204f6f7a75951b7eb04746873.zip
fstab-generator: introduce an helper to write extra dependencies specified via the mount options
No functional change.
Diffstat (limited to 'src/fstab-generator/fstab-generator.c')
-rw-r--r--src/fstab-generator/fstab-generator.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 39e91a9c6b..91581aed30 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -314,6 +314,29 @@ static int write_requires_mounts_for(FILE *f, const char *opts) {
return 0;
}
+static int write_extra_dependencies(FILE *f, const char *opts) {
+ int r;
+
+ assert(f);
+
+ if (opts) {
+ r = write_after(f, opts);
+ if (r < 0)
+ return r;
+ r = write_requires_after(f, opts);
+ if (r < 0)
+ return r;
+ r = write_before(f, opts);
+ if (r < 0)
+ return r;
+ r = write_requires_mounts_for(f, opts);
+ if (r < 0)
+ return r;
+ }
+
+ return 0;
+}
+
static int add_mount(
const char *dest,
const char *what,
@@ -406,20 +429,9 @@ static int add_mount(
SET_FLAG(flags, NOFAIL, true);
}
- if (opts) {
- r = write_after(f, opts);
- if (r < 0)
- return r;
- r = write_requires_after(f, opts);
- if (r < 0)
- return r;
- r = write_before(f, opts);
- if (r < 0)
- return r;
- r = write_requires_mounts_for(f, opts);
- if (r < 0)
- return r;
- }
+ r = write_extra_dependencies(f, opts);
+ if (r < 0)
+ return r;
if (passno != 0) {
r = generator_write_fsck_deps(f, dest, what, where, fstype);