add _fsunmount; do version in fsinit; add nsinit; add chatty9pclient
This commit is contained in:
parent
2aa7d30367
commit
59518849d8
2 changed files with 41 additions and 19 deletions
|
|
@ -13,6 +13,8 @@ static void *_fsrecv(Mux*);
|
||||||
static int _fsgettag(Mux*, void*);
|
static int _fsgettag(Mux*, void*);
|
||||||
static int _fssettag(Mux*, void*, uint);
|
static int _fssettag(Mux*, void*, uint);
|
||||||
|
|
||||||
|
int chatty9pclient;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
CFidchunk = 32
|
CFidchunk = 32
|
||||||
|
|
@ -22,6 +24,7 @@ CFsys*
|
||||||
fsinit(int fd)
|
fsinit(int fd)
|
||||||
{
|
{
|
||||||
CFsys *fs;
|
CFsys *fs;
|
||||||
|
int n;
|
||||||
|
|
||||||
fmtinstall('F', fcallfmt);
|
fmtinstall('F', fcallfmt);
|
||||||
fmtinstall('D', dirfmt);
|
fmtinstall('D', dirfmt);
|
||||||
|
|
@ -42,6 +45,13 @@ fsinit(int fd)
|
||||||
fs->iorecv = ioproc();
|
fs->iorecv = ioproc();
|
||||||
fs->iosend = ioproc();
|
fs->iosend = ioproc();
|
||||||
muxinit(&fs->mux);
|
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;
|
return fs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,28 +65,28 @@ fsroot(CFsys *fs)
|
||||||
CFsys*
|
CFsys*
|
||||||
fsmount(int fd, char *aname)
|
fsmount(int fd, char *aname)
|
||||||
{
|
{
|
||||||
int n;
|
|
||||||
CFsys *fs;
|
CFsys *fs;
|
||||||
CFid *fid;
|
CFid *fid;
|
||||||
|
|
||||||
fs = fsinit(fd);
|
fs = fsinit(fd);
|
||||||
if(fs == nil)
|
if(fs == nil)
|
||||||
return nil;
|
return nil;
|
||||||
strcpy(fs->version, "9P2000");
|
|
||||||
if((n = fsversion(fs, 8192, fs->version, sizeof fs->version)) < 0){
|
if((fid = fsattach(fs, nil, getuser(), aname)) == nil){
|
||||||
Error:
|
_fsunmount(fs);
|
||||||
fs->fd = -1;
|
|
||||||
fsunmount(fs);
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
fs->msize = n;
|
|
||||||
|
|
||||||
if((fid = fsattach(fs, nil, getuser(), aname)) == nil)
|
|
||||||
goto Error;
|
|
||||||
fssetroot(fs, fid);
|
fssetroot(fs, fid);
|
||||||
return fs;
|
return fs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_fsunmount(CFsys *fs)
|
||||||
|
{
|
||||||
|
fs->fd = -1;
|
||||||
|
fsunmount(fs);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fsunmount(CFsys *fs)
|
fsunmount(CFsys *fs)
|
||||||
{
|
{
|
||||||
|
|
@ -196,7 +206,9 @@ _fsrpc(CFsys *fs, Fcall *tx, Fcall *rx, void **freep)
|
||||||
*freep = nil;
|
*freep = nil;
|
||||||
if(tpkt == nil)
|
if(tpkt == nil)
|
||||||
return -1;
|
return -1;
|
||||||
//fprint(2, "<- %F\n", tx);
|
tx->tag = 0;
|
||||||
|
if(chatty9pclient)
|
||||||
|
fprint(2, "<- %F\n", tx);
|
||||||
nn = convS2M(tx, tpkt, n);
|
nn = convS2M(tx, tpkt, n);
|
||||||
if(nn != n){
|
if(nn != n){
|
||||||
free(tpkt);
|
free(tpkt);
|
||||||
|
|
@ -216,7 +228,8 @@ _fsrpc(CFsys *fs, Fcall *tx, Fcall *rx, void **freep)
|
||||||
fprint(2, "%r\n");
|
fprint(2, "%r\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
//fprint(2, "-> %F\n", rx);
|
if(chatty9pclient)
|
||||||
|
fprint(2, "-> %F\n", rx);
|
||||||
if(rx->type == Rerror){
|
if(rx->type == Rerror){
|
||||||
werrstr("%s", rx->ename);
|
werrstr("%s", rx->ename);
|
||||||
free(rpkt);
|
free(rpkt);
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,10 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
CFsys*
|
CFsys*
|
||||||
nsmount(char *name, char *aname)
|
nsinit(char *name)
|
||||||
{
|
{
|
||||||
char *addr, *ns;
|
char *addr, *ns;
|
||||||
int fd;
|
int fd;
|
||||||
CFsys *fs;
|
|
||||||
|
|
||||||
ns = getns();
|
ns = getns();
|
||||||
if(ns == nil)
|
if(ns == nil)
|
||||||
|
|
@ -29,13 +28,23 @@ nsmount(char *name, char *aname)
|
||||||
free(addr);
|
free(addr);
|
||||||
|
|
||||||
fcntl(fd, F_SETFL, FD_CLOEXEC);
|
fcntl(fd, F_SETFL, FD_CLOEXEC);
|
||||||
|
return fsinit(fd);
|
||||||
|
}
|
||||||
|
|
||||||
fs = fsmount(fd, aname);
|
CFsys*
|
||||||
if(fs == nil){
|
nsmount(char *name, char *aname)
|
||||||
close(fd);
|
{
|
||||||
|
CFsys *fs;
|
||||||
|
CFid *fid;
|
||||||
|
|
||||||
|
fs = nsinit(name);
|
||||||
|
if(fs == nil)
|
||||||
|
return nil;
|
||||||
|
if((fid = fsattach(fs, nil, getuser(), aname)) == nil){
|
||||||
|
_fsunmount(fs);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
fssetroot(fs, fid);
|
||||||
return fs;
|
return fs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue