HomeFreeBSD

fdescfs: add an option to return underlying file vnode on lookup

Description

fdescfs: add an option to return underlying file vnode on lookup

The 'nodup' option forces fdescfs to return real vnode behind file
descriptor instead of the fdescfs fd vnode, on lookup. The end result
is that e.g. stat("/dev/fd/3") returns the stat data for the underlying
vnode, if any. Similarly, fchdir(2) works in the expected way.

For open(2), if applied over file descriptor opened with O_PATH, it
effectively re-open that vnode into normal file descriptor which has the
specified access mode, assuming the current vnode permissions allow it.

If the file descriptor does not reference vnode, the behavior is unchanged.

This is done by a mount option, because permission check on open(2) breaks
established fdescfs open semantic of dup(2)-ing the descriptor. So it
is not suitable for /dev/fd mount.

Tested by: Andrew Walker <awalker@ixsystems.com>
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30140

Details

Provenance
kibAuthored on May 5 2021, 10:53 PM
Reviewer
markj
Differential Revision
D30140: fdescfs: add an option to return underlying file vnode on lookup
Parents
rGeae2ef5a0103: smartpqi: Remove stray declaration
Branches
Unknown
Tags
Unknown