]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/tapefs/tapefs.h
disk/format: implement long name support
[plan9front.git] / sys / src / cmd / tapefs / tapefs.h
1 #define g2byte(x)       (((x)[1]<<8) + (x)[0])          /* little-endian */
2 #define g3byte(x)       (((x)[2]<<16) + ((x)[1]<<8) + (x)[0])
3 #define g4byte(x)       (((x)[3]<<24) + ((x)[2]<<16) + ((x)[1]<<8) + (x)[0])
4
5 /* big endian */
6 #define b4byte(x)       (((x)[0]<<24) + ((x)[1]<<16) + ((x)[2]<<8) + (x)[3])
7 #define b8byte(x)       (((vlong)b4byte(x)<<32) | (u32int)b4byte((x)+4))
8 enum
9 {
10         OPERM   = 0x3,          /* mask of all permission types in open mode */
11         Nram    = 512,
12         Maxbuf  = 8192,         /* max buffer size */
13 };
14
15 typedef struct Fid Fid;
16 typedef struct Ram Ram;
17
18 struct Fid
19 {
20         short   busy;
21         short   open;
22         short   rclose;
23         int     fid;
24         Fid     *next;
25         char    *user;
26         Ram     *ram;
27 };
28
29 struct Ram
30 {
31         char    busy;
32         char    open;
33         char    replete;
34         Ram     *parent;        /* parent directory */
35         Ram     *child;         /* first member of directory */
36         Ram     *next;          /* next member of file's directory */
37         Qid     qid;
38         long    perm;
39         char    *name;
40         ulong   atime;
41         ulong   mtime;
42         char    *user;
43         char    *group;
44         vlong addr;
45         void *data;
46         vlong   ndata;
47 };
48
49 enum
50 {
51         Pexec =         1,
52         Pwrite =        2,
53         Pread =         4,
54         Pother =        1,
55         Pgroup =        8,
56         Powner =        64,
57 };
58
59 typedef struct idmap {
60         char    *name;
61         int     id;
62 } Idmap;
63
64 typedef struct fileinf {
65         char    *name;
66         vlong   addr;
67         void    *data;
68         vlong   size;
69         int     mode;
70         int     uid;
71         int     gid;
72         long    mdate;
73 } Fileinf;
74
75 extern  ulong   path;           /* incremented for each new file */
76 extern  Ram     *ram;
77 extern  char    *user;
78 extern  Idmap   *uidmap;
79 extern  Idmap   *gidmap;
80 extern  int     replete;
81 extern  int     blocksize;
82 void    error(char*);
83 void    *erealloc(void*, ulong);
84 void    *emalloc(ulong);
85 char    *estrdup(char*);
86 void    populate(char *);
87 void    dotrunc(Ram*);
88 void    docreate(Ram*);
89 char    *doread(Ram*, vlong, long);
90 void    dowrite(Ram*, char*, long, long);
91 int     dopermw(Ram*);
92 Idmap   *getpass(char*);
93 char    *mapid(Idmap*,int);
94 Ram     *poppath(Fileinf fi, int new);
95 Ram     *popfile(Ram *dir, Fileinf fi);
96 void    popdir(Ram*);
97 Ram     *lookup(Ram*, char*);