2 <title>9p-fid(3) - Plan 9 from User Space</title>
3 <meta content="text/html; charset=utf-8" http-equiv=Content-Type>
6 <table border=0 cellpadding=0 cellspacing=0 width=100%>
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>
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 – 9P fid, request tracking<br>
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 <u.h><br>
26 #include <libc.h><br>
27 #include <fcall.h><br>
28 #include <thread.h><br>
29 #include <9p.h><br>
31 <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
33 typedef struct Fid<br>
36 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
39 char omode; /* −1 if not open */<br>
40 char *uid;<br>
41 Qid qid;<br>
42 File *file;<br>
43 void *aux;<br>
47 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
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>
59 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
64 Req *oldreq;<br>
65 void *aux;<br>
69 <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
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 freefidpool(Fidpool *p)<br>
80 Fid* allocfid(Fidpool *p, ulong fid)<br>
81 Fid* lookupfid(Fidpool *p, ulong fid)<br>
82 void closefid(Fid *f)<br>
83 void 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 freereqpool(Reqpool *p)<br>
89 Req* allocreq(Reqpool *p, ulong tag)<br>
90 Req* lookupreq(Reqpool *p, ulong tag)<br>
91 void closereq(Req *f)<br>
92 void removereq(Req *r)<br>
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>−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&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>’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
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>
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>
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>
162 <table border=0 cellpadding=0 cellspacing=0 width=100%>
163 <tr height=15><td width=10><td><td width=10>
166 <a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a>