]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/9660srv/dat.h
make error handling in 9p service loops consistent
[plan9front.git] / sys / src / cmd / 9660srv / dat.h
1 typedef struct Ioclust  Ioclust;
2 typedef struct Iobuf    Iobuf;
3 typedef struct Isofile  Isofile;
4 typedef struct Xdata    Xdata;
5 typedef struct Xfile    Xfile;
6 typedef struct Xfs      Xfs;
7 typedef struct Xfsub    Xfsub;
8
9 #pragma incomplete Isofile
10
11 enum
12 {
13         Sectorsize = 2048,
14         Maxname = 256,
15 };
16
17 struct Iobuf
18 {
19         Ioclust* clust;
20         long    addr;
21         uchar*  iobuf;
22 };
23
24 struct Ioclust
25 {
26         long    addr;                   /* in sectors; good to 8TB */
27         Xdata*  dev;
28         Ioclust* next;
29         Ioclust* prev;
30         int     busy;
31         int     nbuf;
32         Iobuf*  buf;
33         uchar*  iobuf;
34         ulong   tag;                    /* cache tag for eviction: 0 = data, 1 = metadata */
35 };
36
37 struct Xdata
38 {
39         Xdata*  next;
40         char*   name;           /* of underlying file */
41         Qid     qid;
42         short   type;
43         short   fdev;
44         int     ref;            /* attach count */
45         int     dev;            /* for read/write */
46 };
47
48 struct Xfsub
49 {
50         void    (*reset)(void);
51         int     (*attach)(Xfile*);
52         void    (*clone)(Xfile*, Xfile*);
53         void    (*walkup)(Xfile*);
54         void    (*walk)(Xfile*, char*);
55         void    (*open)(Xfile*, int);
56         void    (*create)(Xfile*, char*, long, int);
57         long    (*readdir)(Xfile*, uchar*, vlong, long);
58         long    (*read)(Xfile*, char*, vlong, long);
59         long    (*write)(Xfile*, char*, vlong, long);
60         void    (*clunk)(Xfile*);
61         void    (*remove)(Xfile*);
62         void    (*stat)(Xfile*, Dir*);
63         void    (*wstat)(Xfile*, Dir*);
64 };
65
66 struct Xfs
67 {
68         Xdata*  d;              /* how to get the bits */
69         Xfsub*  s;              /* how to use them */
70         int     ref;
71         int     issusp; /* follows system use sharing protocol */
72         long    suspoff;        /* if so, offset at which SUSP area begins */
73         int     isrock; /* Rock Ridge format */
74         int     isplan9;        /* has Plan 9-specific directory info */
75         Qid     rootqid;
76         Isofile*        ptr;            /* private data */
77 };
78
79 struct Xfile
80 {
81         Xfile*  next;           /* in fid hash bucket */
82         Xfs*    xf;
83         long    fid;
84         ulong   flags;
85         Qid     qid;
86         int     len;            /* of private data */
87         Isofile*        ptr;
88 };
89
90 enum
91 {
92         Asis,
93         Clean,
94         Clunk
95 };
96
97 enum
98 {
99         Oread = 1,
100         Owrite = 2,
101         Orclose = 4,
102         Omodes = 3,
103 };
104
105 extern char     Enonexist[];    /* file does not exist */
106 extern char     Eperm[];        /* permission denied */
107 extern char     Enofile[];      /* no file system specified */
108 extern char     Eauth[];        /* authentication failed */
109
110 extern char     *srvname;
111 extern char     *deffile;
112 extern int      chatty;
113 extern jmp_buf  err_lab[];
114 extern int      nerr_lab;
115 extern char     err_msg[];
116
117 extern int nojoliet;
118 extern int noplan9;
119 extern int norock;