|
|
1.1 root 1: #include "cbt.h"
2:
3: extern bfile *curbf;
4: extern long lseek();
5:
6: ndwrt(b, where) hdr *b; ndaddr where;
7: {
8: if(lseek(curbf->tfd, where * (long)NDSZ, 0) == -1)
9: return(EOF);
10: if(write(curbf->tfd, (char *)b, NDSZ) != NDSZ) { /*unacceptable*/
11: errno = BIOWRT;
12: curbf->fatal++;
13: return(EOF);
14: }
15: return(0);
16: }
17:
18: long brecwrite(rec) mbuf rec;
19: { long loc;
20: int n;
21: errno = 0;
22: loc = lseek(curbf->dfd, 0L, 2);
23: if((n = write(curbf->dfd, rec.mdata, rec.mlen)) == rec.mlen)
24: return(loc);
25: else if(n == -1 || errno)
26: return(EOF);
27: errno = BIOWRT;
28: return(EOF);
29: }
30:
31: ndaddr newnode(b) hdr *b;
32: { long loc;
33: int n;
34: b->hstamp = tranid;
35: loc = lseek(curbf->tfd, 0L, 2);
36: if(loc == -1)
37: return(EOF);
38: if((n = write(curbf->tfd, (char *)b, NDSZ)) != NDSZ)
39: if(n < 0)
40: return(EOF);
41: else {
42: errno = BIOWRT;
43: return(EOF);
44: }
45: return(loc/NDSZ);
46: }
47:
48: ndaddr oldnode(lev)
49: { int n;
50: ndaddr a;
51: if(curbf->path[lev]->hstamp != tranid) {
52: a = newnode(curbf->path[lev]);
53: if(a == EOF)
54: curbf->fatal++;
55: curbf->loc[lev] = a;
56: return(a);
57: }
58: if(lseek(curbf->tfd, (long)curbf->loc[lev]*NDSZ, 0) == EOF)
59: return(EOF);
60: if((n = write(curbf->tfd, (char *)curbf->path[lev], NDSZ)) != NDSZ) {
61: if(n >= 0)
62: errno = BIOWRT;
63: return(EOF);
64: }
65: mustwrite(curbf, lev) = 0;
66: return(curbf->loc[lev]);
67: }
68: static struct D { struct D *a; char *b;} VER = {&VER,"\n81/8/9:diskwrt.c\n"};
69: /*0100101010000110*/
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.