Open probonopd opened 3 years ago
Note that MONKEYPATCH
can be addressed as /dev/da1
and /dev/msdosfs/MONKEYPATCH
.
In this case, /dev/msdosfs/MONKEYPATCH
was already mounted before automount
was started, and then was mounted again from /dev/da1
.
% mount
/dev/iso9660/LIVE on / (cd9660, local, read-only)
(...)
/dev/msdosfs/MONKEYPATCH on /media/MONKEYPATCH (msdosfs, local)
(...)
/dev/da1 on /media/MONKEYPATCH-2 (msdosfs, local, noatime, read-only)
Thats the 'price' for alternative approach with 'read only' mount.
How would you know if a device is mounted? Check output of mount(8) command.
After /dev/msdosfs/MONKEYPATCH was mounted ... does /dev/da1 appear in the mounted list? No. So its not mounted to the automount. Then automount tries to mount it read write and it fails because its already mounted so it tries to mount it read only and that works.
Can you do not use /dev/msdosfs path for mounting and just use 'plain' devices as da0/da1/...?
We can't trust that user would always do this, so we need to find a solution.
So I propose, when e.g., /usr/local/sbin/automount da1 attach
is invoked, to check using something like
dmesg | grep "Label for provider da1 is" | tail -n 1 | cut -d " " -f 7 | rev | cut -c 2- | rev
in __check_already_mounted()
. And then check whether it is still mounted (because it could have been unmounted since the message appeared in dmesg).
Seems to work for me:
% dmesg | grep "Label for provider da1 is" | tail -n 1 | cut -d " " -f 7 | rev | cut -c 2- | rev
msdosfs/MONKEYPATCH
So from there the next check would be:
mount | grep -e "^/dev/msdosfs/MONKEYPATCH on"
and if that returns nothing, then assume that it was not mounted.
That would also require additional checks for UFS labels, GPT labels, GLABEL labels, ext2/3/4 labels, and so on. It will make supporting automount(8) a nightmare ...
Would you consider it if I come up with a grep one-liner?
One grep(1) one liner would not solve that. You have to use multiple utilities to get the labels of many types of filesystems.
Just do not use /dev/msdosfs as the path for automount(8) daemon.
Use da(4) and ada(4) and md(4) and mmcsd(4) devices.
That does not work for me. The volume with this label may be on different types of disks. I want to address my volumes by their name, not depending on the bus they happen to be connected to.
Anyhow, I'll see what I can do because I need this in helloSystem anyway.
I will try to add that 'check' for label at least for FAT fs.
That would be sufficient for your needs, yes?
Unfortunately no. Do you know what else there is besides msdosfs
, iso9660
, ufs
, uzip
or where to look that up? I haven't given up on the idea of an one-liner entirely yet and would like to try.
Also /dev/gpart and /dev/label for sure.
Relevant docs:
https://docs.freebsd.org/en/books/handbook/geom/#geom-glabel
By permanently labeling the partitions on the boot disk, the system should be able to continue to boot normally, even if the disk is moved to another controller or transferred to a different system.
This is the reason why we want to use the disk labels for everything in helloSystem.
Looking at man glabel(8)
it seems like we need to check:
Yeah, that is why I stick to the 'raw' devices and not their logical clones.
I have other idea. I will add an option to the automount.conf config file that will disallow read only mounts - do each volume will be again mounted once.
mount | grep -e "^/dev/(label|ufs|ufsid|msdosfs|iso9660|ext2fs|reiserfs|ntfs|gpt|gptid|diskid)/MONKEYPATCH on"
I will add an option to the automount.conf config file that will disallow read only mounts
Who would want that? I will need read-only mounts a lot for sure, especially now that double-clicking an ISO file mounts it!
But WHERE that grep(1) expression would help us?
Before doing any mounting, run
<that grep expression> && exit 0
(of course with the correct patition/volume/disk label instead of MONKEYPATCH
;-))
On the helloSystem Live ISO which is heavily based on
automount
, some volumes (e.g.,MONKEYPATCH
in the picture) need to be mounted very early in the boot process, beforeautomount
is started. This results to these being mounted twice (seeMONKEYPATCH-2
).It would be good to check if a geom is already mounted and if so, exit without trying to mount it again.