diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/libstyx/styxserver.c | 12 | ||||
| -rw-r--r-- | tools/libstyx/styxserver.h | 97 | ||||
| -rwxr-xr-x | tools/odbc/odbc.c | 4 |
3 files changed, 11 insertions, 102 deletions
diff --git a/tools/libstyx/styxserver.c b/tools/libstyx/styxserver.c index d0bf1c2c..34257349 100644 --- a/tools/libstyx/styxserver.c +++ b/tools/libstyx/styxserver.c @@ -114,7 +114,7 @@ newclient(Styxserver *server, int fd) c->state = 0; c->fids = nil; c->uname = strdup(eve); - c->aname = strdup(eve); + c->aname = strdup(""); c->next = server->clients; server->clients = c; if(server->ops->newclient) @@ -167,7 +167,7 @@ rd(Client *c, Fcall *r) { if(c->nc > 0){ /* last convM2S consumed nc bytes */ c->nread -= c->nc; - if(c->nread < 0){ + if((int)c->nread < 0){ r->ename = "negative size in rd"; return -1; } @@ -903,7 +903,7 @@ run(Client *c) break; case Tattach: if(Debug) - fprint(2, "Tattach %d %s\n", f.fid, f.uname[0] ? f.uname : c->uname); + fprint(2, "Tattach %d %s %s\n", f.fid, f.uname[0] ? f.uname : c->uname, f.aname[0]? f.aname: c->aname); if(fp){ f.type = Rerror; f.ename = "fid in use"; @@ -1065,3 +1065,9 @@ styxqid(int path, int isdir) q.type = 0; return q; } + +void +styxsetowner(char *name) +{ + eve = name; +} diff --git a/tools/libstyx/styxserver.h b/tools/libstyx/styxserver.h deleted file mode 100644 index 3aac9eee..00000000 --- a/tools/libstyx/styxserver.h +++ /dev/null @@ -1,97 +0,0 @@ - -#define Qroot 0 - -#define MSGMAX ((((8192+128)*2)+3) & ~3) - -extern char Enomem[]; /* out of memory */ -extern char Eperm[]; /* permission denied */ -extern char Enodev[]; /* no free devices */ -extern char Ehungup[]; /* i/o on hungup channel */ -extern char Eexist[]; /* file exists */ -extern char Enonexist[]; /* file does not exist */ -extern char Ebadcmd[]; /* bad command */ -extern char Ebadarg[]; /* bad arguments */ - -typedef uvlong Path; -typedef struct Styxserver Styxserver; -typedef struct Styxops Styxops; -typedef struct Styxfile Styxfile; -typedef struct Client Client; -typedef struct Fid Fid; - -struct Styxserver -{ - Styxops *ops; - Path qidgen; - int connfd; - int needfile; - Client *clients; - Client *curc; - Styxfile *root; - Styxfile **ftab; - void *priv; /* private */ -}; - -struct Client -{ - Styxserver *server; - Client *next; - int fd; - char msg[MSGMAX]; - uint nread; /* valid bytes in msg (including nc)*/ - int nc; /* bytes consumed from front of msg by convM2S */ - char data[MSGMAX]; /* Tread/Rread data */ - int state; - Fid *fids; - char *uname; /* uid */ - char *aname; /* attach name */ - void *u; -}; - -struct Styxops -{ - char *(*newclient)(Client *c); - char *(*freeclient)(Client *c); - - char *(*attach)(char *uname, char *aname); - char *(*walk)(Qid *qid, char *name); - char *(*open)(Qid *qid, int mode); - char *(*create)(Qid *qid, char *name, int perm, int mode); - char *(*read)(Qid qid, char *buf, ulong *n, vlong offset); - char *(*write)(Qid qid, char *buf, ulong *n, vlong offset); - char *(*close)(Qid qid, int mode); - char *(*remove)(Qid qid); - char *(*stat)(Qid qid, Dir *d); - char *(*wstat)(Qid qid, Dir *d); -}; - -struct Styxfile -{ - Dir d; - Styxfile *parent; - Styxfile *child; - Styxfile *sibling; - Styxfile *next; - int ref; - int open; - void *u; -}; - -char *styxinit(Styxserver *server, Styxops *ops, char *port, int perm, int needfile); -char *styxwait(Styxserver *server); -char *styxprocess(Styxserver *server); -char *styxend(Styxserver *server); - -Client *styxclient(Styxserver *server); - -Styxfile *styxaddfile(Styxserver *server, Path pqid, Path qid, char *name, int mode, char *owner); -Styxfile *styxadddir(Styxserver *server, Path pqid, Path qid, char *name, int mode, char *owner); -int styxrmfile(Styxserver *server, Path qid); -Styxfile *styxfindfile(Styxserver *server, Path qid); - -int styxperm(Styxfile *file, char *uid, int mode); -long styxreadstr(ulong off, char *buf, ulong n, char *str); -Qid styxqid(int path, int isdir); -void *styxmalloc(int n); -void styxfree(void *p); -void styxdebug(void); diff --git a/tools/odbc/odbc.c b/tools/odbc/odbc.c index 7b8194d9..f08a4f4f 100755 --- a/tools/odbc/odbc.c +++ b/tools/odbc/odbc.c @@ -844,7 +844,7 @@ dbopen(Qid *qid, int omode) break; case Qclonus: p = &proto[PROTO(q)]; - cv = protoclone(p, c->aname); + cv = protoclone(p, c->uname); if(cv == 0){ return Enodev; } @@ -860,7 +860,7 @@ dbopen(Qid *qid, int omode) case Qctl: p = &proto[PROTO(q)]; cv = p->conv[CONV(q)]; - user = c->aname; + user = c->uname; if((perm & (cv->perm>>6)) != perm) { if(strcmp(user, cv->owner) != 0 || (perm & cv->perm) != perm) { |
