Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!psuvax1!gatech!rebel!george From: george@rebel.UUCP (George M. Sipe) Newsgroups: comp.sources.d Subject: Re: v08i093: System V disk compactor Summary: patches for pcc Keywords: packdisk pcc patches Message-ID: <1383@rebel.UUCP> Date: 12 Oct 89 03:09:36 GMT References: <69626@uunet.UU.NET> Reply-To: george@rebel.UUCP (George M. Sipe) Organization: not yet Lines: 1390 I've just tested Andy Fyfe's "packdisk" posted to comp.sources.misc, volume 8, issue 93. It's great! Thanks Andy. My system is a UniPlus System V.0 and packdisk worked without fault. When done, fsck reported no problems. Even sparse files (history DBM stuff) were handle correctly (fsck bitches about that, always does). Using Michael Young's "fsanalyze" before and after the "packing" of a 20 MB partition produced the following output: before> File system name = "u", Volume name = "w00c" before> Logical block size = 1024 bytes before> Interleave = 1 sectors; 136 sectors/cyl before> Volume Size = 17272 blocks (17686528 bytes) before> 271 blocks reserved for super block and inodes (4304 inodes) before> 17001 blocks reserved for data before> 38.50% inodes used (1657 used, 2647 free) before> 78.08% data blocks used (13274 used, 3727 free) before> before> Fragmentation = 37.70% Special files = 0 (0.00%) before> Average Seek Distance = 57.31 cyls Indirect files = 154 (9.29%) before> Rotation delays = 4.22% Double indirects = 7 (0.42%) before> Multiply-linked files = 181 (10.92%) Triple indirects = 0 (0.00%) before> Directories = 85 (5.13%) Indirection blks = 172 (1.01%) before> Oversized directories = 0 (0.00%) Sparse files = 1 (0.06%) before> Unused bytes in last blocks = 961397 (5.44%) after> File system name = "u", Volume name = "w00c" after> Logical block size = 1024 bytes after> Interleave = 1 sectors; 136 sectors/cyl after> Volume Size = 17272 blocks (17686528 bytes) after> 271 blocks reserved for super block and inodes (4304 inodes) after> 17001 blocks reserved for data after> 38.50% inodes used (1657 used, 2647 free) after> 78.08% data blocks used (13274 used, 3727 free) after> after> Fragmentation = 0.96% Special files = 0 (0.00%) after> Average Seek Distance = 1.60 cyls Indirect files = 154 (9.29%) after> Rotation delays = 0.08% Double indirects = 7 (0.42%) after> Multiply-linked files = 181 (10.92%) Triple indirects = 0 (0.00%) after> Directories = 85 (5.13%) Indirection blks = 172 (1.01%) after> Oversized directories = 0 (0.00%) Sparse files = 1 (0.06%) after> Unused bytes in last blocks = 961397 (5.44%) Quite an improvement. "Feels" faster too. On my aging 68K system, this took about 3 hours to complete. Packdisk showed it's progess (inode #) as it went. Your mileage may vary... be sure to backup everything before starting. In his posting, Andy noted: > Though this program was developed on a 3b1, it was written with > portability in mind (yes, I know -- you can stop laughing now!). > Perhaps other systems with the System V file system (inherited from > V7?) can also use the program, or adapt it to their needs. Well, it is very portable, except for using gcc as the implementation base. Not to take away from gcc, it's just that some of us (me for instance) don't have it up and are stuck with pcc for now. That mean's, among other things no function prototypes. Slight hacking on the source to allow "OLDC" (#ifdef'ed) produced the following patch file. While I was at it, I also put a few casts in place to humor lint. Again, works well for me... your mileage may vary. Regards, George M. Sipe, Phone: (404) 447-4731 537 Lakeshore Drive, Berkeley Lake, GA 30136-3035 UUCP: ...!{decvax,linus,rutgers}!gatech!rebel!george *** opackdisk.c Wed Oct 11 21:41:07 1989 --- packdisk.c Wed Oct 11 21:42:50 1989 *************** *** 9,14 * andy@csvax.caltech.edu */ #include #include #include --- 9,19 ----- * andy@csvax.caltech.edu */ + #ifndef OLDC + #include + #endif + #include + #include #include #include #include *************** *** 13,19 #include #include #include - #include #define NUM_ADDR 13 #define FIRST_INDIR 10 /* 0-9 direct, 10 single, 11 double, 12 triple */ --- 18,23 ----- #include #include #include #ifndef OLDC #define FsBSIZEdev FsBSIZE(dev) *************** *** 15,20 #include #include #define NUM_ADDR 13 #define FIRST_INDIR 10 /* 0-9 direct, 10 single, 11 double, 12 triple */ #define NUM_INDIR (NUM_ADDR - FIRST_INDIR) --- 19,30 ----- #include #include + #ifndef OLDC + #define FsBSIZEdev FsBSIZE(dev) + #else + #define FsBSIZEdev 1024 /* BE SURE THIS IS OK FOR YOU */ + #endif + #define NUM_ADDR 13 #define FIRST_INDIR 10 /* 0-9 direct, 10 single, 11 double, 12 triple */ #define NUM_INDIR (NUM_ADDR - FIRST_INDIR) *************** *** 39,44 long *map; /* a map from block numbers to referencing inode/indir block */ static void read_superblk(void); static void write_superblk(void); static void map_inode(ino_t inode); --- 49,55 ----- long *map; /* a map from block numbers to referencing inode/indir block */ + #ifndef OLDC static void read_superblk(void); static void write_superblk(void); static void map_inode(ino_t inode); *************** *** 55,60 extern void l3tol(long *, char *, int length); extern void ltol3(char *, long *, int length); void main(int argc, char *argv[]) --- 66,80 ----- extern void l3tol(long *, char *, int length); extern void ltol3(char *, long *, int length); + #else + #define move_indirect Move_Indirect /* make uniq */ + extern char *calloc(); + extern char *malloc(); + extern char *memcpy(); + extern char *memset(); + extern long lseek(); + extern void exit(); + extern void perror(); static void read_superblk(); static void write_superblk(); *************** *** 56,63 extern void l3tol(long *, char *, int length); extern void ltol3(char *, long *, int length); ! void ! main(int argc, char *argv[]) { ino_t inode, total_inodes; daddr_t block; --- 76,102 ----- extern void exit(); extern void perror(); ! static void read_superblk(); ! static void write_superblk(); ! static void map_inode(); ! static void update_map(); ! static void read_block(); ! static void write_block(); ! static void read_inode(); ! static void write_inode(); ! static void move_block(); ! static void move_inode(); ! static void move_indirect(); ! static void make_hole(); ! static void rebuild_free_list(); ! ! extern void l3tol(); ! extern void ltol3(); ! #endif ! ! int main(argc, argv) ! int argc; ! char *argv[]; { ino_t inode, total_inodes; daddr_t block; *************** *** 62,67 ino_t inode, total_inodes; daddr_t block; int i; char *ctime(long *); #ifndef DEBUG struct stat statb; --- 101,107 ----- ino_t inode, total_inodes; daddr_t block; int i; + #ifndef OLDC char *ctime(long *); #ifndef DEBUG struct stat statb; *************** *** 67,72 struct stat statb; extern int stat(const char *, struct stat *); #endif cmd_name = argv[0]; --- 107,119 ----- struct stat statb; extern int stat(const char *, struct stat *); #endif + #else + char *ctime(); + #ifndef DEBUG + struct stat statb; + extern int stat(); + #endif + #endif cmd_name = argv[0]; *************** *** 71,77 cmd_name = argv[0]; if (argc != 2) { ! fprintf(stderr, "%s: Usage: %s \n", cmd_name, cmd_name); exit(1); } --- 118,124 ----- cmd_name = argv[0]; if (argc != 2) { ! (void) fprintf(stderr, "%s: Usage: %s \n", cmd_name, cmd_name); exit(1); } *************** *** 78,84 #ifndef DEBUG if (stat(argv[1], &statb) < 0) { ! fprintf(stderr, "%s: can't stat %s: ", cmd_name, argv[1]); perror(""); exit(1); } --- 125,131 ----- #ifndef DEBUG if (stat(argv[1], &statb) < 0) { ! (void) fprintf(stderr, "%s: can't stat %s: ", cmd_name, argv[1]); perror(""); exit(1); } *************** *** 83,89 exit(1); } if ((statb.st_mode & S_IFMT) != S_IFCHR) { ! fprintf(stderr, "%s: %s is not a character device\n", cmd_name, argv[1]); exit(1); } --- 130,136 ----- exit(1); } if ((statb.st_mode & S_IFMT) != S_IFCHR) { ! (void) fprintf(stderr, "%s: %s is not a character device\n", cmd_name, argv[1]); exit(1); } *************** *** 91,97 disk = open(argv[1], 2, 0); if (disk < 0) { ! fprintf(stderr, "%s: can't open %s: ", cmd_name, argv[1]); perror(""); exit(1); } --- 138,144 ----- disk = open(argv[1], 2, 0); if (disk < 0) { ! (void) fprintf(stderr, "%s: can't open %s: ", cmd_name, argv[1]); perror(""); exit(1); } *************** *** 99,105 read_superblk(); total_inodes = (filsys.s_isize - FsITOD(dev, ROOTINO)) * FsINOPB(dev); ! fprintf(stderr, "File system: name: \"%.6s\", pack: \"%.6s\"\n", filsys.s_fname, filsys.s_fpack); fprintf(stderr, "\tlast modified on %s", ctime(&filsys.s_time)); fprintf(stderr, --- 146,152 ----- read_superblk(); total_inodes = (filsys.s_isize - FsITOD(dev, ROOTINO)) * FsINOPB(dev); ! (void) fprintf(stderr, "File system: name: \"%.6s\", pack: \"%.6s\"\n", filsys.s_fname, filsys.s_fpack); (void) fprintf(stderr, "\tlast modified on %s", ctime(&filsys.s_time)); (void) fprintf(stderr, *************** *** 101,108 total_inodes = (filsys.s_isize - FsITOD(dev, ROOTINO)) * FsINOPB(dev); fprintf(stderr, "File system: name: \"%.6s\", pack: \"%.6s\"\n", filsys.s_fname, filsys.s_fpack); ! fprintf(stderr, "\tlast modified on %s", ctime(&filsys.s_time)); ! fprintf(stderr, "\ttotal inodes = %d, data blocks = %d, total = %d blocks\n", total_inodes, filsys.s_fsize - filsys.s_isize, filsys.s_fsize); fprintf(stderr, "\tfree blocks = %d, free inodes = %d\n", --- 148,155 ----- total_inodes = (filsys.s_isize - FsITOD(dev, ROOTINO)) * FsINOPB(dev); (void) fprintf(stderr, "File system: name: \"%.6s\", pack: \"%.6s\"\n", filsys.s_fname, filsys.s_fpack); ! (void) fprintf(stderr, "\tlast modified on %s", ctime(&filsys.s_time)); ! (void) fprintf(stderr, "\ttotal inodes = %d, data blocks = %d, total = %d blocks\n", total_inodes, filsys.s_fsize - filsys.s_isize, filsys.s_fsize); (void) fprintf(stderr, "\tfree blocks = %d, free inodes = %d\n", *************** *** 105,111 fprintf(stderr, "\ttotal inodes = %d, data blocks = %d, total = %d blocks\n", total_inodes, filsys.s_fsize - filsys.s_isize, filsys.s_fsize); ! fprintf(stderr, "\tfree blocks = %d, free inodes = %d\n", filsys.s_tfree, filsys.s_tinode); for (i = 0; i < NUM_INDIR; ++i) { --- 152,158 ----- (void) fprintf(stderr, "\ttotal inodes = %d, data blocks = %d, total = %d blocks\n", total_inodes, filsys.s_fsize - filsys.s_isize, filsys.s_fsize); ! (void) fprintf(stderr, "\tfree blocks = %d, free inodes = %d\n", filsys.s_tfree, filsys.s_tinode); for (i = 0; i < NUM_INDIR; ++i) { *************** *** 110,116 for (i = 0; i < NUM_INDIR; ++i) { w_indir[i] = 0; ! indir[i] = malloc(FsBSIZE(dev)); if (indir[i] == 0) { fprintf(stderr, "%s: can't malloc indir buffer space: ", cmd_name); perror(""); --- 157,163 ----- for (i = 0; i < NUM_INDIR; ++i) { w_indir[i] = 0; ! indir[i] = (char *) malloc((unsigned) FsBSIZE(dev)); if (indir[i] == 0) { (void) fprintf(stderr, "%s: can't malloc indir buffer space: ", cmd_name); *************** *** 112,118 w_indir[i] = 0; indir[i] = malloc(FsBSIZE(dev)); if (indir[i] == 0) { ! fprintf(stderr, "%s: can't malloc indir buffer space: ", cmd_name); perror(""); exit(1); } --- 159,166 ----- w_indir[i] = 0; indir[i] = (char *) malloc((unsigned) FsBSIZE(dev)); if (indir[i] == 0) { ! (void) fprintf(stderr, "%s: can't malloc indir buffer space: ", ! cmd_name); perror(""); exit(1); } *************** *** 119,125 } w_ino = 0; ! map = calloc(filsys.s_fsize, sizeof(*map)); if (map == 0) { fprintf(stderr, "%s: can't calloc map: ", cmd_name); perror(""); --- 167,173 ----- } w_ino = 0; ! map = (long *) calloc((unsigned) filsys.s_fsize, sizeof(*map)); if (map == 0) { (void) fprintf(stderr, "%s: can't calloc map: ", cmd_name); perror(""); *************** *** 121,127 map = calloc(filsys.s_fsize, sizeof(*map)); if (map == 0) { ! fprintf(stderr, "%s: can't calloc map: ", cmd_name); perror(""); exit(1); } --- 169,175 ----- map = (long *) calloc((unsigned) filsys.s_fsize, sizeof(*map)); if (map == 0) { ! (void) fprintf(stderr, "%s: can't calloc map: ", cmd_name); perror(""); exit(1); } *************** *** 126,132 exit(1); } ! inode_table = malloc(filsys.s_isize * FsBSIZE(dev)); if (inode_table == 0) { fprintf(stderr, "%s: can't malloc space for inode table\n", cmd_name); w_ino_blk = 0; --- 174,180 ----- exit(1); } ! inode_table = (char *) malloc(filsys.s_isize * FsBSIZE(dev)); if (inode_table == 0) { (void) fprintf(stderr, "%s: can't malloc space for inode table\n", cmd_name); *************** *** 128,134 inode_table = malloc(filsys.s_isize * FsBSIZE(dev)); if (inode_table == 0) { ! fprintf(stderr, "%s: can't malloc space for inode table\n", cmd_name); w_ino_blk = 0; inode_block = malloc(FsBSIZE(dev)); if (inode_block == 0) { --- 176,183 ----- inode_table = (char *) malloc(filsys.s_isize * FsBSIZE(dev)); if (inode_table == 0) { ! (void) fprintf(stderr, "%s: can't malloc space for inode table\n", ! cmd_name); w_ino_blk = 0; inode_block = (char *) malloc((unsigned) FsBSIZE(dev)); if (inode_block == 0) { *************** *** 130,136 if (inode_table == 0) { fprintf(stderr, "%s: can't malloc space for inode table\n", cmd_name); w_ino_blk = 0; ! inode_block = malloc(FsBSIZE(dev)); if (inode_block == 0) { fprintf(stderr, "%s: can't malloc inode buffer space: ", cmd_name); perror(""); --- 179,185 ----- (void) fprintf(stderr, "%s: can't malloc space for inode table\n", cmd_name); w_ino_blk = 0; ! inode_block = (char *) malloc((unsigned) FsBSIZE(dev)); if (inode_block == 0) { (void) fprintf(stderr, "%s: can't malloc inode buffer space: ", cmd_name); *************** *** 132,138 w_ino_blk = 0; inode_block = malloc(FsBSIZE(dev)); if (inode_block == 0) { ! fprintf(stderr, "%s: can't malloc inode buffer space: ", cmd_name); perror(""); exit(1); } --- 181,188 ----- w_ino_blk = 0; inode_block = (char *) malloc((unsigned) FsBSIZE(dev)); if (inode_block == 0) { ! (void) fprintf(stderr, "%s: can't malloc inode buffer space: ", ! cmd_name); perror(""); exit(1); } *************** *** 141,147 for (block = FsITOD(dev, ROOTINO); block < filsys.s_isize; ++block) read_block(block, &inode_table[block * FsBSIZE(dev)]); ! fprintf(stderr, "mapping..."); for (inode = ROOTINO; inode <= total_inodes; ++inode) map_inode(inode); fprintf(stderr, "done\n"); --- 191,197 ----- for (block = FsITOD(dev, ROOTINO); block < filsys.s_isize; ++block) read_block(block, &inode_table[block * FsBSIZE(dev)]); ! (void) fprintf(stderr, "mapping..."); for (inode = ROOTINO; inode <= total_inodes; ++inode) map_inode(inode); (void) fprintf(stderr, "done\n"); *************** *** 144,150 fprintf(stderr, "mapping..."); for (inode = ROOTINO; inode <= total_inodes; ++inode) map_inode(inode); ! fprintf(stderr, "done\n"); next_fill = filsys.s_isize; for (inode = ROOTINO; inode <= total_inodes; ++inode) --- 194,200 ----- (void) fprintf(stderr, "mapping..."); for (inode = ROOTINO; inode <= total_inodes; ++inode) map_inode(inode); ! (void) fprintf(stderr, "done\n"); next_fill = filsys.s_isize; for (inode = ROOTINO; inode <= total_inodes; ++inode) *************** *** 150,156 for (inode = ROOTINO; inode <= total_inodes; ++inode) move_inode(inode); ! fprintf(stderr, "\nrebuilding the free list\n"); rebuild_free_list(); fprintf(stderr, "*** Run fsck to check out the disk!!!\n"); --- 200,206 ----- for (inode = ROOTINO; inode <= total_inodes; ++inode) move_inode(inode); ! (void) fprintf(stderr, "\nrebuilding the free list\n"); rebuild_free_list(); (void) fprintf(stderr, "*** Run fsck to check out the disk!!!\n"); *************** *** 153,159 fprintf(stderr, "\nrebuilding the free list\n"); rebuild_free_list(); ! fprintf(stderr, "*** Run fsck to check out the disk!!!\n"); close(disk); exit(0); --- 203,209 ----- (void) fprintf(stderr, "\nrebuilding the free list\n"); rebuild_free_list(); ! (void) fprintf(stderr, "*** Run fsck to check out the disk!!!\n"); (void) close(disk); exit(0); *************** *** 155,161 fprintf(stderr, "*** Run fsck to check out the disk!!!\n"); ! close(disk); exit(0); } --- 205,211 ----- (void) fprintf(stderr, "*** Run fsck to check out the disk!!!\n"); ! (void) close(disk); exit(0); } *************** *** 159,166 exit(0); } ! static void ! read_superblk(void) { if (lseek(disk, SUPERBOFF, 0) != SUPERBOFF) { fprintf(stderr, "%s: can't seek to superblock: ", cmd_name); --- 209,215 ----- exit(0); } ! static void read_superblk() { if (lseek(disk, SUPERBOFF, 0) != (long) SUPERBOFF) { (void) fprintf(stderr, "%s: can't seek to superblock: ", cmd_name); *************** *** 162,169 static void read_superblk(void) { ! if (lseek(disk, SUPERBOFF, 0) != SUPERBOFF) { ! fprintf(stderr, "%s: can't seek to superblock: ", cmd_name); perror(""); exit(1); } --- 211,218 ----- static void read_superblk() { ! if (lseek(disk, SUPERBOFF, 0) != (long) SUPERBOFF) { ! (void) fprintf(stderr, "%s: can't seek to superblock: ", cmd_name); perror(""); exit(1); } *************** *** 168,174 exit(1); } if (read(disk, &filsys, sizeof(filsys)) != sizeof(filsys)) { ! fprintf(stderr, "%s: can't read superblock: ", cmd_name); perror(""); exit(1); } --- 217,223 ----- exit(1); } if (read(disk, &filsys, sizeof(filsys)) != sizeof(filsys)) { ! (void) fprintf(stderr, "%s: can't read superblock: ", cmd_name); perror(""); exit(1); } *************** *** 173,179 exit(1); } if (filsys.s_magic != FsMAGIC) { ! fprintf(stderr, "%s: invalid superblock magic number\n", cmd_name); exit(1); } dev = (filsys.s_type == Fs2b) ? Fs2BLK : 0; --- 222,229 ----- exit(1); } if (filsys.s_magic != FsMAGIC) { ! (void) fprintf(stderr, "%s: invalid superblock magic number\n", ! cmd_name); exit(1); } dev = (filsys.s_type == Fs2b) ? Fs2BLK : 0; *************** *** 179,186 dev = (filsys.s_type == Fs2b) ? Fs2BLK : 0; } ! static void ! write_superblk(void) { lseek(disk, SUPERBOFF, 0); if (write(disk, &filsys, sizeof(filsys)) != sizeof(filsys)) { --- 229,235 ----- dev = (filsys.s_type == Fs2b) ? Fs2BLK : 0; } ! static void write_superblk() { if (lseek(disk, SUPERBOFF, 0) == -1L || write(disk, &filsys, sizeof(filsys)) != sizeof(filsys)) { *************** *** 182,190 static void write_superblk(void) { ! lseek(disk, SUPERBOFF, 0); ! if (write(disk, &filsys, sizeof(filsys)) != sizeof(filsys)) { ! fprintf(stderr, "%s: can't write superblock: ", cmd_name); perror(""); exit(1); } --- 231,239 ----- static void write_superblk() { ! if (lseek(disk, SUPERBOFF, 0) == -1L ! || write(disk, &filsys, sizeof(filsys)) != sizeof(filsys)) { ! (void) fprintf(stderr, "%s: can't write superblock: ", cmd_name); perror(""); exit(1); } *************** *** 190,197 } } ! static void ! map_inode(ino_t inode) { int type, i; long block[NUM_ADDR]; --- 239,246 ----- } } ! static void map_inode(inode) ! ino_t inode; { int type, i; long block[NUM_ADDR]; *************** *** 206,212 l3tol(block, ino.di_addr, NUM_ADDR); for (i = 0; i < NUM_ADDR; ++i) if (block[i] != 0) ! update_map(inode, block[i], (i < FIRST_INDIR) ? 0 : (i - FIRST_INDIR + 1)); } --- 255,261 ----- l3tol(block, ino.di_addr, NUM_ADDR); for (i = 0; i < NUM_ADDR; ++i) if (block[i] != 0) ! update_map((long) inode, block[i], (i < FIRST_INDIR) ? 0 : (i - FIRST_INDIR + 1)); } *************** *** 210,217 (i < FIRST_INDIR) ? 0 : (i - FIRST_INDIR + 1)); } ! static void ! update_map(long map_entry, daddr_t block, int level) { int i; --- 259,268 ----- (i < FIRST_INDIR) ? 0 : (i - FIRST_INDIR + 1)); } ! static void update_map(map_entry, block, level) ! long map_entry; ! daddr_t block; ! int level; { int i; *************** *** 216,222 int i; if (map[block] != 0) { ! fprintf(stderr, "%s: duplicate block %d in %d and %d\n", cmd_name, block, map[block], map_entry); exit(1); } --- 267,273 ----- int i; if (map[block] != 0) { ! (void) fprintf(stderr, "%s: duplicate block %d in %d and %d\n", cmd_name, block, map[block], map_entry); exit(1); } *************** *** 232,239 update_map(-block, ((daddr_t *)indir[level])[i], level); } ! static void ! read_block(daddr_t block, void *buf) { lseek(disk, block * FsBSIZE(dev), 0); if (read(disk, buf, FsBSIZE(dev)) != FsBSIZE(dev)) { --- 283,291 ----- update_map(-block, ((daddr_t *)indir[level])[i], level); } ! static void read_block(block, buf) ! daddr_t block; ! char *buf; { if (lseek(disk, block * FsBSIZE(dev), 0) == -1L || read(disk, buf, (unsigned) FsBSIZE(dev)) != FsBSIZE(dev)) { *************** *** 235,243 static void read_block(daddr_t block, void *buf) { ! lseek(disk, block * FsBSIZE(dev), 0); ! if (read(disk, buf, FsBSIZE(dev)) != FsBSIZE(dev)) { ! fprintf(stderr, "%s: can't read block %d: ", cmd_name, block); perror(""); exit(1); } --- 287,295 ----- daddr_t block; char *buf; { ! if (lseek(disk, block * FsBSIZE(dev), 0) == -1L ! || read(disk, buf, (unsigned) FsBSIZE(dev)) != FsBSIZE(dev)) { ! (void) fprintf(stderr, "%s: can't read block %d: ", cmd_name, block); perror(""); exit(1); } *************** *** 243,250 } } ! static void ! write_block(daddr_t block, void *buf) { lseek(disk, block * FsBSIZE(dev), 0); if (write(disk, buf, FsBSIZE(dev)) != FsBSIZE(dev)) { --- 295,303 ----- } } ! static void write_block(block, buf) ! daddr_t block; ! char *buf; { if (lseek(disk, block * FsBSIZE(dev), 0) == -1L || write(disk, buf, (unsigned) FsBSIZE(dev)) != FsBSIZE(dev)) { *************** *** 246,254 static void write_block(daddr_t block, void *buf) { ! lseek(disk, block * FsBSIZE(dev), 0); ! if (write(disk, buf, FsBSIZE(dev)) != FsBSIZE(dev)) { ! fprintf(stderr, "%s: can't write block %d: ", cmd_name, block); perror(""); exit(1); } --- 299,307 ----- daddr_t block; char *buf; { ! if (lseek(disk, block * FsBSIZE(dev), 0) == -1L ! || write(disk, buf, (unsigned) FsBSIZE(dev)) != FsBSIZE(dev)) { ! (void) fprintf(stderr, "%s: can't write block %d: ", cmd_name, block); perror(""); exit(1); } *************** *** 254,261 } } ! static void ! read_inode(ino_t inode, struct dinode *ino) { daddr_t block; --- 307,315 ----- } } ! static void read_inode(inode, the_ino) ! ino_t inode; ! struct dinode *the_ino; { daddr_t block; *************** *** 265,271 w_ino_blk = block; read_block(block, inode_block); } ! *ino = ((struct dinode *)inode_block)[FsITOO(dev, inode)]; } else { *ino = ((struct dinode *)&inode_table[block * FsBSIZE(dev)]) --- 319,325 ----- w_ino_blk = block; read_block(block, inode_block); } ! *the_ino = ((struct dinode *)inode_block)[FsITOO(dev, inode)]; } else { *the_ino = ((struct dinode *)&inode_table[block * FsBSIZE(dev)]) *************** *** 268,274 *ino = ((struct dinode *)inode_block)[FsITOO(dev, inode)]; } else { ! *ino = ((struct dinode *)&inode_table[block * FsBSIZE(dev)]) [FsITOO(dev, inode)]; } } --- 322,328 ----- *the_ino = ((struct dinode *)inode_block)[FsITOO(dev, inode)]; } else { ! *the_ino = ((struct dinode *)&inode_table[block * FsBSIZE(dev)]) [FsITOO(dev, inode)]; } } *************** *** 273,280 } } ! static void ! write_inode(ino_t inode, struct dinode *ino) { daddr_t block; --- 327,335 ----- } } ! static void write_inode(inode, the_ino) ! ino_t inode; ! struct dinode *the_ino; { daddr_t block; *************** *** 284,290 w_ino_blk = block; read_block(block, inode_block); } ! ((struct dinode *)inode_block)[FsITOO(dev, inode)] = *ino; write_block(block, inode_block); } else { --- 339,345 ----- w_ino_blk = block; read_block(block, inode_block); } ! ((struct dinode *)inode_block)[FsITOO(dev, inode)] = *the_ino; write_block(block, inode_block); } else { *************** *** 289,295 } else { ((struct dinode *)&inode_table[block * FsBSIZE(dev)]) ! [FsITOO(dev, inode)] = *ino; write_block(block, &inode_table[block * FsBSIZE(dev)]); } } --- 344,350 ----- } else { ((struct dinode *)&inode_table[block * FsBSIZE(dev)]) ! [FsITOO(dev, inode)] = *the_ino; write_block(block, &inode_table[block * FsBSIZE(dev)]); } } *************** *** 294,301 } } ! static void ! move_block(daddr_t from, daddr_t to) { char buffer[FsBSIZE(dev)]; daddr_t block; --- 349,357 ----- } } ! static void move_block(from, to) ! daddr_t from; ! daddr_t to; { char buffer[FsBSIZEdev]; daddr_t block; *************** *** 297,303 static void move_block(daddr_t from, daddr_t to) { ! char buffer[FsBSIZE(dev)]; daddr_t block; if (map[to] != 0) --- 353,359 ----- daddr_t from; daddr_t to; { ! char buffer[FsBSIZEdev]; daddr_t block; if (map[to] != 0) *************** *** 314,321 map[block] = -to; } ! static void ! move_inode(ino_t inode) { int type, i; long block[NUM_ADDR]; --- 370,377 ----- map[block] = -to; } ! static void move_inode(inode) ! ino_t inode; { int type, i; long block[NUM_ADDR]; *************** *** 328,334 if (type == S_IFCHR || type == S_IFBLK) return; ! fprintf(stderr, "moving inode %d (size %d) \r", inode, ino.di_size); l3tol(block, ino.di_addr, NUM_ADDR); --- 384,391 ----- if (type == S_IFCHR || type == S_IFBLK) return; ! (void) fprintf(stderr, ! "moving inode %d (size %d) \r", inode, ino.di_size); l3tol(block, ino.di_addr, NUM_ADDR); *************** *** 349,356 move_indirect(block[i], i-FIRST_INDIR); } ! static void ! move_indirect(daddr_t block, int level) { int i; --- 406,414 ----- move_indirect(block[i], i-FIRST_INDIR); } ! static void move_indirect(block, level) ! daddr_t block; ! int level; { int i; *************** *** 378,385 move_indirect(((daddr_t *)indir[level])[i], level-1); } ! static void ! make_hole(void) { char t_indir[FsBSIZE(dev)]; daddr_t *p_indir; --- 436,442 ----- move_indirect(((daddr_t *)indir[level])[i], level-1); } ! static void make_hole() { char t_indir[FsBSIZEdev]; daddr_t *p_indir; *************** *** 381,387 static void make_hole(void) { ! char t_indir[FsBSIZE(dev)]; daddr_t *p_indir; struct dinode t_ino, *p_ino; long block[NUM_ADDR]; --- 438,444 ----- static void make_hole() { ! char t_indir[FsBSIZEdev]; daddr_t *p_indir; struct dinode t_ino, *p_ino; long block[NUM_ADDR]; *************** *** 393,399 --back; if (next_fill >= back) { ! fprintf(stderr, "%s: can't find a free block for %d\n", cmd_name, next_fill); exit(1); } --- 450,456 ----- --back; if (next_fill >= back) { ! (void) fprintf(stderr, "%s: can't find a free block for %d\n", cmd_name, next_fill); exit(1); } *************** *** 419,425 } } if (i == FsNINDIR(dev)) { ! fprintf(stderr, "%s: panic: can't find %d in indirect block %d\n", cmd_name, next_fill, -map[back]); exit(1); --- 476,482 ----- } } if (i == FsNINDIR(dev)) { ! (void) fprintf(stderr, "%s: panic: can't find %d in indirect block %d\n", cmd_name, next_fill, -map[back]); exit(1); *************** *** 424,430 cmd_name, next_fill, -map[back]); exit(1); } ! write_block(block[0], p_indir); } else { if (map[back] == w_ino) { --- 481,487 ----- cmd_name, next_fill, -map[back]); exit(1); } ! write_block(block[0], (char *) p_indir); } else { if (map[back] == w_ino) { *************** *** 432,438 } else { p_ino = &t_ino; ! read_inode(map[back], &t_ino); } l3tol(block, p_ino->di_addr, NUM_ADDR); for (i = 0; i < NUM_ADDR; ++i) { --- 489,495 ----- } else { p_ino = &t_ino; ! read_inode((ino_t) map[back], &t_ino); } l3tol(block, p_ino->di_addr, NUM_ADDR); for (i = 0; i < NUM_ADDR; ++i) { *************** *** 443,449 } } if (i == NUM_ADDR) { ! fprintf(stderr, "%s: panic: can't find %d in inode %d\n", cmd_name, next_fill, map[back]); exit(1); } --- 500,506 ----- } } if (i == NUM_ADDR) { ! (void) fprintf(stderr, "%s: panic: can't find %d in inode %d\n", cmd_name, next_fill, map[back]); exit(1); } *************** *** 447,453 cmd_name, next_fill, map[back]); exit(1); } ! write_inode(map[back], p_ino); } } --- 504,510 ----- cmd_name, next_fill, map[back]); exit(1); } ! write_inode((ino_t) map[back], p_ino); } } *************** *** 451,458 } } ! static void ! rebuild_free_list(void) { int free_size, nfree; daddr_t free[NICFREE], block; --- 508,514 ----- } } ! static void rebuild_free_list() { int free_size, nfree; daddr_t free[NICFREE], block; *************** *** 456,462 { int free_size, nfree; daddr_t free[NICFREE], block; ! char buf[FsBSIZE(dev)]; free_size = filsys.s_fsize - next_fill; if (free_size != filsys.s_tfree) { --- 512,518 ----- { int free_size, nfree; daddr_t free[NICFREE], block; ! char buf[FsBSIZEdev]; free_size = filsys.s_fsize - next_fill; if (free_size != filsys.s_tfree) { *************** *** 460,466 free_size = filsys.s_fsize - next_fill; if (free_size != filsys.s_tfree) { ! fprintf(stderr, "%s: free list changed size from %d to %d\n", cmd_name, filsys.s_tfree, free_size); exit(1); } --- 516,522 ----- free_size = filsys.s_fsize - next_fill; if (free_size != filsys.s_tfree) { ! (void) fprintf(stderr, "%s: free list changed size from %d to %d\n", cmd_name, filsys.s_tfree, free_size); exit(1); } *************** *** 466,473 } nfree = 1; ! memset(free, 0, sizeof(free)); ! memset(buf, 0, sizeof(buf)); for (block = filsys.s_fsize - 1; block >= next_fill; --block) { if (nfree == NICFREE) { --- 522,529 ----- } nfree = 1; ! (void) memset((char *) free, 0, sizeof(free)); ! (void) memset(buf, 0, sizeof(buf)); for (block = filsys.s_fsize - 1; block >= next_fill; --block) { if (nfree == NICFREE) { *************** *** 472,478 for (block = filsys.s_fsize - 1; block >= next_fill; --block) { if (nfree == NICFREE) { ((daddr_t *)buf)[0] = nfree; ! memcpy(&((daddr_t *)buf)[1], free, sizeof(free)); write_block(block, buf); nfree = 0; memset(free, 0, sizeof(free)); --- 528,535 ----- for (block = filsys.s_fsize - 1; block >= next_fill; --block) { if (nfree == NICFREE) { ((daddr_t *)buf)[0] = nfree; ! (void) memcpy((char *) (&((daddr_t *)buf)[1]), (char *) free, ! sizeof(free)); write_block(block, buf); nfree = 0; (void) memset((char *) free, 0, sizeof(free)); *************** *** 475,481 memcpy(&((daddr_t *)buf)[1], free, sizeof(free)); write_block(block, buf); nfree = 0; ! memset(free, 0, sizeof(free)); } free[nfree++] = block; } --- 532,538 ----- sizeof(free)); write_block(block, buf); nfree = 0; ! (void) memset((char *) free, 0, sizeof(free)); } free[nfree++] = block; } *************** *** 481,486 } filsys.s_nfree = nfree; ! memcpy(&filsys.s_free, free, sizeof(free)); write_superblk(); } --- 538,543 ----- } filsys.s_nfree = nfree; ! (void) memcpy((char *) filsys.s_free, (char *) free, sizeof(free)); write_superblk(); } -- George M. Sipe, Phone: (404) 447-4731 537 Lakeshore Drive, Berkeley Lake, GA 30136-3035 UUCP: ...!{decvax,linus,rutgers}!gatech!rebel!george