Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NILFS tools fail with space in mountpoint. #22

Closed
will-ca opened this issue Apr 2, 2024 · 0 comments
Closed

NILFS tools fail with space in mountpoint. #22

will-ca opened this issue Apr 2, 2024 · 0 comments

Comments

@will-ca
Copy link

will-ca commented Apr 2, 2024

NILFS2 tools like lscp error when the mountpoint includes a space.

$ cd $(mktemp -d)
$ mkdir MountPoint Mount\ Point
$ truncate -s 1G Nilfs.iso
$ mkfs.nilfs2 Nilfs.iso 
mkfs.nilfs2 (nilfs-utils 2.2.9)
Start writing file system initial data to the device
       Blocksize:4096  Device:Nilfs.iso  Device Size:1073741824
File system initialization succeeded !! 

$ sudo mount Nilfs.iso MountPoint/
$ lscp
                 CNO        DATE     TIME  MODE  FLG      BLKCNT       ICNT
                   1  2024-04-02 05:13:41   cp    -            4          2
$ sudo umount MountPoint/

$ sudo mount Nilfs.iso Mount\ Point/
$ lscp
lscp: cannot open NILFS on device: No such file or directory

Checking /proc/mounts, it seems that the ("Space") character is escaped as \040.

As some distributions allow unprivileged users to mount USB storage devices at a path computed from the partition's name/label, which may include a space, this can happen without anybody knowingly/deliberately specifying a mountpoint with a space.

konis added a commit to konis/nilfs-utils that referenced this issue Apr 3, 2024
…ters

nilfs_find_fs(), called from nilfs_open(), parses "/proc/mounts" using its
own routines, but these parsing routines have a problem in that they
cannot handle escaped path strings.  For example, if the mount point path
name contains spaces, the search will fail.

This is causing errors when running lscp, lssu, and other nilfs tools.

Fix this issue by avoiding custom parsing and using standard mount table
access routines such as setmntent(), getmntent_r(), endmntent(), and
hasmntopt().

Closes: nilfs-dev/nilfs-utils#22
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
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

No branches or pull requests

1 participant