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