chiark / gitweb /
systemadm: make fragment path a clickable link
[elogind.git] / src / automount.c
index 465354f5556503f82f790c8b0f69c973ca1d1a04..730b1572c2ddfff4102e6b9c0e7ee61d0b32de2c 100644 (file)
@@ -59,6 +59,8 @@ static void repeat_unmout(const char *path) {
         assert(path);
 
         for (;;) {
+                /* If there are multiple mounts on a mount point, this
+                 * removes them all */
 
                 if (umount2(path, MNT_DETACH) >= 0)
                         continue;
@@ -118,6 +120,9 @@ int automount_add_one_mount_link(Automount *a, Mount *m) {
         if (!path_startswith(a->where, m->where))
                 return 0;
 
+        if (path_equal(a->where, m->where))
+                return 0;
+
         if ((r = unit_add_dependency(UNIT(m), UNIT_BEFORE, UNIT(a), true)) < 0)
                 return r;
 
@@ -271,8 +276,18 @@ static int open_dev_autofs(Manager *m) {
                 return m->dev_autofs_fd;
 
         if ((m->dev_autofs_fd = open("/dev/autofs", O_CLOEXEC|O_RDONLY)) < 0) {
-                log_error("Failed to open /dev/autofs: %s", strerror(errno));
-                return -errno;
+
+                if (errno == ENOENT || errno == ENODEV) {
+                        log_error("Your kernel apparently lacks built-in autofs4 support. Please fix that. "
+                                  "We'll now try to work around this by calling 'modprobe autofs4'...");
+                        system("/sbin/modprobe -q -- autofs4");
+                        m->dev_autofs_fd = open("/dev/autofs", O_CLOEXEC|O_RDONLY);
+                }
+
+                if (m->dev_autofs_fd < 0) {
+                        log_error("Failed to open /dev/autofs: %s", strerror(errno));
+                        return -errno;
+                }
         }
 
         init_autofs_dev_ioctl(&param);