Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Jun 2020 13:48:45 +0200
From:      Tomasz CEDRO <tomek@cedro.info>
To:        FreeBSD Questions Mailing List <freebsd-questions@freebsd.org>
Subject:   autofs auto(un)mountd umount problem
Message-ID:  <CAM8r67ADM%2BgTLx9j7fv-03XqS-L7ZcR3xGLnBqwHA%2BiFazn0KA@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hello world :-)

I am developing an embedded system. Firmware update can be done by
drag-and-drop a firmware file to a UMS exposed endpoint of the debug
probe (ARM MBED DAPLink) that emulates a small FAT memory drive. After
the firmware file bin/hex is put on the drive probe uses FlashAlgo to
put its content into a microcontroller flash memory over SWD/JTAG port
and then device reboots so the drive vanishes itself as detached and
re-attach when ready for next flashing.

Because I am quite frequently updating this firmware I have decided to
try the autofs and auto(un)mountd.

The mount part works fine. But I always need to unmount by hand. Even
though there are no files after device detach, it does not mount again
without manual umount. This may be caused by device vanish as its
intended behavior.

I guess the role of autounmountd is to unmount detached drive for me
right? After enabling debug of the autofs I can see this message
"autofs_unmount: vflush failed with error 16" which may indicate a
source of the problem. But the flush is not possible as device is
already gone. Would I like umount to use the force in that case?

Also I have vfs.usermount=1 but I am unable to mount/umount as user.

I have set vfs.autofs.cache="5" in /boot/loader.conf.

# sysctl -a | grep autofs
WARNING: autofs_unmount: vflush failed with error 16
vfs.autofs.interruptible: 1
vfs.autofs.retry_delay: 1
vfs.autofs.retry_attempts: 3
vfs.autofs.cache: 5
vfs.autofs.timeout: 30
vfs.autofs.mount_on_stat: 0
vfs.autofs.debug: 1

# sysctl -a|grep mount
WARNING: autofs_unmount: vflush failed with error 16
vfs.autofs.mount_on_stat: 0
vfs.ffs.compute_summary_at_mount: 0
vfs.root_mount_hold:
vfs.root_mount_always_wait: 0
vfs.usermount: 1

 # grep cd /etc/group
wheel:*:0:root,cd
operator:*:5:root,cd
video:*:44:cd
uucp:*:66:cd
dialer:*:68:cd
cd:*:1001:
vboxusers:*:920:cd
clamav:*:106:cd
webcamd:*:145:cd

The questions are:

1. How to make autounmountd quickly unmount vanished device so I do
not need to umount it by hand?

2. Why I cannot mount/umount as user even though vfs.usermount is set?

3. To you know a good standardized way for a memory device to detach
itself in a graceful way? At this point flashing probe just vanishes
itself itself from the scsi (?) layer which looks like a hardware
failure which may cause problems to the USB and AUTOFS layer. I can
modify the debug probe firmware if that would be the most elegant way.
I have already done it, its Open-Source, so that would be no problem,
I would only need to know the valid way of graceful detach that would
work correctly on all platforms.

Any hints welcome :-)

Tomek

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAM8r67ADM%2BgTLx9j7fv-03XqS-L7ZcR3xGLnBqwHA%2BiFazn0KA>