## sfsck

#### OS/161 Reference Manual

### Name

sfsck - check/repair an SFS filesystem

### Synopsis

`/sbin/sfsck` raw-device
`host-sfsck` disk-image-file

### Description

`sfsck` checks the SFS filesystem on the specified device for correctness and consistency. Various possible errors and corrupt states are detected and reported; some (but not all) can be corrected.

If `sfsck` is used under OS/161, the first form should be used, where raw-device is a raw device name (such as "lhd1raw:"). Don't use a device that's currently mounted.

`sfsck` can also be used on the System/161 host OS, in which case the second form should be used. The host-compiled version of `sfsck` knows how to deal with the header on System/161 disk images and does the right thing.

### Requirements

`sfsck` uses the following system calls:

- open
- read
- write
- lseek
- fstat
- close
- sbrk
- _exit

`sfsck` should function properly under OS/161 once you have implemented the basic system calls, `sbrk` in the VM system, and `fstat`.

The host version of `sfsck`, since it runs outside of OS/161, should always work regardless of what you have and have not implemented.

You will likely need to make some changes to `sfsck` in the course of doing the file system assignment. If you are implementing crash recovery for your file system, be sure to update `sfsck` to know about any extra on-disk structures you add. You will want to be able to use it to cross-check your recovery code... and so will the course staff.

### See Also

dumpsfs, mksfs