[comp.os.minix] Changes to make fsck run under MINIX

mas@quali.UUCP (07/29/87)

The 1.1 version of fsck would not compile to run as a normal MINIX program.
Attached is a MINIX man page for fsck and the changes from the original
1.1 version needed to make it run under MINIX.  It includes fixes for a bug
where fsck would complain about zones past the end of the file system if the
nunber of zones in the filesystem modulo 16 was not 0.

Note that cylsiz has been changed for my hard disk.
You may need to change this if you wish to use fsck under STANDALONE mode.

Use the "fix" program to apply the changes.  Compile with cc -o fsck fsck.c.

-Mark Schwenk
-ihnp4!quali!mas
------------------- cut here for manual page -------------------------------
Command:   fsck - perform file system consistency check
Syntax:	   fsck [-aclmrs] [device] ...
Flags:	   -a		automatically repair inconsistencies
	   -c inode ...	check and list only the specified inodes
	   -l		list the files and directories in the filesytem
	   -m		make a new file system
	   -r		prompt user for repairs if inconsistencies are found
	   -s		list the superblock of the file system
Examples:  fsck /dev/hd4	# check file system on /dev/hd4
	   fsck -a		# automatically fix errors on /dev/disk
	   fsck -l /dev/fd0	# list the contents of /dev/fd0
	   fsck -c 2 3 /dev/hd3	# check and list inodes 2 & 3 on /dev/hd3
     Fsck performs consistency checks on the file systems which reside on the
specified devices.  If no device is given, /dev/disk is used.  Fsck may also
be used to list the contents of a file system or to make a new file system.
-------------------- cut here for diffs from fsck.c 1.1 ---------------------
9,10c9,12
< #define STANDALONE		/* compile for the boot-diskette */
< 
---
> /* #define STANDALONE		/* compile for the boot-diskette */
> #ifndef STANDALONE
> #include "stdio.h"
> #endif /*STANDALONE*/
62,68d63
< 
< #ifndef STANDALONE
< #  ifndef DOS
<     -error: no system defined.
< #  endif
< #endif
< 
171c166
< } *top;
---
> } *ftop;
345a341,343
> #ifndef STANDALONE
> 		fflush(stdout);
> #endif /*STANDALONE*/
504c502,518
< #endif
---
> 
> /* Allocate and zero memory
>  */
> char *calloc(nelem, elsize)
> unsigned nelem, elsize;
> {
>     register int i;
>     register char *mem;
>     extern char *malloc();
> 
>     if ((mem = malloc(nelem * elsize)) != NULL) {
>         for (i = 0; i < nelem*elsize; ++i)
>             mem[i] = '\0';
>     }
>     return mem;
> }
> #endif /*STANDALONE*/
538,544c552,558
< 	if (top->st_next == 0)
< 		printf("/");
< 	else
< 		printrec(top);
< 	switch (mode) {
< 	case 1: printf(" (ino = %u, ", top->st_dir->d_inum);	break;
< 	case 2: printf(" (ino = %u)", top->st_dir->d_inum);	break;
---
> 	if (ftop->st_next == 0)
> 		printf("/");
> 	else
> 		printrec(ftop);
> 	switch (mode) {
> 	case 1: printf(" (ino = %u, ", ftop->st_dir->d_inum);	break;
> 	case 2: printf(" (ino = %u)", ftop->st_dir->d_inum);	break;
689c703
< 	copy(&rwbuf[offset % BLOCK_SIZE], buf, size);
---
> 	copy(&rwbuf[(int)(offset % BLOCK_SIZE)], buf, size);
703c717
< 	copy(buf, &rwbuf[offset % BLOCK_SIZE], size);
---
> 	copy(buf, &rwbuf[(int)(offset % BLOCK_SIZE)], size);
1034c1048
< 		*first++ = ~0;
---
> 		*first++ = ~(unsigned)0;
1100,1106c1114,1120
< chkword(w1, w2, bit, type, n, report)
< unsigned w1, w2;
< char *type;
< bit_nr bit;
< int *n, *report;
< {
< 	for (; w1 | w2; w1 >>= 1, w2 >>= 1, bit++)
---
> chkword(w1, w2, bit, nbit, type, n, report)
> unsigned w1, w2;
> char *type;
> bit_nr bit, nbit;
> int *n, *report;
> {
> 	for (; (w1 | w2) && bit < nbit; w1 >>= 1, w2 >>= 1, bit++)
1138c1152
< 			chkword(*p, *q, bit, type, &nerr, &report);
---
> 			chkword(*p, *q, bit, nbit, type, &nerr, &report);
1405c1419
< 		top->st_presence |= DOT;
---
> 		ftop->st_presence |= DOT;
1409,1411c1423,1425
< 		top->st_presence |= DOTDOT;
< 		return(chkdots(ino, pos, dp, ino == ROOT_INODE ? ino :
< 						top->st_next->st_dir->d_inum));
---
> 		ftop->st_presence |= DOTDOT;
> 		return(chkdots(ino, pos, dp, ino == ROOT_INODE ? ino :
> 						ftop->st_next->st_dir->d_inum));
1620c1634
< 	if (!(top->st_presence & DOT)) {
---
> 	if (!(ftop->st_presence & DOT)) {
1625c1639
< 	if (!(top->st_presence & DOTDOT)) {
---
> 	if (!(ftop->st_presence & DOTDOT)) {
1706,1707c1720,1721
< 	stk.st_next = top;
< 	top = &stk;
---
> 	stk.st_next = ftop;
> 	ftop = &stk;
1727c1741
< 				top = top->st_next;
---
> 				ftop = ftop->st_next;
1732c1746
< 	top = top->st_next;
---
> 	ftop = ftop->st_next;
1853c1867
< 			cylsiz = 68;
---
> 			cylsiz = 85;	/* sectors per cylinder */
1932c1946
< 
---
> #ifdef STANDALONE
2018a2033
> #endif /*STANDALONE*/