]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/exportfs/exportfs.h
kernel: make noswap flag exclude processes from killbig() if not eve, reset noswap...
[plan9front.git] / sys / src / cmd / exportfs / exportfs.h
1 /*
2  * exportfs.h - definitions for exporting file server
3  */
4
5 #define DEBUG           if(!dbg){}else fprint
6 #define DFD             9
7 #define fidhash(s)      fhash[s%FHASHSIZE]
8
9 typedef struct Fsrpc Fsrpc;
10 typedef struct Fid Fid;
11 typedef struct File File;
12 typedef struct Proc Proc;
13 typedef struct Qidtab Qidtab;
14
15 struct Fsrpc
16 {
17         Fsrpc   *next;          /* freelist */
18         int     flushtag;       /* Tag on which to reply to flush */
19         Fcall   work;           /* Plan 9 incoming Fcall */
20         uchar   buf[];          /* Data buffer */
21 };
22
23 struct Fid
24 {
25         int     fid;            /* system fd for i/o */
26         File    *f;             /* File attached to this fid */
27         int     mode;
28         int     nr;             /* fid number */
29         int     mid;            /* Mount id */
30         Fid     *next;          /* hash link */
31
32         /* for preaddir -- ARRGH! */
33         Dir     *dir;           /* buffer for reading directories */
34         int     ndir;           /* number of entries in dir */
35         int     cdir;           /* number of consumed entries in dir */
36         int     gdir;           /* glue index */
37         vlong   offset;         /* offset in virtual directory */
38 };
39
40 struct File
41 {
42         char    *name;
43         int     ref;
44         Qid     qid;
45         Qidtab  *qidt;
46         int     inval;
47         File    *parent;
48         File    *child;
49         File    *childlist;
50 };
51
52 struct Proc
53 {
54         Lock;
55         Fsrpc   *busy;
56         Proc    *next;
57         int     pid;
58 };
59
60 struct Qidtab
61 {
62         int     ref;
63         int     type;
64         int     dev;
65         vlong   path;
66         vlong   uniqpath;
67         Qidtab  *next;
68 };
69
70 enum
71 {
72         FHASHSIZE       = 64,
73         Fidchunk        = 1000,
74         Npsmpt          = 32,
75         Nqidbits                = 5,
76         Nqidtab         = (1<<Nqidbits),
77 };
78
79 char Ebadfid[];
80 char Enotdir[];
81 char Edupfid[];
82 char Eopen[];
83 char Exmnt[];
84 char Enomem[];
85 char Emip[];
86 char Enopsmt[];
87
88 Extern int      dbg;
89 Extern File     *root;
90 Extern File     *psmpt;
91 Extern Fid      **fhash;
92 Extern Fid      *fidfree;
93 Extern Proc     *Proclist;
94 Extern char     psmap[Npsmpt];
95 Extern Qidtab   *qidtab[Nqidtab];
96 Extern ulong    messagesize;
97 Extern char     Enomem[];
98 Extern int      srvfd;
99 Extern char*    patternfile;
100
101 /* File system protocol service procedures */
102 void Xattach(Fsrpc*);
103 void Xauth(Fsrpc*);
104 void Xclunk(Fsrpc*); 
105 void Xcreate(Fsrpc*);
106 void Xflush(Fsrpc*); 
107 void Xnop(Fsrpc*);
108 void Xremove(Fsrpc*);
109 void Xstat(Fsrpc*);
110 void Xversion(Fsrpc*);
111 void Xwalk(Fsrpc*);
112 void Xwstat(Fsrpc*);
113 void slave(Fsrpc*);
114
115 void    reply(Fcall*, Fcall*, char*);
116 Fid     *getfid(int);
117 int     freefid(int);
118 Fid     *newfid(int);
119 Fsrpc   *getsbuf(void);
120 void    putsbuf(Fsrpc*);
121 void    initroot(void);
122 void    fatal(char*, ...);
123 char*   makepath(File*, char*);
124 File    *file(File*, char*);
125 void    freefile(File*);
126 void    slaveopen(Fsrpc*);
127 void    slaveread(Fsrpc*);
128 void    slavewrite(Fsrpc*);
129 void    blockingslave(Proc*);
130 void    reopen(Fid *f);
131 void    noteproc(int, char*);
132 void    flushaction(void*, char*);
133 void    pushfcall(char*);
134 Qidtab* uniqueqid(Dir*);
135 void    freeqid(Qidtab*);
136 char*   estrdup(char*);
137 void*   emallocz(uint);
138 int     readmessage(int, char*, int);
139 void    exclusions(void);
140 int     excludefile(char*);
141 int     preaddir(Fid*, uchar*, int, vlong);