|
|
1.1 root 1:
2: static Inode *inodes;
3: static long ip;
4: static long ninodes = 0;
5: static char *nameb;
6: static long np;
7: static long nnameb = 0;
8: static long nblocks;
9: #define IINC 1024
10: #define NINC (64*IINC)
11:
12: ininit()
13: {
14: if(nnameb == 0){
15: nameb = malloc((unsigned)(nnameb = NINC));
16: if(nameb == 0){
17: fprint(2, "wmv: malloc fail, %d bytes\n", nnameb);
18: exit(1);
19: }
20: }
21: np = 0;
22: if(ninodes == 0){
23: inodes = (Inode *)malloc(sizeof(Inode)*(unsigned)(ninodes = IINC));
24: if(inodes == 0){
25: fprint(2, "wmv: malloc fail, %d inodes %d bytes\n", ninodes, ninodes*sizeof(Inode));
26: exit(1);
27: }
28: }
29: ip = 0;
30: }
31:
32: inadd(s, i)
33: Superblock *s;
34: register Inode *i;
35: {
36: register long len;
37:
38: len = strlen(i->name.n)+1;
39: if(np+len > nnameb){
40: while(np+len > nnameb)
41: nnameb += NINC;
42: nameb = realloc(nameb, (unsigned)nnameb);
43: if(nameb == 0){
44: fprint(2, "wmv: realloc fail, %d bytes\n", nnameb);
45: exit(1);
46: }
47: }
48: strcpy(nameb+np, i->name.n);
49: i->name.o = np;
50: np += len;
51: if(ip == ninodes){
52: ninodes += IINC;
53: inodes = (Inode *)realloc((char *)inodes, (unsigned)ninodes*sizeof(Inode));
54: if(inodes == 0){
55: fprint(2, "wmv: realloc fail, %d inodes %d bytes\n", ninodes, ninodes*sizeof(Inode));
56: exit(1);
57: }
58: }
59: inodes[ip++] = *i;
60: }
61:
62: inwrite(s)
63: Superblock *s;
64: {
65: char *e;
66:
67: if(e = lkwri(s, inodes, ip, nameb, np, 0L)){
68: fprint(2, "%s\n", e);
69: return(1);
70: }
71: return(0);
72: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.