-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathlogfs.h
executable file
·158 lines (141 loc) · 5.8 KB
/
logfs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#pragma src "/usr/inferno/liblogfs"
typedef struct LogfsLowLevel LogfsLowLevel;
typedef struct LogfsBoot LogfsBoot;
typedef struct Logfs Logfs;
typedef struct LogfsServer LogfsServer;
typedef struct LogfsIdentityStore LogfsIdentityStore;
#pragma incomplete Logfs
#pragma incomplete LogfsServer
#pragma incomplete LogfsIdentityStore
#pragma incomplete LogfsBoot
typedef u64int Pageset;
#define BITSPERSET (sizeof(Pageset)*8)
#define PAGETOP ((Pageset)1<<(BITSPERSET-1))
enum {
LogfsTnone = 0xff,
LogfsTboot = 0x01,
LogfsTlog = 0x06,
LogfsTdata = 0x18,
LogfsTbad = -1,
LogfsTworse = -2,
LogfsMagic = 'V',
};
enum {
LogfsLogTstart = 's',
LogfsLogTcreate = 'c',
LogfsLogTtrunc = 't',
LogfsLogTremove = 'r',
LogfsLogTwrite = 'w',
LogfsLogTwstat = 'W',
LogfsLogTend = 'e',
};
enum {
LogfsOpenFlagNoPerm = 1,
LogfsOpenFlagWstatAllow = 2,
};
typedef enum LogfsLowLevelReadResult {
LogfsLowLevelReadResultOk,
LogfsLowLevelReadResultSoftError,
LogfsLowLevelReadResultHardError,
LogfsLowLevelReadResultBad,
LogfsLowLevelReadResultAllOnes,
} LogfsLowLevelReadResult;
typedef short LOGFSGETBLOCKTAGFN(LogfsLowLevel*, long);
typedef void LOGFSSETBLOCKTAGFN(LogfsLowLevel*, long, short);
typedef ulong LOGFSGETBLOCKPATHFN(LogfsLowLevel*, long);
typedef void LOGFSSETBLOCKPATHFN(LogfsLowLevel*, long, ulong);
typedef long LOGFSFINDFREEBLOCKFN(LogfsLowLevel*, long*);
typedef char *LOGFSREADBLOCKFN(LogfsLowLevel*, void*, long, LogfsLowLevelReadResult*);
typedef char *LOGFSWRITEBLOCKFN(LogfsLowLevel*, void*, uchar, ulong, int, long*, long);
typedef char *LOGFSERASEBLOCKFN(LogfsLowLevel*, long, void **, int*);
typedef char *LOGFSFORMATBLOCKFN(LogfsLowLevel*, long, uchar, long, long, long, int, long*, void*, int*);
typedef char *LOGFSREFORMATBLOCKFN(LogfsLowLevel*, long, uchar, long, int, long*, void*, int*);
typedef void LOGFSMARKBLOCKBADFN(LogfsLowLevel*, long);
typedef int LOGFSGETBLOCKSFN(LogfsLowLevel*);
typedef long LOGFSGETBASEBLOCKFN(LogfsLowLevel*);
typedef int LOGFSGETBLOCKSIZEFN(LogfsLowLevel*);
typedef int LOGFSGETBLOCKPARTIALFORMATSTATUSFN(LogfsLowLevel*, long);
typedef ulong LOGFSCALCRAWADDRESSFN(LogfsLowLevel*, long, int);
typedef char *LOGFSOPENFN(LogfsLowLevel*, long, long, int, int, long*);
typedef char *LOGFSGETBLOCKSTATUSFN(LogfsLowLevel*, long, int*, void **, LogfsLowLevelReadResult*);
typedef int LOGFSCALCFORMATFN(LogfsLowLevel*, long, long, long, long*, long*, long*);
typedef int LOGFSGETOPENSTATUSFN(LogfsLowLevel*);
typedef void LOGFSFREEFN(LogfsLowLevel*);
typedef char *LOGFSREADPAGERANGEFN(LogfsLowLevel*, uchar*, long, int, int, int, LogfsLowLevelReadResult*);
typedef char *LOGFSWRITEPAGEFN(LogfsLowLevel*, uchar*, long, int);
typedef char *LOGFSSYNCFN(LogfsLowLevel*);
struct LogfsLowLevel {
int l2pagesize;
int l2pagesperblock;
long blocks;
int pathbits;
LOGFSOPENFN *open;
LOGFSGETBLOCKTAGFN *getblocktag;
LOGFSSETBLOCKTAGFN *setblocktag;
LOGFSGETBLOCKPATHFN *getblockpath;
LOGFSSETBLOCKPATHFN *setblockpath;
LOGFSREADPAGERANGEFN *readpagerange;
LOGFSWRITEPAGEFN *writepage;
LOGFSFINDFREEBLOCKFN *findfreeblock;
LOGFSREADBLOCKFN *readblock;
LOGFSWRITEBLOCKFN *writeblock;
LOGFSERASEBLOCKFN *eraseblock;
LOGFSFORMATBLOCKFN *formatblock;
LOGFSREFORMATBLOCKFN *reformatblock;
LOGFSMARKBLOCKBADFN *markblockbad;
LOGFSGETBASEBLOCKFN *getbaseblock;
LOGFSGETBLOCKSIZEFN *getblocksize;
LOGFSGETBLOCKPARTIALFORMATSTATUSFN *getblockpartialformatstatus;
LOGFSCALCRAWADDRESSFN *calcrawaddress;
LOGFSGETBLOCKSTATUSFN *getblockstatus;
LOGFSCALCFORMATFN *calcformat;
LOGFSGETOPENSTATUSFN *getopenstatus;
LOGFSFREEFN *free;
LOGFSSYNCFN *sync;
};
char *logfstagname(uchar);
char *logfsisnew(LogfsIdentityStore **);
void logfsisfree(LogfsIdentityStore **);
char *logfsisgroupcreate(LogfsIdentityStore*, char*, char*);
char *logfsisgrouprename(LogfsIdentityStore*, char*, char*);
char *logfsisgroupsetleader(LogfsIdentityStore*, char*, char*);
char *logfsisgroupaddmember(LogfsIdentityStore*, char*, char*);
char *logfsisgroupremovemember(LogfsIdentityStore*, char*, char*);
char *logfsisusersread(LogfsIdentityStore*, void*, long, ulong, long*);
char *logfsformat(LogfsLowLevel*, long, long, long, int);
char *logfsbootopen(LogfsLowLevel*, long, long, int, int, LogfsBoot**);
void logfsbootfree(LogfsBoot*);
char *logfsbootread(LogfsBoot*, void*, long, ulong);
char *logfsbootwrite(LogfsBoot*, void*, long, ulong);
char *logfsbootio(LogfsBoot*, void*, long, ulong, int);
char *logfsbootmap(LogfsBoot*, ulong, ulong*, int*, int*, int*, ulong*, ulong*);
long logfsbootgetiosize(LogfsBoot*);
long logfsbootgetsize(LogfsBoot*);
void logfsboottrace(LogfsBoot*, int);
char *logfsserverattach(LogfsServer*, u32int, char*, Qid*);
char *logfsserverclunk(LogfsServer*, u32int);
char *logfsservercreate(LogfsServer*, u32int, char*, u32int, uchar, Qid*);
char *logfsserverflush(LogfsServer*);
char *logfsservernew(LogfsBoot*, LogfsLowLevel*, LogfsIdentityStore*, ulong, int, LogfsServer**);
char *logfsserveropen(LogfsServer*, u32int, uchar mode, Qid*);
char *logfsserverread(LogfsServer*, u32int, u32int, u32int, uchar*, u32int, u32int*);
char *logfsserverremove(LogfsServer*, u32int);
char *logfsserverstat(LogfsServer*, u32int, uchar*, u32int, ushort*);
char *logfsserverwalk(LogfsServer*, u32int, u32int, ushort, char **, ushort*, Qid*);
char *logfsserverwrite(LogfsServer*, u32int, u32int, u32int, uchar*, u32int*);
char *logfsserverwstat(LogfsServer*, u32int, uchar*, ushort nstat);
void logfsserverfree(LogfsServer **);
char *logfsserverlogsweep(LogfsServer*, int, int*);
char *logfsserverreadpathextent(LogfsServer*, u32int, int, u32int*, u32int*, long*, int*, int*);
char *logfsservertestcmd(LogfsServer*, int, char **);
void logfsservertrace(LogfsServer*, int);
/*
* implemented by the environment
*/
ulong logfsnow(void);
void *logfsrealloc(void*, ulong);
void logfsfreemem(void*);
int nrand(int);
extern char Eio[];
extern char Ebadarg[];
extern char Eperm[];