FDESCFS(5)
π fdescfs(5) β file-descriptor file system π
File Formats Manual, section 5 β yes bestie, we are literally in the file formats manual. π
πΈ NAME πΈ
fdescfs β file-descriptor file system.
β¨ SYNOPSIS β¨
fdescfs /dev/fd fdescfs rw 0 0
π¦ DESCRIPTION π¦
Okay so the file-descriptor file system, aka fdescfs, gives you access to the per-process file descriptor namespace in the global file system namespace. The conventional mount point is /dev/fd.
The file systemβs contents appear as a list of numbered files which correspond to the open files of the process reading the directory. The files /dev/fd/0 through /dev/fd/# refer to file descriptors which can be accessed through the file system.
π Mount options π
The following mount options can be used when mounting fdescfs filesystem:
nodupβ for file descriptors referencing vnodes, instead of thedup(2)semantic described above, implement re-opening of the referenced vnode. See below for more details.linrdlnkβ report the type of thefdescfsvnode asVLNKinstead of FreeBSD traditionalVCHR. Forlinux(4)ABI compatibility mountfdescfsvolume with thelinrdlnkoption.rdlnkβ treatfdescfsvnodes as symbolic links consistently, in particular, follow the resolved name for the name lookups. This option is strictly stronger than thelinrdlnkoption, it changes not only the type returned bystat(2), but also causes thefdescfsfiles to behave as symlinks.
For fdescfs mounted without the nodup mount option, if the file descriptor is open and the mode the file is being opened with is a subset of the mode of the existing descriptor, the call:
fd = open("/dev/fd/0", mode);
and the call:
fd = fcntl(0, F_DUPFD, 0);
are equivalent. Flags to the open(2) call other than O_RDONLY, O_WRONLY and O_RDWR are ignored.
For fdescfs mounted with the nodup option, and file descriptor referencing a vnode, the call:
fd = open("/dev/fd/0", mode);
reopens the referenced vnode with the specified mode. In other words, the open() call above is equivalent to
fd = openat(0, "", O_EMPTY_PATH, mode);
In particular, if the file descriptor was opened with the O_PATH flag, then either O_EMPTY_PATH or open() over fdescfs mount with nodup option allows one to convert it to a regularly opened file, assuming that the current permissions allow the requested mode.
Note:/dev/fd/0,/dev/fd/1and/dev/fd/2files are created by default whendevfsalone is mounted.fdescfscreates entries for all file descriptors opened by the process. π«Ά
π FILES π
/dev/fd/#
π EXAMPLES π
To mount a fdescfs volume located on /dev/fd:
mount -t fdescfs none /dev/fd
For linux(4) ABI compatibility:
mount -t fdescfs -o linrdlnk none /compat/linux/dev/fd
For substitute of the O_EMPTY_PATH flag use:
mount -t fdescfs -o nodup none /dev/fdpath
π SEE ALSO π
π HISTORY π
The fdescfs file system first appeared in 4.4BSD. The fdescfs manual page first appeared in FreeBSD 2.2.
π§ AUTHORS π§
The fdescfs manual page was written by Mike Pritchard <mpp@FreeBSD.org>, and was based on the manual page written by Jan-Simon Pendry.
Thatβs the whole page, bestie β source/version tag: Debian; date: Jul 11, 2023. Periodt. πβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- Copyright (c) 2021 The FreeBSD Foundation
- Copyright (c) 1996 Mike Pritchard <mpp@FreeBSD.org>. All rights reserved
- Copyright (c) 1992, 1993, 1994 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms