]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
fdescfs: add an option to return underlying file vnode on lookup
authorKonstantin Belousov <kib@FreeBSD.org>
Wed, 5 May 2021 22:53:20 +0000 (01:53 +0300)
committerKonstantin Belousov <kib@FreeBSD.org>
Fri, 4 Jun 2021 00:30:12 +0000 (03:30 +0300)
commitf9b1e711f0d8c27f2d29e7a8e6276947d37a6a22
treef906278e68ce5985d6c2742a941c326bfad39909
parenteae2ef5a010366c673ad912cae23b426ebb9a8a2
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
share/man/man5/fdescfs.5
sys/fs/fdescfs/fdesc.h
sys/fs/fdescfs/fdesc_vfsops.c
sys/fs/fdescfs/fdesc_vnops.c