Skip to content

libmount: separate fstype from mounttype, add config file support - #4583

Open
karelzak wants to merge 6 commits into
util-linux:masterfrom
karelzak:PR/libmount-mounttype
Open

libmount: separate fstype from mounttype, add config file support#4583
karelzak wants to merge 6 commits into
util-linux:masterfrom
karelzak:PR/libmount-mounttype

Conversation

@karelzak

Copy link
Copy Markdown
Collaborator

Summary

  • Separate filesystem type (fstype) from kernel driver name (mounttype) in libmount, so helper lookup (/sbin/mount.<fstype>) uses the original detected name while mount syscalls use the configured driver name.
  • Add /etc/mount/fs.d/<type>.conf config file support with standard three-tier priority (/etc > /run > /usr/lib) for mounttype overrides.
  • New public API: mnt_config_get_value() for reading per-filesystem configuration.
  • Document the new feature in mount(8) man page.

Fixes the problem where ul_fstype_to_mounttype() overwrote fstype with driver name, breaking helper search (e.g., searching for /sbin/mount.ntfs3 instead of /sbin/mount.ntfs).

Example config (/etc/mount/fs.d/ntfs.conf):

mounttype = ntfs3

Addresses: #3618
Addresses: #4307

@masatake

Copy link
Copy Markdown
Member

No testcase?

@karelzak

Copy link
Copy Markdown
Collaborator Author

Not yet.

@karelzak
karelzak marked this pull request as draft August 27, 2026 08:09
Comment thread tests/ts/libmount/config Dismissed
Comment thread libmount/src/config.c Dismissed
Separate the on-disk filesystem type (fstype, e.g. "ntfs") from the
kernel FS driver name (mounttype, e.g. "ntfs3"). Previously,
ul_fstype_to_mounttype() completely overwrote the fstype with the
driver name, causing helper lookup to search for /sbin/mount.<mounttype>
instead of /sbin/mount.<fstype>.

Now fstype and mounttype are stored separately in struct libmnt_fs:
 - fstype is used for helper search (/sbin/mount.<fstype>) and
   user-facing display
 - mounttype is used for mount(2) and fsopen() syscalls

The mounttype mapping only applies to auto-detected types. When the
user explicitly specifies a type via -t or fstab, it is used as-is
for both helper search and the syscall -- no remapping.

By default, no fstype-to-mounttype mapping is defined. Use
--with-ntfs-mounttype=<type> (or -Dntfs-mounttype=<type>) to define
a compile-time mapping for NTFS.

Addresses: util-linux#3618
Addresses: util-linux#4307

Signed-off-by: Karel Zak <kzak@redhat.com>
@karelzak
karelzak force-pushed the PR/libmount-mounttype branch from c1f7746 to 242b254 Compare August 27, 2026 10:46
Comment thread libmount/src/config.c Dismissed
Add /etc/mount/fs.d/<fstype>.conf config file support to override the
kernel driver name (mounttype) for auto-detected filesystem types.

The config file uses simple "key = value" format:

  # /etc/mount/fs.d/ntfs.conf
  mounttype = ntfs3

The config file lookup uses ul_configs_file_list() with standard
three-tier priority (admin > runtime > vendor):

  /etc/mount/fs.d/<fstype>.conf
  /run/mount/fs.d/<fstype>.conf
  /usr/lib/mount/fs.d/<fstype>.conf

Priority for mounttype resolution:
  config file > hardcoded ul_fstype_to_mounttype() > no remapping

Config values are cached on the mount context so each fs.d/<name>
is parsed only once per context lifetime.

Addresses: util-linux#3618
Addresses: util-linux#4307

Signed-off-by: Karel Zak <kzak@redhat.com>
Document the new /etc/mount/fs.d/<type>.conf config file support
in the mount(8) man page. Add a new FILESYSTEM TYPE CONFIGURATION
section, a cross-reference from -t option description, and a FILES
entry.

Signed-off-by: Karel Zak <kzak@redhat.com>
Move the compile-time ntfs mounttype mapping into the config cache as
a built-in default (lowest priority), making mnt_config_get_value() the
single lookup point for mounttype. This eliminates ul_fstype_to_mounttype()
from mount, umount, findmnt-verify and removes it from mountutils.h.

Signed-off-by: Karel Zak <kzak@redhat.com>
Add TEST_PROGRAM to config.c and a test script exercising
mnt_config_get_value() with subtests for basic reading, missing
keys, comments, etc/usr priority, multiple keys, and the
CONFIG_UL_NTFS_MOUNTTYPE built-in default.

Signed-off-by: Karel Zak <kzak@redhat.com>
@karelzak
karelzak force-pushed the PR/libmount-mounttype branch from 242b254 to aece143 Compare August 27, 2026 10:57
@karelzak
karelzak marked this pull request as ready for review August 27, 2026 10:57
Create a config file in /run/mount/fs.d/ with a fake mounttype,
attempt to mount an ext2 device, and verify that mount(8) reports
the configured (non-existent) kernel driver name in the error.

Skip on platforms without fsopen() to avoid unstable errno
differences with legacy mount(2).

Signed-off-by: Karel Zak <kzak@redhat.com>
@karelzak
karelzak force-pushed the PR/libmount-mounttype branch from aece143 to 8bdb001 Compare August 27, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants