Blob


1 <head>
2 <title>9p-fid(3) - Plan 9 from User Space</title>
3 <meta content="text/html; charset=utf-8" http-equiv=Content-Type>
4 </head>
5 <body bgcolor=#ffffff>
6 <table border=0 cellpadding=0 cellspacing=0 width=100%>
7 <tr height=10><td>
8 <tr><td width=20><td>
9 <tr><td width=20><td><b>9P-FID(3)</b><td align=right><b>9P-FID(3)</b>
10 <tr><td width=20><td colspan=2>
11 <br>
12 <p><font size=+1><b>NAME </b></font><br>
14 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
16 Fid, Fidpool, allocfidpool, freefidpool, allocfid, closefid, lookupfid,
17 removefid, Req, Reqpool, allocreqpool, freereqpool, allocreq,
18 closereq, lookupreq, removereq &ndash; 9P fid, request tracking<br>
20 </table>
21 <p><font size=+1><b>SYNOPSIS </b></font><br>
23 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
25 <tt><font size=+1>#include &lt;u.h&gt;<br>
26 #include &lt;libc.h&gt;<br>
27 #include &lt;fcall.h&gt;<br>
28 #include &lt;thread.h&gt;<br>
29 #include &lt;9p.h&gt;<br>
31 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
33 typedef struct Fid<br>
34 {<br>
36 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
38 ulong fid;<br>
39 char &nbsp;&nbsp;&nbsp;omode; &nbsp;&nbsp;&nbsp;/* &#8722;1 if not open */<br>
40 char &nbsp;&nbsp;&nbsp;*uid;<br>
41 Qid &nbsp;&nbsp;&nbsp;&nbsp;qid;<br>
42 File &nbsp;&nbsp;&nbsp;*file;<br>
43 void &nbsp;&nbsp;&nbsp;*aux;<br>
45 </table>
46 </font></tt>
47 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
49 <i>...<br>
50 </i>
51 </table>
52 <tt><font size=+1>} Fid;<br>
54 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
56 typedef struct Req<br>
57 {<br>
59 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
61 ulong tag;<br>
62 Fcall ifcall;<br>
63 Fcall ofcall;<br>
64 Req &nbsp;&nbsp;&nbsp;&nbsp;*oldreq;<br>
65 void &nbsp;&nbsp;&nbsp;*aux;<br>
67 </table>
68 </font></tt>
69 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
71 <i>...<br>
72 </i>
73 </table>
74 <tt><font size=+1>} Req;<br>
76 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
78 Fidpool* allocfidpool(void (*destroy)(Fid*))<br>
79 void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;freefidpool(Fidpool *p)<br>
80 Fid* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;allocfid(Fidpool *p, ulong fid)<br>
81 Fid* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lookupfid(Fidpool *p, ulong fid)<br>
82 void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;closefid(Fid *f)<br>
83 void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;removefid(Fid *f)<br>
85 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
87 Reqpool* allocreqpool(void (*destroy)(Req*))<br>
88 void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;freereqpool(Reqpool *p)<br>
89 Req* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;allocreq(Reqpool *p, ulong tag)<br>
90 Req* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lookupreq(Reqpool *p, ulong tag)<br>
91 void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;closereq(Req *f)<br>
92 void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;removereq(Req *r)<br>
93 </font></tt>
94 </table>
95 <p><font size=+1><b>DESCRIPTION </b></font><br>
97 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
99 These routines provide management of <tt><font size=+1>Fid</font></tt> and <tt><font size=+1>Req</font></tt> structures from
100 <tt><font size=+1>Fidpool</font></tt>s and <tt><font size=+1>Reqpool</font></tt>s. They are primarily used by the 9P server
101 loop described in <a href="../man3/9p.html"><i>9p</i>(3)</a>.
102 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
104 <tt><font size=+1>Fid</font></tt> structures are intended to represent active fids in a 9P connection,
105 as <tt><font size=+1>Chan</font></tt> structures do in the Plan 9 kernel. The <tt><font size=+1>fid</font></tt> element is
106 the integer fid used in the 9P connection. <tt><font size=+1>Omode</font></tt> is the mode under
107 which the fid was opened, or <tt><font size=+1>&#8722;1</font></tt> if this fid has not been opened
108 yet. Note that in addition to the values <tt><font size=+1>OREAD</font></tt>,
109 <tt><font size=+1>OWRITE</font></tt>, and <tt><font size=+1>ORDWR</font></tt>, <tt><font size=+1>omode</font></tt> can contain the various flags permissible
110 in an open call. To ignore the flags, use <tt><font size=+1>omode&amp;OMASK</font></tt>. <tt><font size=+1>Omode</font></tt> should
111 not be changed by the client. The fid derives from a successful
112 authentication by <tt><font size=+1>uid</font></tt>. <tt><font size=+1>Qid</font></tt> contains the qid returned in the last
113 successful <tt><font size=+1>walk</font></tt> or <tt><font size=+1>create</font></tt> transaction
114 involving the fid. In a file tree-based server, the <tt><font size=+1>Fid</font></tt>&#8217;s <tt><font size=+1>file</font></tt>
115 element points at a <tt><font size=+1>File</font></tt> structure (see <a href="../man3/9p-file.html"><i>9p-file</i>(3)</a>) corresponding
116 to the fid. The <tt><font size=+1>aux</font></tt> member is intended for use by the client to
117 hold information specific to a particular <tt><font size=+1>Fid</font></tt>. With the exception
118 of <tt><font size=+1>aux</font></tt>, these elements should be treated as read-only by
119 the client.
120 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
122 <i>Allocfidpool</i> creates a new <tt><font size=+1>Fidpool</font></tt>. <i>Freefidpool</i> destroys such
123 a pool. <i>Allocfid</i> returns a new <tt><font size=+1>Fid</font></tt> whose fid number is <i>fid</i>. There
124 must not already be an extant <tt><font size=+1>Fid</font></tt> with that number in the pool.
125 Once a <tt><font size=+1>Fid</font></tt> has been allocated, it can be looked up by fid number
126 using <i>lookupfid</i>. <tt><font size=+1>Fid</font></tt>s are reference counted: both
127 <i>allocfid</i> and <i>lookupfid</i> increment the reference count on the <tt><font size=+1>Fid</font></tt>
128 structure before returning. When a reference to a <tt><font size=+1>Fid</font></tt> is no longer
129 needed, <i>closefid</i> should be called to note the destruction of the
130 reference. When the last reference to a <tt><font size=+1>Fid</font></tt> is removed, if <i>destroy</i>
131 (supplied when creating the fid pool) is not zero, it is
132 called with the <tt><font size=+1>Fid</font></tt> as a parameter. It should perform whatever
133 cleanup is necessary regarding the <tt><font size=+1>aux</font></tt> element. <i>Removefid</i> is equivalent
134 to <i>closefid</i> but also removes the <tt><font size=+1>Fid</font></tt> from the pool. Note that
135 due to lingering references, the return of <i>removefid</i> may not mean
136 that <i>destroy</i> has been called.
137 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
139 <i>Allocreqpool</i>, <i>freereqpool</i>, <i>allocreq</i>, <i>lookupreq</i>, <i>closereq</i>, and
140 <i>removereq</i> are analogous but operate on <tt><font size=+1>Reqpool</font></tt>s and <tt><font size=+1>Req</font></tt> structures.<br>
142 </table>
143 <p><font size=+1><b>SOURCE </b></font><br>
145 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
147 <tt><font size=+1>/usr/local/plan9/src/lib9p<br>
148 </font></tt>
149 </table>
150 <p><font size=+1><b>SEE ALSO </b></font><br>
152 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
154 <a href="../man3/9p.html"><i>9p</i>(3)</a>, <a href="../man3/9p-file.html"><i>9p-file</i>(3)</a><br>
156 </table>
158 <td width=20>
159 <tr height=20><td>
160 </table>
161 <!-- TRAILER -->
162 <table border=0 cellpadding=0 cellspacing=0 width=100%>
163 <tr height=15><td width=10><td><td width=10>
164 <tr><td><td>
165 <center>
166 <a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a>
167 </center>
168 </table>
169 <!-- TRAILER -->
170 </body></html>