There is no (documented) way to pass locale options (e.g. -L ru_RU.UTF-8 -D CP866) to mount_msdosfs when using the default special -media map.
You can specify options in /etc/fstab like follows. %grep msdosfs /etc/fstab /dev/ada0pX /hoge msdosfs rw,noauto,-L=ru_RU.UTF-8,-D=CP866 0 0
(In reply to Masachika ISHIZUKA from comment #1) > You can specify options in /etc/fstab like follows. How is fstab related to autofs, automount and /etc/autofs/special_media ?
(In reply to Victor Sudakov from comment #2) Automount is referring /etc/fstab. See 'special maps' (-noauto) in 'man 5 auto_master'.
(In reply to Masachika ISHIZUKA from comment #3) No, I don't use the -noauto map, I use the -media map. I need to pass locale options to the -media map. I think I made it clear from the very beginning.
(In reply to Victor Sudakov from comment #4) Sorry. I think there is no way to specify locale options for the original (non modified) /etc/autofs/special_media.
(In reply to Masachika ISHIZUKA from comment #5) Well, I'm not afraid to modify the original /etc/autofs/special_media. In fact I can make it produce the following output: root@vas:~ # /etc/autofs/special_media da0 -fstype=msdosfs,nosuid,async,-L=ru_RU.UTF-8,-D=CP866 :/dev/da0 But it's an ugly undocumented way. root@vas:~ # diff -u /etc/autofs/special_media.bak /etc/autofs/special_media --- /etc/autofs/special_media.bak 2019-10-26 14:02:02.810753000 +0700 +++ /etc/autofs/special_media 2019-10-26 14:02:59.638463000 +0700 @@ -58,7 +58,7 @@ fi ;; "ext2fs" | "msdosfs") - echo "-fstype=${_fstype},nosuid,async :/dev/${_p}" + echo "-fstype=${_fstype},nosuid,async,-L=ru_RU.UTF-8,-D=CP866 :/dev/${_p}" ;; *) echo "-fstype=${_fstype},nosuid :/dev/${_p}" root@vas:~ #
Can you try passing it in auto_master, like this? /media -media -nosuid,noatime,autoro,-L=ru_RU.UTF-8,-D=CP866 It wouldn't be shown in special_media's output, but it should get used by automountd(8) when mounting; if you set automountd_flags="-v" you should see this in logs: Nov 25 12:35:05 v2 automountd[1866]: executing "mount -t msdosfs -o nosuid,async,nosuid,noatime,autoro,-L=ru_RU.UTF-8,-D=CP866,automounted /dev/md0 /media/md0/" as pid 1875
(In reply to Edward Tomasz Napierala from comment #7) This won't work because fusefs does not support locale options, and the /media map mount options are common for both fuse and msdosfs. If I do as you request, mounting exfat will break.
Okay, in this case the best way is modifying /etc/autofs/special_media then.
(In reply to Edward Tomasz Napierala from comment #9) > Okay, in this case the best way is modifying /etc/autofs/special_media then. Do you plan to provide some tunable variables in /etc/autofs/special_media (or even in rc.conf) because hacking /etc/autofs/special_media directly is kind of ugly? Like MSDOSFS_ENCODING, MSDOSFS_UMASK or whatever?
I think hacking special_media is fragile as well as ugly, as the file could be clobbered by freebsd-update. I did the following to get msdosfs USB sticks writable by default: - "ext2fs" | "msdosfs") + "ext2fs") echo "-fstype=${_fstype},nosuid,async :/dev/${_p}" + ;; + "msdosfs") + echo "-fstype=${_fstype},nosuid,async,-m=770,-g=operator : Adding -m=770 to auto_master breaks mounting for other filesystems like UFS2, which don't accept the flag. I think a simple solution here would be sourcing an rc.conf-like script for default options, let's say /etc/autofs/defaults.msdosfs. Or maybe one defaults file for all filesystems: # /etc/autofs/special_media_defaults msdosfs_mount_flags="-m=770,-L=ru_RU.UTF-8,-D=CP866" We could maybe just use /etc/rc.conf for this as well. I develop and maintain sysutils/auto-admin and sysutils/desktop-installer and I would really like a simple, scriptable way to make automount work out-of-the-box for all common filesystems. It's one of the few remaining issues for basic desktop functionality in desktop-installer.
(In reply to Jason W. Bacon from comment #11) > I develop and maintain sysutils/auto-admin and sysutils/desktop-installer I've used FreeBSD as desktop for over 20 years, and so has (nolens volens) my wife. I assure you, FreeBSD cannot be declared desktop-ready until there is an automounter for removable media working out of the box (supporting files with non-ascii names out of the box etc). autofs has numerous problems, the worst being these: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241531 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242243 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241684 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241474 Unless they are fixed, we cannot think about using autofs on desktop IMHO. I'm aware of userland automounters in Gnome, Mate etc, but they are not Cyrillic-ready out of the box.
I agree. So let's get the remaining issues fixed. With the recent demise of TrueOS-Desktop (and Trident moving to a Linux base), I'm ramping up my efforts to improve both the functionality and UI of desktop-installer and make it suitable for a less geeky audience. My two big remaining issues are external media and selecting a drm-kmod + video driver. The latter may always require some sort of end-user intervention, but I think the autofs issues can be resolved pretty quickly. My wife also uses a FreeBSD laptop, sometimes with Chinese characters. It's doable, but needs to be made more easily configurable. Most of the pieces are there in base and ports, but figuring out how to integrate them has taken some research.
FWIW, most of those issues are not bugs in autofs itself, but in other pieces of software that autofs uses. I'd prefer fixing them in the correct place instead of adding workarounds to autofs. I wonder if we could just add a sysctl that would specify the default charset, user, group, file mode, and directory mode, to be used by filesystems that don't store this information, if it is not specified on the mount command line. This way you would set it in sysctl.conf(5). What do you guys think?
I'm all for fixing core issues/limitations rather than working around them. The thought had crossed my mind that maybe end-users should be able specify default options for mount_msdosfs across-the-board rather than just for autofs. As long as there are easy ways to customize these things and they're well-documented.
A sysctl may be the solution for some of the issues, but setting command-line flags via sysctl seems rather unconventional. If we do this through autofs, which is a daemon, I would probably use rc.conf, e.g. autofs_msdosfs_flags="-m=0660,-M0770" To modify behavior of a command like mount_msdosfs, a config file and/or env variable would seem more intuitive.
(In reply to Jason W. Bacon from comment #16) > autofs_msdosfs_flags="-m=0660,-M0770" I second this.
(In reply to Victor Sudakov from comment #17) If there's any resistance to hacking mount_*, this approach would be really easy to implement in special_media for now. I would document in the code that it might be preferable to do it in mount_msdosfs instead.
It's not about setting command-line arguments via sysctl; it's about setting a kernel parameter via sysctl instead of doing it via command line. Also, I don't see a point in making it msdosfs-specific, instead of a global knob that applies to all permissionless filesystems.
(In reply to Edward Tomasz Napierala from comment #19) Either way it seems a bit counterintuitive to me. I.e., sysctl is not a place I would think to look for a solution to this problem. Also, it's creating a redundant interface since the command-line flags already exist. Are there existing examples of sysctls that mirror command-line flags? If there are precedents for this sort of thing, I might be inclined to agree. I definitely agree that one set of controls for all permissionless FSs is the way to go. What other ones are there besides msdosfs?
Regarding the locale issue, it occurred to me that maybe mount_msdosfs should use LANG/LC_* from the env as a default. It may already be doing so. Looking at /usr/src/sbin/mount_msdosfs/mount_msdosfs.c, the -L flag merely calls setlocale(): case 'L': { const char *quirk = NULL; if (setlocale(LC_CTYPE, optarg) == NULL) err(EX_CONFIG, "%s", optarg); Victor: Have you tried setting LANG or LC_CTYPE globally, so it's set for the automountd process and inherited by mount_*? I'm not entirely sure that it's safe to set a non-default LANG for all root processes, but I'd like to know if setting it for automountd solves this issue. Maybe as a quick test you could manually start the daemon with service automountd stop env LANG=ru_RU.UTF-8 automountd [flags] As for the permissions issues, perhaps the mount directory should default to the ownership of /dev/console, which is set to the user currently running a session. I think this would be more useful than root:wheel. This still leaves some issues for multiuser installations, but I think allowing the local sysadmin to control mount options would take care of most of them.
(In reply to Jason W. Bacon from comment #21) > Victor: Have you tried setting LANG or LC_CTYPE globally Jason, I'm afraid you are not quite getting the point. There is the local charset which you can specify with -L or $LANG. That's correct but it's only a part of the matter. It's about how filenames are presented to the user. The other part of the matter is how filenames are encoded on the filesystem itself. Most often is's either CP866 or WINDOWS-1251. That's where -D comes into play, and you cannot set -D via locale.
(In reply to Victor Sudakov from comment #22) You're right, I did not fully understand the issue. Just throwing out some ideas. Thanks for the explanation.
This autofs thing is unusable for any practical purpose. Use sysutils/automount from ports for removable media, it works out of the box. This is probably the reason why noone is willing to fix autofs.