123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- /*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
- #include <auth.h>
- #include <fcall.h>
- enum {
- NFidHash = 503,
- };
- typedef struct Con Con;
- typedef struct DirBuf DirBuf;
- typedef struct Excl Excl;
- typedef struct Fid Fid;
- typedef struct Fsys Fsys;
- typedef struct Msg Msg;
- #pragma incomplete DirBuf
- #pragma incomplete Excl
- #pragma incomplete Fsys
- struct Msg {
- unsigned char* data;
- uint32_t msize; /* actual size of data */
- Fcall t;
- Fcall r;
- Con* con;
- Msg* anext; /* allocation free list */
- Msg* mnext; /* all active messsages on this Con */
- Msg* mprev;
- int state; /* */
- Msg* flush; /* flushes waiting for this Msg */
- Msg* rwnext; /* read/write queue */
- int nowq; /* do not place on write queue */
- };
- enum {
- MsgN = 0,
- MsgR = 1,
- Msg9 = 2,
- MsgW = 3,
- MsgF = 4,
- };
- enum {
- ConNoneAllow = 1<<0,
- ConNoAuthCheck = 1<<1,
- ConNoPermCheck = 1<<2,
- ConWstatAllow = 1<<3,
- ConIPCheck = 1<<4,
- };
- struct Con {
- char* name;
- unsigned char* data; /* max, not negotiated */
- int isconsole; /* immutable */
- int flags; /* immutable */
- char remote[128]; /* immutable */
- VtLock* lock;
- int state;
- int fd;
- Msg* version;
- uint32_t msize; /* negotiated with Tversion */
- VtRendez* rendez;
- Con* anext; /* alloc */
- Con* cnext; /* in use */
- Con* cprev;
- VtLock* alock;
- int aok; /* authentication done */
- VtLock* mlock;
- Msg* mhead; /* all Msgs on this connection */
- Msg* mtail;
- VtRendez* mrendez;
- VtLock* wlock;
- Msg* whead; /* write queue */
- Msg* wtail;
- VtRendez* wrendez;
- VtLock* fidlock; /* */
- Fid* fidhash[NFidHash];
- Fid* fhead;
- Fid* ftail;
- int nfid;
- };
- enum {
- ConDead = 0,
- ConNew = 1,
- ConDown = 2,
- ConInit = 3,
- ConUp = 4,
- ConMoribund = 5,
- };
- struct Fid {
- VtLock* lock;
- Con* con;
- uint32_t fidno;
- int ref; /* inc/dec under Con.fidlock */
- int flags;
- int open;
- Fsys* fsys;
- File* file;
- Qid qid;
- char* uid;
- char* uname;
- DirBuf* db;
- Excl* excl;
- VtLock* alock; /* Tauth/Tattach */
- AuthRpc* rpc;
- char* cuname;
- Fid* sort; /* sorted by uname in cmdWho */
- Fid* hash; /* lookup by fidno */
- Fid* next; /* clunk session with Tversion */
- Fid* prev;
- };
- enum { /* Fid.flags and fidGet(..., flags) */
- FidFCreate = 0x01,
- FidFWlock = 0x02,
- };
- enum { /* Fid.open */
- FidOCreate = 0x01,
- FidORead = 0x02,
- FidOWrite = 0x04,
- FidORclose = 0x08,
- };
- /*
- * 9p.c
- */
- extern int (*rFcall[Tmax])(Msg*);
- extern int validFileName(char*);
- /*
- * 9auth.c
- */
- extern int authCheck(Fcall*, Fid*, Fsys*);
- extern int authRead(Fid*, void*, int);
- extern int authWrite(Fid*, void*, int);
- /*
- * 9dir.c
- */
- extern void dirBufFree(DirBuf*);
- extern int dirDe2M(DirEntry*, unsigned char*, int);
- extern int dirRead(Fid*, unsigned char*, int, int64_t);
- /*
- * 9excl.c
- */
- extern int exclAlloc(Fid*);
- extern void exclFree(Fid*);
- extern void exclInit(void);
- extern int exclUpdate(Fid*);
- /*
- * 9fid.c
- */
- extern void fidClunk(Fid*);
- extern void fidClunkAll(Con*);
- extern Fid* fidGet(Con*, uint32_t, int);
- extern void fidInit(void);
- extern void fidPut(Fid*);
- /*
- * 9fsys.c
- */
- extern void fsysFsRlock(Fsys*);
- extern void fsysFsRUnlock(Fsys*);
- extern Fs* fsysGetFs(Fsys*);
- extern Fsys* fsysGet(char*);
- extern char* fsysGetName(Fsys*);
- extern File* fsysGetRoot(Fsys*, char*);
- extern Fsys* fsysIncRef(Fsys*);
- extern int fsysInit(void);
- extern int fsysNoAuthCheck(Fsys*);
- extern int fsysNoPermCheck(Fsys*);
- extern void fsysPut(Fsys*);
- extern int fsysWstatAllow(Fsys*);
- /*
- * 9lstn.c
- */
- extern int lstnInit(void);
- /*
- * 9proc.c
- */
- extern Con* conAlloc(int, char*, int);
- extern void conInit(void);
- extern void msgFlush(Msg*);
- extern void msgInit(void);
- /*
- * 9srv.c
- */
- extern int srvInit(void);
- /*
- * 9user.c
- */
- extern int groupLeader(char*, char*);
- extern int groupMember(char*, char*);
- extern int groupWriteMember(char*);
- extern char* unameByUid(char*);
- extern char* uidByUname(char*);
- extern int usersInit(void);
- extern int usersFileRead(char*);
- extern int validUserName(char*);
- extern char* uidadm;
- extern char* unamenone;
- extern char* uidnoworld;
- /*
- * Ccli.c
- */
- extern int cliAddCmd(char*, int (*)(int, char*[]));
- extern int cliError(char*, ...);
- extern int cliInit(void);
- extern int cliExec(char*);
- #pragma varargck argpos cliError 1
- /*
- * Ccmd.c
- */
- extern int cmdInit(void);
- /*
- * Ccons.c
- */
- extern int consPrompt(char*);
- extern int consInit(void);
- extern int consOpen(int, int, int);
- extern int consTTY(void);
- extern int consWrite(char*, int);
- /*
- * Clog.c
- */
- extern int consPrint(char*, ...);
- extern int consVPrint(char*, va_list);
- #pragma varargck argpos consPrint 1
- /*
- * fossil.c
- */
- extern int Dflag;
|