|
|
572a44 |
From 980112adcce965de6808390330750aaf11c165ab Mon Sep 17 00:00:00 2001
|
|
|
a4b143 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
|
a4b143 |
Date: Sat, 5 Oct 2013 13:09:43 -0400
|
|
|
a4b143 |
Subject: [PATCH] core: do not add "what" to RequiresMountsFor for network
|
|
|
a4b143 |
mounts
|
|
|
a4b143 |
|
|
|
a4b143 |
For cifs mount like //server/share, we would get
|
|
|
a4b143 |
RequiresMountsFor=/server/share, which probably isn't
|
|
|
a4b143 |
harmful, but quite confusing.
|
|
|
a4b143 |
|
|
|
a4b143 |
Unfortunately a bunch of static functions had to be moved
|
|
|
a4b143 |
up, but patch is really one line.
|
|
|
a4b143 |
---
|
|
|
a4b143 |
src/core/mount.c | 137 ++++++++++++++++++++++++++++---------------------------
|
|
|
a4b143 |
1 file changed, 70 insertions(+), 67 deletions(-)
|
|
|
a4b143 |
|
|
|
a4b143 |
diff --git a/src/core/mount.c b/src/core/mount.c
|
|
|
a4b143 |
index db055f0..70cd372 100644
|
|
|
a4b143 |
--- a/src/core/mount.c
|
|
|
a4b143 |
+++ b/src/core/mount.c
|
|
|
a4b143 |
@@ -59,6 +59,72 @@ static const UnitActiveState state_translation_table[_MOUNT_STATE_MAX] = {
|
|
|
a4b143 |
[MOUNT_FAILED] = UNIT_FAILED
|
|
|
a4b143 |
};
|
|
|
a4b143 |
|
|
|
a4b143 |
+static char* mount_test_option(const char *haystack, const char *needle) {
|
|
|
a4b143 |
+ struct mntent me = { .mnt_opts = (char*) haystack };
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ assert(needle);
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ /* Like glibc's hasmntopt(), but works on a string, not a
|
|
|
a4b143 |
+ * struct mntent */
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ if (!haystack)
|
|
|
a4b143 |
+ return NULL;
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ return hasmntopt(&me, needle);
|
|
|
a4b143 |
+}
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+static bool mount_is_network(MountParameters *p) {
|
|
|
a4b143 |
+ assert(p);
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ if (mount_test_option(p->options, "_netdev"))
|
|
|
a4b143 |
+ return true;
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ if (p->fstype && fstype_is_network(p->fstype))
|
|
|
a4b143 |
+ return true;
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ return false;
|
|
|
a4b143 |
+}
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+static bool mount_is_bind(MountParameters *p) {
|
|
|
a4b143 |
+ assert(p);
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ if (mount_test_option(p->options, "bind"))
|
|
|
a4b143 |
+ return true;
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ if (p->fstype && streq(p->fstype, "bind"))
|
|
|
a4b143 |
+ return true;
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ if (mount_test_option(p->options, "rbind"))
|
|
|
a4b143 |
+ return true;
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ if (p->fstype && streq(p->fstype, "rbind"))
|
|
|
a4b143 |
+ return true;
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ return false;
|
|
|
a4b143 |
+}
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+static bool mount_is_auto(MountParameters *p) {
|
|
|
a4b143 |
+ assert(p);
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ return !mount_test_option(p->options, "noauto");
|
|
|
a4b143 |
+}
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+static bool needs_quota(MountParameters *p) {
|
|
|
a4b143 |
+ assert(p);
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ if (mount_is_network(p))
|
|
|
a4b143 |
+ return false;
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ if (mount_is_bind(p))
|
|
|
a4b143 |
+ return false;
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ return mount_test_option(p->options, "usrquota") ||
|
|
|
a4b143 |
+ mount_test_option(p->options, "grpquota") ||
|
|
|
a4b143 |
+ mount_test_option(p->options, "quota") ||
|
|
|
a4b143 |
+ mount_test_option(p->options, "usrjquota") ||
|
|
|
a4b143 |
+ mount_test_option(p->options, "grpjquota");
|
|
|
a4b143 |
+}
|
|
|
a4b143 |
+
|
|
|
a4b143 |
static void mount_init(Unit *u) {
|
|
|
a4b143 |
Mount *m = MOUNT(u);
|
|
|
a4b143 |
|
|
|
a4b143 |
@@ -182,7 +248,10 @@ static int mount_add_mount_links(Mount *m) {
|
|
|
a4b143 |
* for the source path (if this is a bind mount) to be
|
|
|
a4b143 |
* available. */
|
|
|
a4b143 |
pm = get_mount_parameters_fragment(m);
|
|
|
a4b143 |
- if (pm && pm->what && path_is_absolute(pm->what)) {
|
|
|
a4b143 |
+ if (pm && pm->what &&
|
|
|
a4b143 |
+ path_is_absolute(pm->what) &&
|
|
|
a4b143 |
+ !mount_is_network(pm)) {
|
|
|
a4b143 |
+
|
|
|
a4b143 |
r = unit_require_mounts_for(UNIT(m), pm->what);
|
|
|
a4b143 |
if (r < 0)
|
|
|
a4b143 |
return r;
|
|
|
a4b143 |
@@ -214,72 +283,6 @@ static int mount_add_mount_links(Mount *m) {
|
|
|
a4b143 |
return 0;
|
|
|
a4b143 |
}
|
|
|
a4b143 |
|
|
|
a4b143 |
-static char* mount_test_option(const char *haystack, const char *needle) {
|
|
|
a4b143 |
- struct mntent me = { .mnt_opts = (char*) haystack };
|
|
|
a4b143 |
-
|
|
|
a4b143 |
- assert(needle);
|
|
|
a4b143 |
-
|
|
|
a4b143 |
- /* Like glibc's hasmntopt(), but works on a string, not a
|
|
|
a4b143 |
- * struct mntent */
|
|
|
a4b143 |
-
|
|
|
a4b143 |
- if (!haystack)
|
|
|
a4b143 |
- return NULL;
|
|
|
a4b143 |
-
|
|
|
a4b143 |
- return hasmntopt(&me, needle);
|
|
|
a4b143 |
-}
|
|
|
a4b143 |
-
|
|
|
a4b143 |
-static bool mount_is_network(MountParameters *p) {
|
|
|
a4b143 |
- assert(p);
|
|
|
a4b143 |
-
|
|
|
a4b143 |
- if (mount_test_option(p->options, "_netdev"))
|
|
|
a4b143 |
- return true;
|
|
|
a4b143 |
-
|
|
|
a4b143 |
- if (p->fstype && fstype_is_network(p->fstype))
|
|
|
a4b143 |
- return true;
|
|
|
a4b143 |
-
|
|
|
a4b143 |
- return false;
|
|
|
a4b143 |
-}
|
|
|
a4b143 |
-
|
|
|
a4b143 |
-static bool mount_is_bind(MountParameters *p) {
|
|
|
a4b143 |
- assert(p);
|
|
|
a4b143 |
-
|
|
|
a4b143 |
- if (mount_test_option(p->options, "bind"))
|
|
|
a4b143 |
- return true;
|
|
|
a4b143 |
-
|
|
|
a4b143 |
- if (p->fstype && streq(p->fstype, "bind"))
|
|
|
a4b143 |
- return true;
|
|
|
a4b143 |
-
|
|
|
a4b143 |
- if (mount_test_option(p->options, "rbind"))
|
|
|
a4b143 |
- return true;
|
|
|
a4b143 |
-
|
|
|
a4b143 |
- if (p->fstype && streq(p->fstype, "rbind"))
|
|
|
a4b143 |
- return true;
|
|
|
a4b143 |
-
|
|
|
a4b143 |
- return false;
|
|
|
a4b143 |
-}
|
|
|
a4b143 |
-
|
|
|
a4b143 |
-static bool mount_is_auto(MountParameters *p) {
|
|
|
a4b143 |
- assert(p);
|
|
|
a4b143 |
-
|
|
|
a4b143 |
- return !mount_test_option(p->options, "noauto");
|
|
|
a4b143 |
-}
|
|
|
a4b143 |
-
|
|
|
a4b143 |
-static bool needs_quota(MountParameters *p) {
|
|
|
a4b143 |
- assert(p);
|
|
|
a4b143 |
-
|
|
|
a4b143 |
- if (mount_is_network(p))
|
|
|
a4b143 |
- return false;
|
|
|
a4b143 |
-
|
|
|
a4b143 |
- if (mount_is_bind(p))
|
|
|
a4b143 |
- return false;
|
|
|
a4b143 |
-
|
|
|
a4b143 |
- return mount_test_option(p->options, "usrquota") ||
|
|
|
a4b143 |
- mount_test_option(p->options, "grpquota") ||
|
|
|
a4b143 |
- mount_test_option(p->options, "quota") ||
|
|
|
a4b143 |
- mount_test_option(p->options, "usrjquota") ||
|
|
|
a4b143 |
- mount_test_option(p->options, "grpjquota");
|
|
|
a4b143 |
-}
|
|
|
a4b143 |
-
|
|
|
a4b143 |
static int mount_add_device_links(Mount *m) {
|
|
|
a4b143 |
MountParameters *p;
|
|
|
a4b143 |
bool device_wants_mount = false;
|