mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-24 11:41:58 +00:00
venti.h: import indentation from plan 9
R=rsc CC=plan9port.codebot http://codereview.appspot.com/4571065
This commit is contained in:
parent
8aeb3ea1c0
commit
79793adc21
1 changed files with 144 additions and 142 deletions
286
include/venti.h
286
include/venti.h
|
@ -17,27 +17,28 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct Packet Packet;
|
typedef struct Packet Packet;
|
||||||
Packet *packetalloc(void);
|
|
||||||
void packetfree(Packet*);
|
Packet* packetalloc(void);
|
||||||
Packet *packetforeign(uchar *buf, int n, void (*free)(void *a), void *a);
|
void packetappend(Packet*, uchar *buf, int n);
|
||||||
Packet *packetdup(Packet*, int offset, int n);
|
uint packetasize(Packet*);
|
||||||
Packet *packetsplit(Packet*, int n);
|
int packetcmp(Packet*, Packet*);
|
||||||
int packetconsume(Packet*, uchar *buf, int n);
|
int packetcompact(Packet*);
|
||||||
int packettrim(Packet*, int offset, int n);
|
void packetconcat(Packet*, Packet*);
|
||||||
uchar *packetheader(Packet*, int n);
|
int packetconsume(Packet*, uchar *buf, int n);
|
||||||
uchar *packettrailer(Packet*, int n);
|
int packetcopy(Packet*, uchar *buf, int offset, int n);
|
||||||
void packetprefix(Packet*, uchar *buf, int n);
|
Packet* packetdup(Packet*, int offset, int n);
|
||||||
void packetappend(Packet*, uchar *buf, int n);
|
Packet* packetforeign(uchar *buf, int n, void (*free)(void *a), void *a);
|
||||||
void packetconcat(Packet*, Packet*);
|
int packetfragments(Packet*, IOchunk*, int nio, int offset);
|
||||||
uchar *packetpeek(Packet*, uchar *buf, int offset, int n);
|
void packetfree(Packet*);
|
||||||
int packetcopy(Packet*, uchar *buf, int offset, int n);
|
uchar* packetheader(Packet*, int n);
|
||||||
int packetfragments(Packet*, IOchunk*, int nio, int offset);
|
uchar* packetpeek(Packet*, uchar *buf, int offset, int n);
|
||||||
uint packetsize(Packet*);
|
void packetprefix(Packet*, uchar *buf, int n);
|
||||||
uint packetasize(Packet*);
|
void packetsha1(Packet*, uchar sha1[20]);
|
||||||
int packetcompact(Packet*);
|
uint packetsize(Packet*);
|
||||||
int packetcmp(Packet*, Packet*);
|
Packet* packetsplit(Packet*, int n);
|
||||||
void packetstats(void);
|
void packetstats(void);
|
||||||
void packetsha1(Packet*, uchar sha1[20]);
|
uchar* packettrailer(Packet*, int n);
|
||||||
|
int packettrim(Packet*, int offset, int n);
|
||||||
|
|
||||||
/* XXX should be own library? */
|
/* XXX should be own library? */
|
||||||
/*
|
/*
|
||||||
|
@ -48,28 +49,28 @@ typedef struct VtLogChunk VtLogChunk;
|
||||||
|
|
||||||
struct VtLog
|
struct VtLog
|
||||||
{
|
{
|
||||||
VtLog *next; /* in hash table */
|
VtLog *next; /* in hash table */
|
||||||
char *name;
|
char *name;
|
||||||
VtLogChunk *chunk;
|
VtLogChunk *chunk;
|
||||||
uint nchunk;
|
uint nchunk;
|
||||||
VtLogChunk *w;
|
VtLogChunk *w;
|
||||||
QLock lk;
|
QLock lk;
|
||||||
int ref;
|
int ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VtLogChunk
|
struct VtLogChunk
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
char *ep;
|
char *ep;
|
||||||
char *wp;
|
char *wp;
|
||||||
};
|
};
|
||||||
|
|
||||||
VtLog *vtlogopen(char *name, uint size);
|
VtLog* vtlogopen(char *name, uint size);
|
||||||
void vtlogprint(VtLog *log, char *fmt, ...);
|
void vtlogprint(VtLog *log, char *fmt, ...);
|
||||||
void vtlog(char *name, char *fmt, ...);
|
void vtlog(char *name, char *fmt, ...);
|
||||||
void vtlogclose(VtLog*);
|
void vtlogclose(VtLog*);
|
||||||
void vtlogremove(char *name);
|
void vtlogremove(char *name);
|
||||||
char **vtlognames(int*);
|
char** vtlognames(int*);
|
||||||
void vtlogdump(int fd, VtLog*);
|
void vtlogdump(int fd, VtLog*);
|
||||||
|
|
||||||
/* XXX begin actual venti.h */
|
/* XXX begin actual venti.h */
|
||||||
|
@ -84,7 +85,7 @@ typedef struct VtRoot VtRoot;
|
||||||
*/
|
*/
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
VtScoreSize = 20,
|
VtScoreSize = 20,
|
||||||
VtMaxStringSize = 1024,
|
VtMaxStringSize = 1024,
|
||||||
VtPointerDepth = 7
|
VtPointerDepth = 7
|
||||||
};
|
};
|
||||||
|
@ -145,13 +146,13 @@ enum
|
||||||
};
|
};
|
||||||
struct VtEntry
|
struct VtEntry
|
||||||
{
|
{
|
||||||
ulong gen; /* generation number */
|
ulong gen; /* generation number */
|
||||||
ulong psize; /* pointer block size */
|
ulong psize; /* pointer block size */
|
||||||
ulong dsize; /* data block size */
|
ulong dsize; /* data block size */
|
||||||
uchar type;
|
uchar type;
|
||||||
uchar flags;
|
uchar flags;
|
||||||
uvlong size;
|
uvlong size;
|
||||||
uchar score[VtScoreSize];
|
uchar score[VtScoreSize];
|
||||||
};
|
};
|
||||||
|
|
||||||
void vtentrypack(VtEntry*, uchar*, int index);
|
void vtentrypack(VtEntry*, uchar*, int index);
|
||||||
|
@ -159,11 +160,11 @@ int vtentryunpack(VtEntry*, uchar*, int index);
|
||||||
|
|
||||||
struct VtRoot
|
struct VtRoot
|
||||||
{
|
{
|
||||||
char name[128];
|
char name[128];
|
||||||
char type[128];
|
char type[128];
|
||||||
uchar score[VtScoreSize]; /* to a Dir block */
|
uchar score[VtScoreSize]; /* to a Dir block */
|
||||||
ulong blocksize; /* maximum block size */
|
ulong blocksize; /* maximum block size */
|
||||||
uchar prev[VtScoreSize]; /* last root block */
|
uchar prev[VtScoreSize]; /* last root block */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -205,12 +206,12 @@ int vtscorefmt(Fmt*);
|
||||||
/*
|
/*
|
||||||
* error-checking malloc et al.
|
* error-checking malloc et al.
|
||||||
*/
|
*/
|
||||||
void vtfree(void *);
|
void vtfree(void *);
|
||||||
void *vtmalloc(int);
|
void* vtmalloc(int);
|
||||||
void *vtmallocz(int);
|
void* vtmallocz(int);
|
||||||
void *vtrealloc(void *p, int);
|
void* vtrealloc(void *p, int);
|
||||||
void *vtbrk(int n);
|
void* vtbrk(int n);
|
||||||
char *vtstrdup(char *);
|
char* vtstrdup(char *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Venti protocol
|
* Venti protocol
|
||||||
|
@ -277,7 +278,7 @@ struct VtFcall
|
||||||
uchar msgtype;
|
uchar msgtype;
|
||||||
uchar tag;
|
uchar tag;
|
||||||
|
|
||||||
char *error; /* Rerror */
|
char *error; /* Rerror */
|
||||||
|
|
||||||
char *version; /* Thello */
|
char *version; /* Thello */
|
||||||
char *uid; /* Thello */
|
char *uid; /* Thello */
|
||||||
|
@ -292,15 +293,15 @@ struct VtFcall
|
||||||
uchar *auth; /* TauthX, RauthX */
|
uchar *auth; /* TauthX, RauthX */
|
||||||
uint nauth; /* TauthX, RauthX */
|
uint nauth; /* TauthX, RauthX */
|
||||||
uchar score[VtScoreSize]; /* Tread, Rwrite */
|
uchar score[VtScoreSize]; /* Tread, Rwrite */
|
||||||
uchar blocktype; /* Tread, Twrite */
|
uchar blocktype; /* Tread, Twrite */
|
||||||
uint count; /* Tread */
|
uint count; /* Tread */
|
||||||
Packet *data; /* Rread, Twrite */
|
Packet *data; /* Rread, Twrite */
|
||||||
};
|
};
|
||||||
|
|
||||||
Packet *vtfcallpack(VtFcall*);
|
Packet* vtfcallpack(VtFcall*);
|
||||||
int vtfcallunpack(VtFcall*, Packet*);
|
int vtfcallunpack(VtFcall*, Packet*);
|
||||||
void vtfcallclear(VtFcall*);
|
void vtfcallclear(VtFcall*);
|
||||||
int vtfcallfmt(Fmt*);
|
int vtfcallfmt(Fmt*);
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -321,7 +322,7 @@ struct VtConn
|
||||||
void *writeq;
|
void *writeq;
|
||||||
void *readq;
|
void *readq;
|
||||||
int state;
|
int state;
|
||||||
void *wait[256];
|
void *wait[256];
|
||||||
uint ntag;
|
uint ntag;
|
||||||
uint nsleep;
|
uint nsleep;
|
||||||
Packet *part;
|
Packet *part;
|
||||||
|
@ -329,19 +330,19 @@ struct VtConn
|
||||||
Rendez rpcfork;
|
Rendez rpcfork;
|
||||||
char *version;
|
char *version;
|
||||||
char *uid;
|
char *uid;
|
||||||
char *sid;
|
char *sid;
|
||||||
char addr[256]; /* address of other side */
|
char addr[256]; /* address of other side */
|
||||||
};
|
};
|
||||||
|
|
||||||
VtConn *vtconn(int infd, int outfd);
|
VtConn* vtconn(int infd, int outfd);
|
||||||
VtConn *vtdial(char*);
|
VtConn* vtdial(char*);
|
||||||
void vtfreeconn(VtConn*);
|
void vtfreeconn(VtConn*);
|
||||||
int vtsend(VtConn*, Packet*);
|
int vtsend(VtConn*, Packet*);
|
||||||
Packet *vtrecv(VtConn*);
|
Packet* vtrecv(VtConn*);
|
||||||
int vtversion(VtConn *z);
|
int vtversion(VtConn* z);
|
||||||
void vtdebug(VtConn *z, char*, ...);
|
void vtdebug(VtConn* z, char*, ...);
|
||||||
void vthangup(VtConn *z);
|
void vthangup(VtConn* z);
|
||||||
int vtgoodbye(VtConn *z);
|
int vtgoodbye(VtConn* z);
|
||||||
|
|
||||||
/* #pragma varargck argpos vtdebug 2 */
|
/* #pragma varargck argpos vtdebug 2 */
|
||||||
|
|
||||||
|
@ -350,32 +351,32 @@ typedef struct VtSrv VtSrv;
|
||||||
typedef struct VtReq VtReq;
|
typedef struct VtReq VtReq;
|
||||||
struct VtReq
|
struct VtReq
|
||||||
{
|
{
|
||||||
VtFcall tx;
|
VtFcall tx;
|
||||||
VtFcall rx;
|
VtFcall rx;
|
||||||
/* private */
|
/* private */
|
||||||
VtSrv *srv;
|
VtSrv *srv;
|
||||||
void *sc;
|
void *sc;
|
||||||
};
|
};
|
||||||
|
|
||||||
int vtsrvhello(VtConn*);
|
int vtsrvhello(VtConn*);
|
||||||
VtSrv *vtlisten(char *addr);
|
VtSrv* vtlisten(char *addr);
|
||||||
VtReq *vtgetreq(VtSrv*);
|
VtReq* vtgetreq(VtSrv*);
|
||||||
void vtrespond(VtReq*);
|
void vtrespond(VtReq*);
|
||||||
|
|
||||||
/* client */
|
/* client */
|
||||||
Packet *vtrpc(VtConn*, Packet*);
|
Packet* vtrpc(VtConn*, Packet*);
|
||||||
Packet *_vtrpc(VtConn*, Packet*, VtFcall*);
|
Packet* _vtrpc(VtConn*, Packet*, VtFcall*);
|
||||||
void vtrecvproc(void*); /* VtConn* */
|
void vtrecvproc(void*); /* VtConn */
|
||||||
void vtsendproc(void*); /* VtConn* */
|
void vtsendproc(void*); /* VtConn */
|
||||||
|
|
||||||
int vtconnect(VtConn*);
|
int vtconnect(VtConn*);
|
||||||
int vthello(VtConn*);
|
int vthello(VtConn*);
|
||||||
int vtread(VtConn*, uchar score[VtScoreSize], uint type, uchar *buf, int n);
|
int vtread(VtConn*, uchar score[VtScoreSize], uint type, uchar *buf, int n);
|
||||||
int vtwrite(VtConn*, uchar score[VtScoreSize], uint type, uchar *buf, int n);
|
int vtwrite(VtConn*, uchar score[VtScoreSize], uint type, uchar *buf, int n);
|
||||||
Packet *vtreadpacket(VtConn*, uchar score[VtScoreSize], uint type, int n);
|
Packet* vtreadpacket(VtConn*, uchar score[VtScoreSize], uint type, int n);
|
||||||
int vtwritepacket(VtConn*, uchar score[VtScoreSize], uint type, Packet *p);
|
int vtwritepacket(VtConn*, uchar score[VtScoreSize], uint type, Packet *p);
|
||||||
int vtsync(VtConn*);
|
int vtsync(VtConn*);
|
||||||
int vtping(VtConn*);
|
int vtping(VtConn*);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data blocks and block cache.
|
* Data blocks and block cache.
|
||||||
|
@ -399,9 +400,9 @@ struct VtBlock
|
||||||
ulong size;
|
ulong size;
|
||||||
|
|
||||||
/* internal to cache */
|
/* internal to cache */
|
||||||
int nlock;
|
int nlock;
|
||||||
int iostate;
|
int iostate;
|
||||||
int ref;
|
int ref;
|
||||||
u32int heap;
|
u32int heap;
|
||||||
VtBlock *next;
|
VtBlock *next;
|
||||||
VtBlock **prev;
|
VtBlock **prev;
|
||||||
|
@ -411,19 +412,20 @@ struct VtBlock
|
||||||
uintptr pc;
|
uintptr pc;
|
||||||
};
|
};
|
||||||
|
|
||||||
u32int vtglobaltolocal(uchar[VtScoreSize]);
|
u32int vtglobaltolocal(uchar[VtScoreSize]);
|
||||||
void vtlocaltoglobal(u32int, uchar[VtScoreSize]);
|
void vtlocaltoglobal(u32int, uchar[VtScoreSize]);
|
||||||
|
|
||||||
VtCache *vtcachealloc(VtConn*, ulong maxmem);
|
VtCache*vtcachealloc(VtConn*, ulong maxmem);
|
||||||
void vtcachefree(VtCache*);
|
void vtcachefree(VtCache*);
|
||||||
VtBlock *vtcachelocal(VtCache*, u32int addr, int type);
|
VtBlock*vtcachelocal(VtCache*, u32int addr, int type);
|
||||||
VtBlock *vtcacheglobal(VtCache*, uchar[VtScoreSize], int type, ulong size);
|
VtBlock*vtcacheglobal(VtCache*, uchar[VtScoreSize], int type, ulong size);
|
||||||
VtBlock *vtcacheallocblock(VtCache*, int type, ulong size);
|
VtBlock*vtcacheallocblock(VtCache*, int type, ulong size);
|
||||||
void vtcachesetwrite(VtCache*, int(*)(VtConn*,uchar[VtScoreSize],uint,uchar*,int));
|
void vtcachesetwrite(VtCache*,
|
||||||
void vtblockput(VtBlock*);
|
int(*)(VtConn*, uchar[VtScoreSize], uint, uchar*, int));
|
||||||
int vtblockwrite(VtBlock*);
|
void vtblockput(VtBlock*);
|
||||||
VtBlock *vtblockcopy(VtBlock*);
|
int vtblockwrite(VtBlock*);
|
||||||
void vtblockduplock(VtBlock*);
|
VtBlock*vtblockcopy(VtBlock*);
|
||||||
|
void vtblockduplock(VtBlock*);
|
||||||
|
|
||||||
extern int vtcachencopy, vtcachenread, vtcachenwrite;
|
extern int vtcachencopy, vtcachenread, vtcachenwrite;
|
||||||
extern int vttracelevel;
|
extern int vttracelevel;
|
||||||
|
@ -434,23 +436,23 @@ extern int vttracelevel;
|
||||||
typedef struct VtFile VtFile;
|
typedef struct VtFile VtFile;
|
||||||
struct VtFile
|
struct VtFile
|
||||||
{
|
{
|
||||||
QLock lk;
|
QLock lk;
|
||||||
int ref;
|
int ref;
|
||||||
int local;
|
int local;
|
||||||
VtBlock *b; /* block containing this file */
|
VtBlock *b; /* block containing this file */
|
||||||
uchar score[VtScoreSize]; /* score of block containing this file */
|
uchar score[VtScoreSize]; /* score of block containing this file */
|
||||||
int bsize; /* size of block */
|
int bsize; /* size of block */
|
||||||
|
|
||||||
/* immutable */
|
/* immutable */
|
||||||
VtCache *c;
|
VtCache *c;
|
||||||
int mode;
|
int mode;
|
||||||
u32int gen;
|
u32int gen;
|
||||||
int dsize;
|
int dsize;
|
||||||
int psize;
|
int psize;
|
||||||
int dir;
|
int dir;
|
||||||
VtFile *parent;
|
VtFile *parent;
|
||||||
int epb; /* entries per block in parent */
|
int epb; /* entries per block in parent */
|
||||||
u32int offset; /* entry offset in parent */
|
u32int offset; /* entry offset in parent */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -460,32 +462,32 @@ enum
|
||||||
VtORDWR
|
VtORDWR
|
||||||
};
|
};
|
||||||
|
|
||||||
VtFile *vtfileopenroot(VtCache*, VtEntry*);
|
VtBlock*vtfileblock(VtFile*, u32int, int mode);
|
||||||
VtFile *vtfilecreateroot(VtCache*, int psize, int dsize, int type);
|
int vtfileblockscore(VtFile*, u32int, uchar[VtScoreSize]);
|
||||||
VtFile *vtfileopen(VtFile*, u32int, int);
|
void vtfileclose(VtFile*);
|
||||||
VtFile *vtfilecreate(VtFile*, int psize, int dsize, int dir);
|
VtFile* _vtfilecreate(VtFile*, int offset, int psize, int dsize, int dir);
|
||||||
VtFile *_vtfilecreate(VtFile*, int offset, int psize, int dsize, int dir);
|
VtFile* vtfilecreate(VtFile*, int psize, int dsize, int dir);
|
||||||
VtBlock *vtfileblock(VtFile*, u32int, int mode);
|
VtFile* vtfilecreateroot(VtCache*, int psize, int dsize, int type);
|
||||||
long vtfileread(VtFile*, void*, long, vlong);
|
int vtfileflush(VtFile*);
|
||||||
long vtfilewrite(VtFile*, void*, long, vlong);
|
int vtfileflushbefore(VtFile*, u64int);
|
||||||
int vtfileflush(VtFile*);
|
u32int vtfilegetdirsize(VtFile*);
|
||||||
void vtfileincref(VtFile*);
|
int vtfilegetentry(VtFile*, VtEntry*);
|
||||||
void vtfileclose(VtFile*);
|
uvlong vtfilegetsize(VtFile*);
|
||||||
int vtfilegetentry(VtFile*, VtEntry*);
|
void vtfileincref(VtFile*);
|
||||||
int vtfilesetentry(VtFile*, VtEntry*);
|
int vtfilelock2(VtFile*, VtFile*, int);
|
||||||
int vtfileblockscore(VtFile*, u32int, uchar[VtScoreSize]);
|
int vtfilelock(VtFile*, int);
|
||||||
u32int vtfilegetdirsize(VtFile*);
|
VtFile* vtfileopen(VtFile*, u32int, int);
|
||||||
int vtfilesetdirsize(VtFile*, u32int);
|
VtFile* vtfileopenroot(VtCache*, VtEntry*);
|
||||||
|
long vtfileread(VtFile*, void*, long, vlong);
|
||||||
|
int vtfileremove(VtFile*);
|
||||||
|
int vtfilesetdirsize(VtFile*, u32int);
|
||||||
|
int vtfilesetentry(VtFile*, VtEntry*);
|
||||||
|
int vtfilesetsize(VtFile*, u64int);
|
||||||
|
int vtfiletruncate(VtFile*);
|
||||||
void vtfileunlock(VtFile*);
|
void vtfileunlock(VtFile*);
|
||||||
int vtfilelock(VtFile*, int);
|
long vtfilewrite(VtFile*, void*, long, vlong);
|
||||||
int vtfilelock2(VtFile*, VtFile*, int);
|
|
||||||
int vtfileflushbefore(VtFile*, u64int);
|
|
||||||
int vtfiletruncate(VtFile*);
|
|
||||||
uvlong vtfilegetsize(VtFile*);
|
|
||||||
int vtfilesetsize(VtFile*, u64int);
|
|
||||||
int vtfileremove(VtFile*);
|
|
||||||
|
|
||||||
extern int vttimefmt(Fmt*);
|
int vttimefmt(Fmt*);
|
||||||
|
|
||||||
extern int chattyventi;
|
extern int chattyventi;
|
||||||
extern int ventidoublechecksha1;
|
extern int ventidoublechecksha1;
|
||||||
|
|
Loading…
Reference in a new issue