FDESCFS(4)
πΈ NAME πΈ
okay bestie, say hi to fdescfs(4) β the file-descriptor file system. this is a kernel interfaces manual page, and honestly it's giving main character energy for something that lives in the kernel. π
π¦ SYNOPSIS π¦
fdescfs /dev/fd fdescfs rw 0 0
β¨ DESCRIPTION β¨
so fdescfs is the file-descriptor file system, and it gives you access to the per-process file descriptor namespace right inside the global file system namespace. the conventional mount point is /dev/fd. no cap. π«Ά
The file system's contents show up as a list of numbered files, and those correspond to the open files of the process that's reading the directory. the files /dev/fd/0 through /dev/fd/# refer to file descriptors that you can access through the file system. iconic behavior, honestly. β¨
The following mount options can be used when mounting an fdescfs filesystem:
nodupβ for file descriptors referencing vnodes, instead of thedup(2)semantic described above, this implements re-opening of the referenced vnode. see below for more details. πlinrdlnkβ reports the type of thefdescfsvnode asVLNKinstead of the FreeBSD traditionalVCHR. forlinux(4)ABI compatibility, mount anfdescfsvolume with thelinrdlnkoption. π§rdlnkβ treatsfdescfsvnodes as symbolic links consistently; in particular, it follows the resolved name for 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. lowkey powerful. π₯
For an 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, then this call:
fd = open("/dev/fd/0", mode);
and this 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. periodt. π
For an fdescfs mounted with the nodup option, and a file descriptor referencing a vnode, this call:
fd = open("/dev/fd/0", mode);
reopens the referenced vnode with the specified mode. in other words, that 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 an fdescfs mount with the nodup option lets you convert it to a regularly opened file, assuming that the current permissions allow the requested mode. fr fr, permissions still run this. π
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 an 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. history really said "let there be fd files." π
π 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. shoutout to the OGs. π«Ά
mwah π β source/version: Debian; date: Jul 11, 2023; manual: FDESCFS(4). bye bestie, go mount something cute. πΈ
π¦ where this page comes from
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- 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