blob: 0029ab5243fc7728a0719f8879b9e5044f1f1eb5 (
plain)
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
|
typedef struct Bbuf Bbuf;
typedef struct Bcache Bcache;
enum
{
Nbcache= 32, /* number of blocks kept in pool */
};
/*
* block cache descriptor
*/
struct Bbuf
{
Lru; /* must be first in struct */
ulong bno;
int inuse;
Bbuf *next; /* next in dirty list */
int dirty;
char *data;
};
/*
* the buffer cache
*/
struct Bcache
{
Lru;
int bsize; /* block size in bytes */
int f; /* fd to disk */
Bbuf *dfirst; /* dirty list */
Bbuf *dlast;
Bbuf bb[Nbcache];
};
int bcinit(Bcache*, int, int);
Bbuf* bcalloc(Bcache*, ulong);
Bbuf* bcread(Bcache*, ulong);
void bcmark(Bcache*, Bbuf*);
int bcwrite(Bcache*, Bbuf*);
int bcsync(Bcache*);
int bread(Bcache*, ulong, void*);
int bwrite(Bcache*, ulong, void*);
int bref(Bcache*, Bbuf*);
void error(char*, ...);
void warning(char*);
|