diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/cmd/9nfs/dat.h |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/9nfs/dat.h')
-rwxr-xr-x | sys/src/cmd/9nfs/dat.h | 273 |
1 files changed, 273 insertions, 0 deletions
diff --git a/sys/src/cmd/9nfs/dat.h b/sys/src/cmd/9nfs/dat.h new file mode 100755 index 000000000..c9f6a8664 --- /dev/null +++ b/sys/src/cmd/9nfs/dat.h @@ -0,0 +1,273 @@ +enum +{ + FHSIZE = 32 +}; + +typedef struct Accept Accept; +typedef struct Auth Auth; +typedef struct Authunix Authunix; +typedef struct Chalstuff Chalstuff; +typedef uchar Fhandle[FHSIZE]; +typedef struct Fid Fid; +typedef struct Procmap Procmap; +typedef struct Progmap Progmap; +typedef struct Reject Reject; +typedef struct Rpccall Rpccall; +typedef struct Rpccache Rpccache; +typedef struct Sattr Sattr; +typedef struct Session Session; +typedef struct String String; +typedef struct Strnode Strnode; +typedef struct Unixid Unixid; +typedef struct Unixidmap Unixidmap; +typedef struct Unixmap Unixmap; +typedef struct Unixscmap Unixscmap; +typedef struct Xfid Xfid; +typedef struct Xfile Xfile; + +struct String +{ + ulong n; + char * s; +}; + +struct Progmap +{ + int progno; + int vers; + void (*init)(int, char**); + Procmap *pmap; +}; + +struct Procmap +{ + int procno; + int (*procp)(int, Rpccall*, Rpccall*); +}; + +struct Auth +{ + ulong flavor; + ulong count; + void * data; +}; + +struct Authunix +{ + ulong stamp; + String mach; + ulong uid; + ulong gid; + int gidlen; + ulong gids[10]; +}; + +struct Accept +{ + Auth averf; + ulong astat; + union{ + void * results; /* SUCCESS */ + struct{ /* PROG_MISMATCH */ + ulong plow; /* acceptable version numbers */ + ulong phigh; + }; + }; +}; + +struct Reject +{ + ulong rstat; + union{ + struct{ /* RPC_MISMATCH */ + ulong rlow; /* acceptable rpc version numbers */ + ulong rhigh; + }; + ulong authstat; /* AUTH_ERROR */ + }; +}; + +struct Rpccall +{ + /* corresponds to Udphdr */ + uchar prefix0[12]; + ulong host; /* ipv4 subset: prefixed to RPC message */ + uchar prefix1[12]; + ulong lhost; /* ipv4 subset: prefixed to RPC message */ + /* ignore ifcaddr */ + ulong port; /* prefixed to RPC message */ + ulong lport; /* prefixed to RPC message */ + + ulong xid; /* transaction id */ + ulong mtype; /* CALL or REPLY */ + union{ + struct{ /* CALL */ + ulong rpcvers; /* must be equal to two (2) */ + ulong prog; /* program number */ + ulong vers; /* program version */ + ulong proc; /* procedure number */ + Auth cred; /* authentication credentials */ + Auth verf; /* authentication verifier */ + Unixidmap *up; + char * user; + void * args; /* procedure-specific */ + }; + struct{ /* REPLY */ + ulong stat; /* MSG_ACCEPTED or MSG_DENIED */ + union{ + Accept; + Reject; + }; + }; + }; +}; + +struct Rpccache +{ + Rpccache *prev; + Rpccache *next; + ulong host; + ulong port; + ulong xid; + int n; + uchar data[4]; +}; + +struct Sattr +{ + ulong mode; + ulong uid; + ulong gid; + ulong size; + ulong atime; /* sec's */ + ulong ausec; /* microsec's */ + ulong mtime; + ulong musec; +}; + +struct Strnode +{ + Strnode *next; /* in hash bucket */ + char str[4]; +}; + +struct Unixid +{ + Unixid *next; + char * name; + int id; +}; + +struct Unixmap +{ + char * file; + int style; + long timestamp; + Unixid *ids; +}; + +struct Unixidmap +{ + Unixidmap *next; + int flag; + char * server; + char * client; + Reprog *sexp; + Reprog *cexp; + Unixmap u; + Unixmap g; +}; + +struct Unixscmap +{ + Unixscmap *next; + char * server; + ulong clientip; + Unixidmap *map; +}; + +struct Xfile +{ + Xfile * next; /* hash chain */ + Session *s; + Qid qid; /* from stat */ + Xfile * parent; + Xfile * child; /* if directory */ + Xfile * sib; /* siblings */ + char * name; /* path element */ + Xfid * users; +}; + +enum +{ + Oread = 1, + Owrite = 2, + Open = 3, + Trunc = 4 +}; + +struct Xfid +{ + Xfid * next; /* Xfile's user list */ + Xfile * xp; + char * uid; + Fid * urfid; + Fid * opfid; + ulong mode; /* open mode, if opfid is non-zero */ + ulong offset; +}; + +struct Fid +{ + Fid ** owner; /* null for root fids */ + Fid * prev; + Fid * next; + long tstale; /* auto-clunk */ +}; + +enum +{ + Maxfdata = 8192, + Maxstatdata = 2048, +}; + +struct Session +{ + Session *next; + char * service; /* for dial */ + int fd; +#define CHALLEN 1 + char cchal[CHALLEN]; /* client challenge */ + char schal[CHALLEN]; /* server challenge */ + char authid[ANAMELEN]; /* server encryption uid */ + char authdom[DOMLEN]; /* server encryption domain */ + char * spec; /* for attach */ + Xfile * root; /* to answer mount rpc */ + ushort tag; + Fcall f; + uchar data[IOHDRSZ+Maxfdata]; + uchar statbuf[Maxstatdata]; + Fid * free; /* available */ + Fid list; /* active, most-recently-used order */ + Fid fids[1000]; + int noauth; +}; + +struct Chalstuff +{ + Chalstuff *next; + Xfid * xf; + long tstale; + Chalstate; +}; + +extern int rpcdebug; +extern int p9debug; +extern int chatty; +extern void (*rpcalarm)(void); +extern long starttime; +extern long nfstime; +extern char * config; +extern int staletime; +extern int messagesize; +extern char * commonopts; |