Blob
1 .TH 9P-FID 32 .SH NAME3 Fid, Fidpool, allocfidpool, freefidpool, allocfid, closefid, lookupfid, removefid,4 Req, Reqpool, allocreqpool, freereqpool, allocreq, closereq, lookupreq, removereq \- 9P fid, request tracking5 .SH SYNOPSIS6 .ft L7 .nf8 #include <u.h>9 #include <libc.h>10 #include <fcall.h>11 #include <thread.h>12 #include <9p.h>13 .fi14 .PP15 .ft L16 .nf17 .ta \w'\fL 'u +\w'\fLulong 'u18 typedef struct Fid19 {20 ulong fid;21 char omode; /* -1 if not open */22 char *uid;23 Qid qid;24 File *file;25 void *aux;26 \fI...\fP27 } Fid;28 .fi29 .PP30 .ft L31 .nf32 .ta \w'\fL 'u +\w'\fLulong 'u33 typedef struct Req34 {35 ulong tag;36 Fcall ifcall;37 Fcall ofcall;38 Req *oldreq;39 void *aux;40 \fI...\fP41 } Req;42 .fi43 .PP44 .ft L45 .nf46 .ta \w'\fLFidpool* 'u47 Fidpool* allocfidpool(void (*destroy)(Fid*))48 void freefidpool(Fidpool *p)49 Fid* allocfid(Fidpool *p, ulong fid)50 Fid* lookupfid(Fidpool *p, ulong fid)51 void closefid(Fid *f)52 void removefid(Fid *f)53 .fi54 .PP55 .ft L56 .nf57 .ta \w'\fLReqpool* 'u58 Reqpool* allocreqpool(void (*destroy)(Req*))59 void freereqpool(Reqpool *p)60 Req* allocreq(Reqpool *p, ulong tag)61 Req* lookupreq(Reqpool *p, ulong tag)62 void closereq(Req *f)63 void removereq(Req *r)64 .fi65 .SH DESCRIPTION66 These routines provide management of67 .B Fid68 and69 .B Req70 structures from71 .BR Fidpool s72 and73 .BR Reqpool s.74 They are primarily used by the 9P server loop75 described in76 .IR 9p (3).77 .PP78 .B Fid79 structures are intended to represent80 active fids in a 9P connection, as81 .B Chan82 structures do in the Plan 9 kernel.83 The84 .B fid85 element is the integer fid used in the 9P86 connection.87 .B Omode88 is the mode under which the fid was opened, or89 .B -190 if this fid has not been opened yet.91 Note that in addition to the values92 .BR OREAD ,93 .BR OWRITE ,94 and95 .BR ORDWR ,96 .B omode97 can contain the various flags permissible in98 an open call.99 To ignore the flags, use100 .BR omode&OMASK .101 .B Omode102 should not be changed by the client.103 The fid derives from a successful authentication by104 .BR uid .105 .B Qid106 contains the qid returned in the last successful107 .B walk108 or109 .B create110 transaction involving the fid.111 In a file tree-based server, the112 .BR Fid 's113 .B file114 element points at a115 .B File116 structure117 (see118 .IR 9p-file (3))119 corresponding to the fid.120 The121 .B aux122 member is intended for use by the123 client to hold information specific to a particular124 .BR Fid .125 With the exception of126 .BR aux ,127 these elements should be treated128 as read-only by the client.129 .PP130 .I Allocfidpool131 creates a new132 .BR Fidpool .133 .I Freefidpool134 destroys such a pool.135 .I Allocfid136 returns a new137 .B Fid138 whose fid number is139 .IR fid .140 There must not already be an extant141 .B Fid142 with that number in the pool.143 Once a144 .B Fid145 has been allocated, it can be looked up by146 fid number using147 .IR lookupfid .148 .BR Fid s149 are reference counted: both150 .I allocfid151 and152 .I lookupfid153 increment the reference count on the154 .B Fid155 structure before156 returning.157 When a reference to a158 .B Fid159 is no longer needed,160 .I closefid161 should be called to note the destruction of the reference.162 When the last reference to a163 .B Fid164 is removed, if165 .I destroy166 (supplied when creating the fid pool)167 is not zero, it is called with the168 .B Fid169 as a parameter.170 It should perform whatever cleanup is necessary171 regarding the172 .B aux173 element.174 .I Removefid175 is equivalent to176 .I closefid177 but also removes the178 .B Fid179 from the pool.180 Note that due to lingering references,181 the return of182 .I removefid183 may not mean that184 .I destroy185 has been called.186 .PP187 .IR Allocreqpool ,188 .IR freereqpool ,189 .IR allocreq ,190 .IR lookupreq ,191 .IR closereq ,192 and193 .I removereq194 are analogous but195 operate on196 .BR Reqpool s197 and198 .B Req199 structures.200 .SH SOURCE201 .B \*9/src/lib9p202 .SH SEE ALSO203 .IR 9p (3),204 .IR 9p-file (3)