commit - 2aa7d3036738bc548cfe6d8d83ff45cb1cb9c8c7
commit + 59518849d81a71284b90513f6ba76770b42ce32b
blob - a7bf1b9e923328834fcc1ca47ccf889dd17bc6c1
blob + 1a641d129a60d7f8c1fddabc2b37d1c577d56642
--- src/lib9pclient/fs.c
+++ src/lib9pclient/fs.c
static int _fsgettag(Mux*, void*);
static int _fssettag(Mux*, void*, uint);
+int chatty9pclient;
+
enum
{
CFidchunk = 32
fsinit(int fd)
{
CFsys *fs;
-
+ int n;
+
fmtinstall('F', fcallfmt);
fmtinstall('D', dirfmt);
fmtinstall('M', dirmodefmt);
fs->iorecv = ioproc();
fs->iosend = ioproc();
muxinit(&fs->mux);
+
+ strcpy(fs->version, "9P2000");
+ if((n = fsversion(fs, 8192, fs->version, sizeof fs->version)) < 0){
+ _fsunmount(fs);
+ return nil;
+ }
+ fs->msize = n;
return fs;
}
CFsys*
fsmount(int fd, char *aname)
{
- int n;
CFsys *fs;
CFid *fid;
fs = fsinit(fd);
if(fs == nil)
return nil;
- strcpy(fs->version, "9P2000");
- if((n = fsversion(fs, 8192, fs->version, sizeof fs->version)) < 0){
- Error:
- fs->fd = -1;
- fsunmount(fs);
- return nil;
- }
- fs->msize = n;
- if((fid = fsattach(fs, nil, getuser(), aname)) == nil)
- goto Error;
+ if((fid = fsattach(fs, nil, getuser(), aname)) == nil){
+ _fsunmount(fs);
+ return nil;
+ }
fssetroot(fs, fid);
return fs;
+}
+
+void
+_fsunmount(CFsys *fs)
+{
+ fs->fd = -1;
+ fsunmount(fs);
}
void
*freep = nil;
if(tpkt == nil)
return -1;
- //fprint(2, "<- %F\n", tx);
+ tx->tag = 0;
+ if(chatty9pclient)
+ fprint(2, "<- %F\n", tx);
nn = convS2M(tx, tpkt, n);
if(nn != n){
free(tpkt);
fprint(2, "%r\n");
return -1;
}
- //fprint(2, "-> %F\n", rx);
+ if(chatty9pclient)
+ fprint(2, "-> %F\n", rx);
if(rx->type == Rerror){
werrstr("%s", rx->ename);
free(rpkt);
blob - 428f7fbb832e85f65fde137fc0a4e4c4c9d10b3e
blob + c71defd6e48da424133cffeb5e0b44755f2a3b67
--- src/lib9pclient/ns.c
+++ src/lib9pclient/ns.c
#include <ctype.h>
CFsys*
-nsmount(char *name, char *aname)
+nsinit(char *name)
{
char *addr, *ns;
int fd;
- CFsys *fs;
ns = getns();
if(ns == nil)
free(addr);
fcntl(fd, F_SETFL, FD_CLOEXEC);
+ return fsinit(fd);
+}
- fs = fsmount(fd, aname);
- if(fs == nil){
- close(fd);
+CFsys*
+nsmount(char *name, char *aname)
+{
+ CFsys *fs;
+ CFid *fid;
+
+ fs = nsinit(name);
+ if(fs == nil)
return nil;
+ if((fid = fsattach(fs, nil, getuser(), aname)) == nil){
+ _fsunmount(fs);
+ return nil;
}
-
+ fssetroot(fs, fid);
return fs;
}