Bug 291027 - mount(8) may produce invalid fstab(5) output
Summary: mount(8) may produce invalid fstab(5) output
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 14.3-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-11-15 09:51 UTC by Markus Stoff
Modified: 2025-11-15 09:55 UTC (History)
0 users

See Also:


Attachments
Suggested fix (1.85 KB, patch)
2025-11-15 09:51 UTC, Markus Stoff
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Stoff 2025-11-15 09:51:53 UTC
Created attachment 265421 [details]
Suggested fix

Background:

fstab(5) expects the first two fields (fs_spec and fs_file i.e. the device and the mountpoint) to escape spaces and tabs. The contents of these two fields are decoded using strunvis(3).

Problem:

When calling mount(8) with -p (to print mount information in fstab(5) format), spaces and tabs in the first two fields are not escaped and can thus not be distinguished from field separators.

Solution:

Use vis(3) to encode the first two fields when producing output in fstab(5) format (i.e. when called with -p).

How to reproduce:

  # zfs create 'tank/test with spaces'
  # mount -p
  zroot/test with spaces  /zroot/test with spaces zfs     rw,noatime,nfsv4acls    0 0

Expected:

  # zfs create 'tank/test with spaces'
  # mount -p
  tank/test\swith\sspaces /zroot/test\swith\sspaces zfs  rw,noatime,nfsv4acls    0 0

Please see the attached diff for a possible fix.
Comment 1 Markus Stoff 2025-11-15 09:55:51 UTC
Sorry for the copy and paste error in the how to reproduce section. It should of course read:

How to reproduce:

  # zfs create 'tank/test with spaces'
  # mount -p
  tank/test with spaces  /tank/test with spaces zfs     rw,noatime,nfsv4acls    0 0

Expected:

  # zfs create 'tank/test with spaces'
  # mount -p
  tank/test\swith\sspaces /tank/test\swith\sspaces zfs  rw,noatime,nfsv4acls    0 0