10 #define rhdr r->ofcall
35 chat("attach(fid=%d,uname=\"%s\",aname=\"%s\",afid=\"%d\")...",
36 thdr.fid, thdr.uname, thdr.aname, thdr.afid);
39 root = xfile(r->fid, Clean);
44 root->xf = xf = getxfs(thdr.aname);
48 /* now attach root inode */
49 if( get_inode(root, EXT2_ROOT_INODE) < 0 )
52 r->fid->qid.type = QTDIR;
54 root->xf->rootqid = r->fid->qid;
55 root->pinbr = EXT2_ROOT_INODE;
57 rhdr.qid = r->fid->qid;
63 rclone(Fid *fid, Fid *newfid)
65 Xfile *of = xfile(fid, Asis);
66 Xfile *nf = xfile(newfid, Clean);
68 chat("clone(fid=%d,newfid=%d)...", fid->fid, newfid->fid);
75 Xfile *next = nf->next;
78 nf->fid = newfid->fid;
81 chat("%s\n", errno? xerrstr(errno) : "OK");
82 return errno ? xerrstr(errno) : 0;
85 rwalk1(Fid *fid, char *name, Qid *qid)
87 Xfile *f=xfile(fid, Asis);
90 chat("walk1(fid=%d,name=\"%s\")...", fid->fid, name);
96 if( !(fid->qid.type & QTDIR) ){
97 chat("qid.type=0x%x...", fid->qid.type);
101 if( name == 0 || name[0] == 0 || !strcmp(name, ".") ){
104 }else if( !strcmp(name, "..") ){
105 if( fid->qid.path == f->xf->rootqid.path ){
106 chat("walkup from root...");
110 if( get_inode(f, f->pinbr) < 0 )
112 if( f->pinbr == EXT2_ROOT_INODE ){
113 *qid = f->xf->rootqid;
114 f->pinbr = EXT2_ROOT_INODE;
116 *qid = (Qid){f->pinbr,0,QTDIR};
118 if( (nr = get_file(f, "..")) < 0 )
124 if( (nr = get_file(f, name)) < 0 )
126 if( get_inode(f, nr) < 0 )
128 *qid = (Qid){nr,0,0};
129 if( nr == EXT2_ROOT_INODE )
130 *qid = f->xf->rootqid;
131 else if( S_ISDIR(getmode(f)) )
133 /*strcpy(f->name, thdr.name);*/
140 chat("%s\n", xerrstr(Enonexist));
141 return xerrstr(Enonexist);
146 Xfile *f=xfile(r->fid, Asis);
148 chat("stat(fid=%d)...", thdr.fid);
153 dostat(r->fid->qid, f, &r->d);
160 Xfile *f=xfile(r->fid, Asis);
162 chat("wstat(fid=%d)...", thdr.fid);
176 chat("read(fid=%d,offset=%lld,count=%d)...",
177 thdr.fid, thdr.offset, thdr.count);
179 if ( !(f=xfile(r->fid, Asis)) )
181 if( r->fid->qid.type & QTDIR ){
182 nr = readdir(f, r->rbuf, thdr.offset, thdr.count);
184 nr = readfile(f, r->rbuf, thdr.offset, thdr.count);
188 chat("rcnt=%d...OK\n", nr);
201 chat("write(fid=%d,offset=%lld,count=%d)...",
202 thdr.fid, thdr.offset, thdr.count);
205 if (!(f=xfile(r->fid, Asis)) ){
209 if( !S_ISREG(getmode(f)) ){
213 nr = writefile(f, thdr.data, thdr.offset, thdr.count);
216 chat("rcnt=%d...OK\n", nr);
227 chat("destroy(fid=%d)\n", fid->fid);
236 chat("open(fid=%d,mode=%d)...", thdr.fid, thdr.mode);
239 f = xfile(r->fid, Asis);
245 if(thdr.mode & OTRUNC){
246 if( !S_ISREG(getmode(f)) ){
250 if(truncfile(f) < 0){
254 chat("f->qid=0x%8.8lux...", r->fid->qid.path);
255 rhdr.qid = r->fid->qid;
265 chat("create(fid=%d,name=\"%s\",perm=%uo,mode=%d)...",
266 thdr.fid, thdr.name, thdr.perm, thdr.mode);
269 if(strcmp(thdr.name, ".") == 0 || strcmp(thdr.name, "..") == 0){
273 f = xfile(r->fid, Asis);
278 if( strlen(thdr.name) > EXT2_NAME_LEN ){
279 chat("name too long ...");
286 if( thdr.perm & DMDIR ){
287 perm = (thdr.perm & ~0777) |
288 (getmode(f) & thdr.perm & 0777);
290 inr = create_dir(f, thdr.name, perm);
292 perm = (thdr.perm & (~0777|0111)) |
293 (getmode(f) & thdr.perm & 0666);
295 inr = create_file(f, thdr.name, perm);
301 /* fill with new inode */
303 if( get_inode(f, inr) < 0 ){
307 r->fid->qid = (Qid){inr, 0, 0};
308 if( S_ISDIR(getmode(f)) )
309 r->fid->qid.type |= QTDIR;
310 chat("f->qid=0x%8.8lux...", r->fid->qid.path);
311 rhdr.qid = r->fid->qid;
318 Xfile *f=xfile(r->fid, Asis);
320 chat("remove(fid=%d) ...", thdr.fid);
328 /* check permission here !!!!*/
337 .destroyfid = destroyfid,