Bug 192852 - sysutils/fusefs-libs: ignore |automounted| option used by autofs
Summary: sysutils/fusefs-libs: ignore |automounted| option used by autofs
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Edward Tomasz Napierala
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-20 12:38 UTC by Jan Beich
Modified: 2015-05-15 11:00 UTC (History)
2 users (show)

See Also:


Attachments
fix (1.14 KB, patch)
2014-08-20 12:38 UTC, Jan Beich
no flags Details | Diff
poudriere testport log (9.3R i386) (20.78 KB, text/plain)
2014-08-20 13:26 UTC, Jan Beich
no flags Details
A patch to pass "automounted" flag properly so that auto*un*mountd DTRT. (1.04 KB, patch)
2015-01-31 08:42 UTC, Taku YAMAMOTO
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer freebsd_triage 2014-08-20 12:38:53 UTC
Created attachment 146067 [details]
fix

|automounted| mount option was added in /head@270096 and is passed by automountd(8) without a way to opt-out. But fusefs chokes on it or any other unknown option.

$ cat /etc/auto_master
/media		auto_media

$ cat /etc/auto_media
android	-intr,fstype=mtpfs,allow_other,mountprog=/usr/local/bin/simple-mtpfs :nil

$ ls /media/android/SD\ card
load: 0.10  cmd: ls 1643 [autofs] 4.52r 0.00u 0.00s 0% 2832k

