summaryrefslogtreecommitdiff
path: root/static/freebsd/man4/fdescfs.4 3.html
blob: 9e0f124a159f68db6d972b0d95ca55f2b1f68f30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<table class="head">
  <tr>
    <td class="head-ltitle">FDESCFS(4)</td>
    <td class="head-vol">Device Drivers Manual</td>
    <td class="head-rtitle">FDESCFS(4)</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">fdescfs</code> &#x2014;
    <span class="Nd">file-descriptor file system</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<div class="Bd Li">
<pre>fdescfs	/dev/fd	fdescfs rw 0 0</pre>
</div>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">The file-descriptor file system, or
    <code class="Nm">fdescfs</code>, provides access to the per-process file
    descriptor namespace in the global file system namespace. The conventional
    mount point is <span class="Pa">/dev/fd</span>.</p>
<p class="Pp">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 <span class="Pa">/dev/fd/0</span> through
    <span class="Pa">/dev/fd/#</span> refer to file descriptors which can be
    accessed through the file system.</p>
<p class="Pp">The following mount options can be used when mounting
    <code class="Nm">fdescfs</code> filesystem:</p>
<dl class="Bl-tag">
  <dt id="nodup"><a class="permalink" href="#nodup"><code class="Cm">nodup</code></a></dt>
  <dd>For file descriptors referencing vnodes, instead of the
      <a class="Xr">dup(2)</a> semantic described above, implement re-opening of
      the referenced vnode. See below for more details.</dd>
  <dt id="linrdlnk"><a class="permalink" href="#linrdlnk"><code class="Cm">linrdlnk</code></a></dt>
  <dd>Report the type of the <code class="Nm">fdescfs</code> vnode as
      <code class="Dv">VLNK</code> instead of <span class="Ux">FreeBSD</span>
      traditional <code class="Dv">VCHR</code>. For <a class="Xr">linux(4)</a>
      ABI compatibility mount <code class="Nm">fdescfs</code> volume with the
      <code class="Cm">linrdlnk</code> option.</dd>
  <dt id="rdlnk"><a class="permalink" href="#rdlnk"><code class="Cm">rdlnk</code></a></dt>
  <dd>Treat <code class="Nm">fdescfs</code> vnodes as symbolic links
      consistently, in particular, follow the resolved name for the name
      lookups. This option is strictly stronger than the
      <code class="Cm">linrdlnk</code> option, it changes not only the type
      returned by <a class="Xr">stat(2)</a>, but also causes the
      <code class="Nm">fdescfs</code> files to behave as symlinks.</dd>
</dl>
<p class="Pp">For <code class="Nm">fdescfs</code> mounted without the
    <code class="Cm">nodup</code> 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:</p>
<div class="Bd Pp Bd-indent Li">
<pre>fd = open(&quot;/dev/fd/0&quot;, mode);</pre>
</div>
<p class="Pp">and the call:</p>
<div class="Bd Pp Bd-indent Li">
<pre>fd = fcntl(0, F_DUPFD, 0);</pre>
</div>
<p class="Pp">are equivalent. Flags to the <a class="Xr">open(2)</a> call other
    than <code class="Dv">O_RDONLY</code>, <code class="Dv">O_WRONLY</code> and
    <code class="Dv">O_RDWR</code> are ignored.</p>
<p class="Pp">For <code class="Nm">fdescfs</code> mounted with the
    <code class="Cm">nodup</code> option, and file descriptor referencing a
    vnode, the call:</p>
<div class="Bd Pp Bd-indent Li">
<pre>fd = open(&quot;/dev/fd/0&quot;, mode);</pre>
</div>
<p class="Pp" id="open">reopens the referenced vnode with the specified
    <var class="Fa">mode</var>. In other words, the
    <a class="permalink" href="#open"><code class="Fn">open</code></a>() call
    above is equivalent to</p>
<div class="Bd Pp Bd-indent Li">
<pre>fd = openat(0, &quot;&quot;, O_EMPTY_PATH, mode);</pre>
</div>
<p class="Pp" id="open~2">In particular, if the file descriptor was opened with
    the <code class="Dv">O_PATH</code> flag, then either
    <code class="Dv">O_EMPTY_PATH</code> or
    <a class="permalink" href="#open~2"><code class="Fn">open</code></a>() over
    <code class="Nm">fdescfs</code> mount with <code class="Cm">nodup</code>
    option allows one to convert it to a regularly opened file, assuming that
    the current permissions allow the requested <var class="Fa">mode</var>.</p>
<p class="Pp" id="Note:"><a class="permalink" href="#Note:"><i class="Em">Note:</i></a>
    <span class="Pa">/dev/fd/0</span>, <span class="Pa">/dev/fd/1</span> and
    <span class="Pa">/dev/fd/2</span> files are created by default when devfs
    alone is mounted. <code class="Nm">fdescfs</code> creates entries for all
    file descriptors opened by the process.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="FILES"><a class="permalink" href="#FILES">FILES</a></h1>
<dl class="Bl-tag Bl-compact">
  <dt><span class="Pa">/dev/fd/#</span></dt>
  <dd style="width: auto;">&#x00A0;</dd>
</dl>
</section>
<section class="Sh">
<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
<p class="Pp">To mount a <code class="Nm">fdescfs</code> volume located on
    <span class="Pa">/dev/fd</span>:</p>
<p class="Pp"></p>
<div class="Bd Bd-indent"><code class="Li">mount -t fdescfs none
  /dev/fd</code></div>
<p class="Pp">For <a class="Xr">linux(4)</a> ABI compatibility:</p>
<p class="Pp"></p>
<div class="Bd Bd-indent"><code class="Li">mount -t fdescfs -o linrdlnk none
  /compat/linux/dev/fd</code></div>
<p class="Pp">For substitute of <code class="Dv">O_EMPTY_PATH</code> flag
  use:</p>
<p class="Pp"></p>
<div class="Bd Bd-indent"><code class="Li">mount -t fdescfs -o nodup none
  /dev/fdpath</code></div>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
  ALSO</a></h1>
<p class="Pp"><a class="Xr">devfs(4)</a>, <a class="Xr">mount(8)</a></p>
</section>
<section class="Sh">
<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
<p class="Pp">The <code class="Nm">fdescfs</code> file system first appeared in
    <span class="Ux">4.4BSD</span>. The <code class="Nm">fdescfs</code> manual
    page first appeared in <span class="Ux">FreeBSD 2.2</span>.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
<p class="Pp">The <code class="Nm">fdescfs</code> manual page was written by
    <span class="An">Mike Pritchard</span>
    &lt;<a class="Mt" href="mailto:mpp@FreeBSD.org">mpp@FreeBSD.org</a>&gt;, and
    was based on the manual page written by <span class="An">Jan-Simon
    Pendry</span>.</p>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date">July 11, 2023</td>
    <td class="foot-os">FreeBSD 15.0</td>
  </tr>
</table>