1

I tried to contrive a test case using the FUSE filesystem sshfs. My idea was sshfs would be a bit easier for developers to test with, compared to the original issue which involved NFS. But my idea did not quite work how I expected.

What is happening here?

$ mkdir /tmp/alan
$ sudo mkdir /root/mnt
$ sudo sshfs alan@localhost:/tmp/alan /root/mnt
$ mkdir /tmp/alan/mnt
$ sudo mount --bind /root/mnt/mnt /root/mnt/mnt
$ chmod a-rwx /tmp/alan
$ findmnt | grep mnt
  /root/mnt        alan@localhost:/tmp/alan  fuse.sshfs  ...
    /root/mnt/mnt  alan@localhost:/tmp/alan  fuse.sshfs  ...

$ mount -oremount,bind,ro /root/mnt/mnt
mount: /root/mnt/mnt: cannot mount (null) read-only.

$ findmnt | grep mnt
  /root/mnt        alan@localhost:/tmp/alan  fuse.sshfs  ...

The sub-mount vanished.

If I re-run this and prefix the mount -oremount command with sudo strace -e trace=mount, it shows that system call fails with "Permission denied", so that part seemed to be working as expected.

mount("none", "/root/mnt/mnt", 0x55b13233d620, MS_MGC_VAL|MS_RDONLY|MS_REMOUNT|MS_BIND, NULL) = -1 EACCESS (Permission denied)

1 Answer 1

1

You can replace the mount -oremount command with sudo ls /root/mnt/mnt. You get the same EACCESS ("Permission denied") error, and the mount point still disappears.

ls /tmp/alan/mnt would also fail due to EACCESS. Notice that the error will be EACCESS even if /tmp/alan/mnt had also been removed, or replaced with a non-directory file.

Normally, if /tmp/alan/mnt had been removed or replaced with a non-directory, the sub-mount /root/mnt/mnt will no longer be valid, and it will be removed automatically. In this case, when the kernel asks sshfs if /root/mnt/mnt still exists as a directory, sshfs just tells it "Permission denied". The kernel treats this as a failure, just like "No such file or directory".

I don't know if that's exactly what happens.

Also sub-mounts don't seem to vanish when ls on the sub-mount returns ENOTCONN "Transport endpoint is not connected". This error happens when you kill the FUSE process for the parent mount. (See https://github.com/systemd/systemd/issues/9872 )

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .