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