chiark / gitweb /
mount: add remote-fs dependencies if needed after change
authorChris Leech <cleech@redhat.com>
Mon, 24 Nov 2014 04:33:40 +0000 (20:33 -0800)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 28 Nov 2014 19:30:50 +0000 (14:30 -0500)
This is an attempt to add it the remote-fs dependencies to a mount unit
if the options change, like when the utab options are picked up after
mountinfo has already been processed.  It just adds the remote-fs
dependencies, leaving the local-fs ones in place.

With this change I always get mount units with proper remote-fs
dependencies when mounted with the _netdev option.

src/core/mount.c

index c961677ff98382a69b4f51e9a4fc7b08551124d8..e62a5f1b17e1a55404bb07d4f452a033f6c0de92 100644 (file)
@@ -1438,6 +1438,19 @@ static int mount_add_one(
                         }
                 }
 
                         }
                 }
 
+                if (m->running_as == SYSTEMD_SYSTEM) {
+                        const char* target;
+
+                        target = mount_needs_network(options, fstype) ?  SPECIAL_REMOTE_FS_TARGET : NULL;
+                        /* _netdev option may have shown up late, or on a
+                         * remount. Add remote-fs dependencies, even though
+                         * local-fs ones may already be there */
+                        if (target) {
+                                unit_add_dependency_by_name(u, UNIT_BEFORE, target, NULL, true);
+                                load_extras = true;
+                        }
+                }
+
                 if (u->load_state == UNIT_NOT_FOUND) {
                         u->load_state = UNIT_LOADED;
                         u->load_error = 0;
                 if (u->load_state == UNIT_NOT_FOUND) {
                         u->load_state = UNIT_LOADED;
                         u->load_error = 0;