[systemd-devel] Considering fuse+sshfs mounts as "network"

Colin Guthrie gmane at colin.guthr.ie
Wed Jan 11 04:31:28 PST 2012


'Twas brillig, and Karel Zak at 11/01/12 12:13 did gyre and gimble:
> man fstab:
> 
>   mount(8) and umount(8) support filesystem subtypes. The subtype is
>   defined by '.subtype' suffix. For example 'fuse.sshfs'. It's
>   recommended to use subtype notation rather  than add any prefix to
>   the first fstab field (for example 'sshfs#example.com' is deprecated).
> 
> 
> Note that this feature has been requested by fuse developers, because
> with this notation we can support subtype specific
> /sbin/mount.<type>[.<subtype>] helpers. The 'sshfs#example.com' is
> horrible hack.

Cool, so in theory at least, this modified patch would support this
older syntax and still allow the newer syntax to work fine too?

If the deprecated format should not be supported at all, then the first
hunk (i.e. all changes in src/mount.c) can just be dropped (in order to
not break upgrades, I'd quite like to support the deprecated format at
least for this cycle, but I'm more than happy for that to be a
distro-applied patch and/or to do some funky awk/sed work on the fstab
on package upgrade... tho' I'm always a bit wary of messing with a
user's fstab if not 100% needed.).


commit ca4c47b568b126774941f51f495e0e41a6ab8bb9
Author: Colin Guthrie <colin at mageia.org>
Date:   Mon Jan 9 11:14:15 2012 +0000

    mount: Consider some fuse mounts as network (sshfs)

diff --git a/src/mount.c b/src/mount.c
index f72c50a..ff3af39 100644
--- a/src/mount.c
+++ b/src/mount.c
@@ -285,8 +285,22 @@ static bool mount_is_network(MountParameters *p) {
         if (mount_test_option(p->options, "_netdev"))
                 return true;

-        if (p->fstype && fstype_is_network(p->fstype))
-                return true;
+        if (p->fstype) {
+                if (p->what && streq(p->fstype, "fuse")) {
+                        char *fstype;
+                        if (asprintf(&fstype, "fuse.%s", p->what) >= 0) {
+                                fstype[strcspn(fstype, "#")] = 0;
+                                if (fstype_is_network(fstype)) {
+                                        free(fstype);
+                                        return true;
+                                }
+                                free(fstype);
+                        }
+
+                }
+                else if (fstype_is_network(p->fstype))
+                        return true;
+        }

         return false;
 }
diff --git a/src/util.c b/src/util.c
index b4c5e2e..fab698c 100644
--- a/src/util.c
+++ b/src/util.c
@@ -2312,7 +2312,8 @@ bool fstype_is_network(const char *fstype) {
                 "nfs",
                 "nfs4",
                 "gfs",
-                "gfs2"
+                "gfs2",
+                "fuse.sshfs"
         };

         unsigned i;

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/


More information about the systemd-devel mailing list