From: Franck Bui Date: Thu, 9 Apr 2020 13:01:53 +0000 (+0200) Subject: mount: introduce mount_add_default_ordering_dependencies() X-Git-Tag: v246-rc1~361^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61154cf9533f0bbce674b2de22956f7086604c91;p=thirdparty%2Fsystemd.git mount: introduce mount_add_default_ordering_dependencies() Move the handling of the usual startup/shutdown dependencies in a dedicated funtion. No functional change. --- diff --git a/src/core/mount.c b/src/core/mount.c index a70013cecf7..585bfbde10d 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -427,29 +427,17 @@ static bool mount_is_extrinsic(Mount *m) { return false; } -static int mount_add_default_dependencies(Mount *m) { +static int mount_add_default_ordering_dependencies( + Mount *m, + MountParameters *p, + UnitDependencyMask mask) { + const char *after, *before, *e; - UnitDependencyMask mask; - MountParameters *p; bool nofail; int r; assert(m); - if (!UNIT(m)->default_dependencies) - return 0; - - /* We do not add any default dependencies to /, /usr or /run/initramfs/, since they are guaranteed to stay - * mounted the whole time, since our system is on it. Also, don't bother with anything mounted below virtual - * file systems, it's also going to be virtual, and hence not worth the effort. */ - if (mount_is_extrinsic(m)) - return 0; - - p = get_mount_parameters(m); - if (!p) - return 0; - - mask = m->from_fragment ? UNIT_DEPENDENCY_FILE : UNIT_DEPENDENCY_MOUNTINFO_DEFAULT; nofail = m->from_fragment ? fstab_test_yes_no_option(m->parameters_fragment.options, "nofail\0" "fail\0") : false; e = path_startswith(m->where, "/sysroot"); @@ -502,7 +490,34 @@ static int mount_add_default_dependencies(Mount *m) { return r; } - r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, true, mask); + return unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_CONFLICTS, + SPECIAL_UMOUNT_TARGET, true, mask); +} + +static int mount_add_default_dependencies(Mount *m) { + UnitDependencyMask mask; + MountParameters *p; + int r; + + assert(m); + + if (!UNIT(m)->default_dependencies) + return 0; + + /* We do not add any default dependencies to /, /usr or /run/initramfs/, since they are + * guaranteed to stay mounted the whole time, since our system is on it. Also, don't + * bother with anything mounted below virtual file systems, it's also going to be virtual, + * and hence not worth the effort. */ + if (mount_is_extrinsic(m)) + return 0; + + p = get_mount_parameters(m); + if (!p) + return 0; + + mask = m->from_fragment ? UNIT_DEPENDENCY_FILE : UNIT_DEPENDENCY_MOUNTINFO_DEFAULT; + + r = mount_add_default_ordering_dependencies(m, p, mask); if (r < 0) return r;