$ automountd -d
automountd: waiting for request from the kernel
automountd: not forking due to -d flag; will exit after servicing a single request
automountd: got request 2: from map auto_media, path /media/android/, prefix "/media", key "android", options ""
automountd: parsing map "auto_media"
automountd: map "auto_media" maps to "/etc/auto_media"
automountd: done parsing map "auto_media"
automountd: found node defined at auto_media:7; it is a mountpoint
automountd: executing "mount -t mtpfs -o intr,allow_other,mountprog=/usr/local/bin/simple-mtpfs,automounted nil /media/android/" as pid 1644
fuse: unknown option `automounted'
load: 0.06  cmd: simple-mtpfs 1645 [fu_ini] 28.84r 0.00u 0.00s 0% 4164k
^C

simple-mtpfs command is from bug 192552 + bug 192851 hack.
Comment 1 Jan Beich freebsd_committer freebsd_triage 2014-08-20 13:26:16 UTC
Created attachment 146069 [details]
poudriere testport log (9.3R i386)
Comment 2 Edward Tomasz Napierala freebsd_committer freebsd_triage 2014-08-20 13:58:30 UTC
With the patch applied, are automounted FUSE filesystems properly marked with "automounted" in mount(8) output?
Comment 3 Edward Tomasz Napierala freebsd_committer freebsd_triage 2014-08-20 14:02:12 UTC
One more thing: is there any mechanism to enumerate connected MTP devices?  Would be nice to have a special mtpfs map, allowing to automatically mount whatever MTP devices are available.  I'm working with Vermaden to do something like that for removable media.
Comment 4 Jan Beich freebsd_committer freebsd_triage 2014-08-20 16:01:54 UTC
(In reply to Edward Tomasz Napierala from comment #2)
> With the patch applied, are automounted FUSE filesystems properly marked
> with "automounted" in mount(8) output?

No, |automounted| isn't propagated to the mountpoint unlike, say, |union| option. This severely reduces the usefulness of autofs + fuse. I'm currently trying to debug.

And a .conf file under /etc/devd/ may still be required to handle device reattach. Not sure how to map devices back to $cdev and mountpoint on detach.

(In reply to Edward Tomasz Napierala from comment #3)
> One more thing: is there any mechanism to enumerate connected MTP devices?

mtp-detect (from libmtp) or provided by implementation. mtp-* commands are very slow here. Here's what I use.

$ simple-mtpfs --help |& fgrep device
    -l   --list-devices    print available devices
         --device          select a device number to mount

$ simple-mtpfs --list-devices
1: PhoneA MTP
2: PhoneB MTP+ADB

$ simple-mtpfs --device 2 -o allow_other /mnt
$ ls -F /mnt
Internal storage/ SD card/

> Would be nice to have a special mtpfs map, allowing to automatically mount
> whatever MTP devices are available.

Yes, implementing /etc/autofs/special_simple-mtpfs shouldn't be hard. 

> I'm working with Vermaden to do something like that for removable media.

A few network filesystems may benefit from special maps as well e.g., curlftpfs, sshfs, smbnetfs.
Comment 5 Edward Tomasz Napierala freebsd_committer freebsd_triage 2014-08-22 16:53:14 UTC
True.  I already have the SMB map: https://github.com/trasz/autofs/blob/master/etc/autofs/special_smb
Comment 6 Edward Tomasz Napierala freebsd_committer freebsd_triage 2014-08-23 10:39:15 UTC
Not sure how far have you got with debugging the missing 'automounted' flag, but here's suggestion: the binary flag, MNT_AUTOMOUNTED, does not fit in int, so you have to pass it to nmount(2) as string, not in 'flags' field.  This might be what breaks things for FUSE.  It certainly breaks mount_fusefs(8).
Comment 7 Jan Beich freebsd_committer freebsd_triage 2014-08-24 16:19:34 UTC
(In reply to Edward Tomasz Napierala from comment #5)
> True.  I already have the SMB map:
> https://github.com/trasz/autofs/blob/master/etc/autofs/special_smb

Please, use |smbutil view //host| to list shares with smbfs in base. Leave smbclient(1) for smbnetfs (fuse) from ports.

Also, autofs would choke on space (bug 192968) or may list bogus dirs (see below).

$ nmblookup '*'
querying * on 1.1.1.1
name_query failed to find name *

$ /etc/autofs/special_smb
name_query
querying

$ ls -F /smb
name_query/ querying/
Comment 8 Taku YAMAMOTO 2015-01-31 08:42:58 UTC
Created attachment 152412 [details]
A patch to pass "automounted" flag properly so that auto*un*mountd DTRT.

In order for auto-*un*mounting fusefs to work, we have to pass "automounted" flag properly, which the current implementation of mount_fusefs silently drops.

This patch would not be needed if only nmount(2) accepted flags as 64-bits, sigh...
Comment 9 Jan Beich freebsd_committer freebsd_triage 2015-02-18 19:56:22 UTC
I confirm the patch in comment 8 addresses comment 2. My patch in comment 0 is still needed as well. Edward, can you review/land?

$ mount | fgrep fuse
/dev/fuse on /mtp/PhoneA (fusefs, local, synchronous, automounted)
Comment 10 commit-hook freebsd_committer freebsd_triage 2015-02-20 08:26:24 UTC
A commit references this bug:

Author: jbeich
Date: Fri Feb 20 08:26:22 UTC 2015
New revision: 379415
URL: https://svnweb.freebsd.org/changeset/ports/379415

Log:
  Pass "automounted" mount option to mount_fusefs(8)

  This only addresses libfuse rejecting unknown option. mount_fusefs(8)
  still needs to be fixed separately.

  PR:		192852

Changes:
  head/sysutils/fusefs-libs/Makefile
  head/sysutils/fusefs-libs/files/patch-lib_mount_bsd.c
Comment 11 Jan Beich freebsd_committer freebsd_triage 2015-02-20 08:33:44 UTC
(In reply to Edward Tomasz Napierala from comment #6)
libfuse doesn't use binary flags, options are passed to mount_fusefs(8) as arguments. As the bug has stalled for too long I've landed my fix (assuming no objection), the rest is yours.
Comment 12 Edward Tomasz Napierala freebsd_committer freebsd_triage 2015-03-01 14:02:08 UTC
Can you test an alternative version of the patch?  Thanks!

Index: mount_fusefs.c
===================================================================
--- mount_fusefs.c      (revision 279486)
+++ mount_fusefs.c      (working copy)
@@ -73,6 +73,13 @@
        { "subtype=",            0, ALTF_SUBTYPE, 1 },
        #define ALTF_SYNC_UNMOUNT 0x80
        { "sync_unmount",        0, ALTF_SYNC_UNMOUNT, 1 },
+       /*
+        * MOPT_AUTOMOUNTED, included by MOPT_STDOPTS, does not fit into
+        * the 'flags' argument to nmount(2).  We have to abuse altflags
+        * to pass it, as string, via iovec.
+        */
+       #define ALTF_AUTOMOUNTED 0x100
+       { "automounted",        0, ALTF_AUTOMOUNTED, 1 },
        /* Linux specific options, we silently ignore them */
        { "fsname=",             0, 0x00, 1 },
        { "fd=",                 0, 0x00, 1 },
Comment 13 Edward Tomasz Napierala freebsd_committer freebsd_triage 2015-03-01 14:36:50 UTC
(Jan, your MTA is bouncing my emails.)
Comment 14 Jan Beich freebsd_committer freebsd_triage 2015-03-01 14:51:24 UTC
Tested. Comment #12 version also fixes the issue.

# unpatched
$ mount | fgrep fuse
/dev/fuse on /mtp/PhoneA (fusefs, local, synchronous)
# 10 mins later
$ mount | fgrep fuse
/dev/fuse on /mtp/PhoneA (fusefs, local, synchronous)

# patched
$ mount | fgrep fuse
/dev/fuse on /mtp/PhoneA (fusefs, local, synchronous, automounted)
# 10 mins later
$ mount | fgrep fuse
$

(In reply to Edward Tomasz Napierala from comment #13)
(Jan, your MTA is bouncing my emails.)

Hmm, bugzilla mail passes through...
Comment 15 commit-hook freebsd_committer freebsd_triage 2015-03-01 18:27:28 UTC
A commit references this bug:

Author: trasz
Date: Sun Mar  1 18:26:27 UTC 2015
New revision: 279489
URL: https://svnweb.freebsd.org/changeset/base/279489

Log:
  Make the "automounted" flag work for FUSE filesystems.

  PR:		192852
  Submitted by:	taku at tackymt.homeip.net (earlier version)
  MFC after:	1 month
  Sponsored by:	The FreeBSD Foundation

Changes:
  head/sbin/mount_fusefs/mount_fusefs.c
Comment 16 Jan Beich freebsd_committer freebsd_triage 2015-05-04 05:21:17 UTC
MFC ping!
Comment 17 commit-hook freebsd_committer freebsd_triage 2015-05-15 11:00:30 UTC
A commit references this bug:

Author: trasz
Date: Fri May 15 11:00:13 UTC 2015
New revision: 282959
URL: https://svnweb.freebsd.org/changeset/base/282959

Log:
  MFC r279489:

  Make the "automounted" flag work for FUSE filesystems.

  PR:		192852
  Submitted by:	taku at tackymt.homeip.net (earlier version)
  Sponsored by:	The FreeBSD Foundation

Changes:
_U  stable/10/
  stable/10/sbin/mount_fusefs/mount_fusefs.c