1: char *dargv[]
2: {
3: 0,
4: "/dev/rk2",
5: "/dev/rp0",
6: 0
7: };
8: struct
9: {
10: char *s_isize;
11: char *s_fsize;
12: int s_nfree;
13: int s_free[100];
14: int s_ninode;
15: int s_inode[100];
16: char s_flock;
17: char s_ilock;
18: char s_fmod;
19: int time[2];
20: int pad[50];
21: } sblock;
22:
23: int fi;
24:
25: main(argc, argv)
26: char **argv;
27: {
28: int i;
29:
30: if(argc <= 1) {
31: for(argc = 1; dargv[argc]; argc++);
32: argv = dargv;
33: }
34:
35: for(i=1; i<argc; i++) {
36: if(argc > 1)
37: printf("%s ", argv[i]);
38: dfree(argv[i]);
39: }
40: }
41:
42: dfree(file)
43: char *file;
44: {
45: int i;
46:
47: fi = open(file, 0);
48: if(fi < 0) {
49: printf("cannot open %s\n", file);
50: return;
51: }
52: sync();
53: bread(1, &sblock);
54: i = 0;
55: while(alloc())
56: i++;
57: printf("%l\n", i);
58: close(fi);
59: }
60:
61: alloc()
62: {
63: int b, i, buf[256];
64:
65: i = --sblock.s_nfree;
66: if(i<0 || i>=100) {
67: printf("bad free count\n");
68: return(0);
69: }
70: b = sblock.s_free[i];
71: if(b == 0)
72: return(0);
73: if(b<sblock.s_isize+2 || b>=sblock.s_fsize) {
74: printf("bad free block (%l)\n", b);
75: return(0);
76: }
77: if(sblock.s_nfree <= 0) {
78: bread(b, buf);
79: sblock.s_nfree = buf[0];
80: for(i=0; i<100; i++)
81: sblock.s_free[i] = buf[i+1];
82: }
83: return(b);
84: }
85:
86: bread(bno, buf)
87: {
88: int n;
89: extern errno;
90:
91: seek(fi, bno, 3);
92: if((n=read(fi, buf, 512)) != 512) {
93: printf("read error %d\n", bno);
94: printf("count = %d; errno = %d\n", n, errno);
95: exit();
96: }
97: }
Defined functions
alloc
defined in line
61; used 2 times
bread
defined in line
86; used 2 times
dfree
defined in line
42; used 1 times
main
defined in line
25;
never used
Defined variables
dargv
defined in line
1; used 2 times
fi
defined in line
23; used 5 times