923a60
From 602786c9171d189e859796fd61873835fe858a06 Mon Sep 17 00:00:00 2001
923a60
From: Lennart Poettering <lennart@poettering.net>
923a60
Date: Tue, 19 May 2015 17:19:27 +0200
923a60
Subject: [PATCH] mount: properly check for mounts currently in
923a60
 /proc/self/mountinfo
923a60
923a60
http://lists.freedesktop.org/archives/systemd-devel/2015-May/032059.html
923a60
(cherry picked from commit 394763f63c1941cafd9d3bf81e8151a2206474a7)
923a60
923a60
Cherry-picked from: 394763f
923a60
Resolves: #1222517
923a60
---
923a60
 src/core/mount.c | 33 +++++++++++++++++++--------------
923a60
 1 file changed, 19 insertions(+), 14 deletions(-)
923a60
923a60
diff --git a/src/core/mount.c b/src/core/mount.c
923a60
index fa63f2426f..1f1a41ab66 100644
923a60
--- a/src/core/mount.c
923a60
+++ b/src/core/mount.c
923a60
@@ -1768,7 +1768,18 @@ static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
923a60
 
923a60
                 if (!mount->is_mounted) {
923a60
 
923a60
-                        /* A mount point is gone */
923a60
+                        /* A mount point is not around right now. It
923a60
+                         * might be gone, or might never have
923a60
+                         * existed. */
923a60
+
923a60
+                        if (mount->from_proc_self_mountinfo &&
923a60
+                            mount->parameters_proc_self_mountinfo.what) {
923a60
+
923a60
+                                /* Remember that this device might just have disappeared */
923a60
+                                if (set_ensure_allocated(&gone, &string_hash_ops) < 0 ||
923a60
+                                    set_put(gone, mount->parameters_proc_self_mountinfo.what) < 0)
923a60
+                                        log_oom(); /* we don't care too much about OOM here... */
923a60
+                        }
923a60
 
923a60
                         mount->from_proc_self_mountinfo = false;
923a60
 
923a60
@@ -1785,14 +1796,6 @@ static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
923a60
                                 break;
923a60
                         }
923a60
 
923a60
-                        /* Remember that this device might just have disappeared */
923a60
-                        if (mount->parameters_proc_self_mountinfo.what) {
923a60
-
923a60
-                                if (set_ensure_allocated(&gone, &string_hash_ops) < 0 ||
923a60
-                                    set_put(gone, mount->parameters_proc_self_mountinfo.what) < 0)
923a60
-                                        log_oom(); /* we don't care too much about OOM here... */
923a60
-                        }
923a60
-
923a60
                 } else if (mount->just_mounted || mount->just_changed) {
923a60
 
923a60
                         /* A mount point was added or changed */
923a60
@@ -1820,13 +1823,15 @@ static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
923a60
                                 mount_set_state(mount, mount->state);
923a60
                                 break;
923a60
                         }
923a60
+                }
923a60
 
923a60
-                        if (mount->parameters_proc_self_mountinfo.what) {
923a60
+                if (mount->is_mounted &&
923a60
+                    mount->from_proc_self_mountinfo &&
923a60
+                    mount->parameters_proc_self_mountinfo.what) {
923a60
 
923a60
-                                if (set_ensure_allocated(&around, &string_hash_ops) < 0 ||
923a60
-                                    set_put(around, mount->parameters_proc_self_mountinfo.what) < 0)
923a60
-                                        log_oom();
923a60
-                        }
923a60
+                        if (set_ensure_allocated(&around, &string_hash_ops) < 0 ||
923a60
+                            set_put(around, mount->parameters_proc_self_mountinfo.what) < 0)
923a60
+                                log_oom();
923a60
                 }
923a60
 
923a60
                 /* Reset the flags for later calls */