]> err.no Git - systemd/commitdiff
swap: don't add mount links for swap devices
authorLennart Poettering <lennart@poettering.net>
Sun, 16 May 2010 16:13:58 +0000 (18:13 +0200)
committerLennart Poettering <lennart@poettering.net>
Sun, 16 May 2010 16:13:58 +0000 (18:13 +0200)
swap.c
unit.c
util.c
util.h

diff --git a/swap.c b/swap.c
index 174ce1dc0e1d95bb6579afd107d21f6ab7532fff..bd49e1ea2bd36e5743d9e30ad58605f52b389abc 100644 (file)
--- a/swap.c
+++ b/swap.c
@@ -70,6 +70,9 @@ int swap_add_one_mount_link(Swap *s, Mount *m) {
             m->meta.load_state != UNIT_LOADED)
                 return 0;
 
+        if (is_device_path(s->what))
+                return 0;
+
         if (!path_startswith(s->what, m->where))
                 return 0;
 
diff --git a/unit.c b/unit.c
index ee0c120b24fe0eee8aba3ab7758427c936821c7b..1959b1b940074d0ff23dd81ed3be72d511814f6a 100644 (file)
--- a/unit.c
+++ b/unit.c
@@ -1864,7 +1864,7 @@ int unit_add_node_link(Unit *u, const char *what, bool wants) {
 
         /* Adds in links to the device node that this unit is based on */
 
-        if (!path_startswith(what, "/dev/") && !path_startswith(what, "/sys/"))
+        if (!is_device_path(what))
                 return 0;
 
         if (!(e = unit_name_build_escape(what+1, NULL, ".device")))
diff --git a/util.c b/util.c
index 5e3654d1d1ff383d96ec5de86381e85ed8a41d37..f7d538aaacf87496367661ba3822bc2f44cb6070 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1927,6 +1927,16 @@ bool is_clean_exit(int code, int status) {
         return false;
 }
 
+bool is_device_path(const char *path) {
+
+        /* Returns true on paths that refer to a device, either in
+         * sysfs or in /dev */
+
+        return
+                path_startswith(path, "/dev/") ||
+                path_startswith(path, "/sys/");
+}
+
 static const char *const ioprio_class_table[] = {
         [IOPRIO_CLASS_NONE] = "none",
         [IOPRIO_CLASS_RT] = "realtime",
diff --git a/util.h b/util.h
index d0fc319e0313f696f3310dbb03adfc0f9465d867..a77a952ed6d053436421b14b644f8f9a450604c7 100644 (file)
--- a/util.h
+++ b/util.h
@@ -231,6 +231,8 @@ ssize_t loop_read(int fd, void *buf, size_t nbytes);
 
 int path_is_mount_point(const char *path);
 
+bool is_device_path(const char *path);
+
 extern char * __progname;
 
 const char *ioprio_class_to_string(int i);