code: mafs

ref: 48c656d809eba4bdb5092b07c3c0b4487f6cd69f
dir: /fsck/

View raw version
#!/bin/rc

# usage
#	disk/fsck /dev/sdFn/fs

disk=$1
if(~ $#disk '')
	exit invalid disk

# get the total number of blocks from the config block
nblocks=`{disk/block $disk 1 | awk '$1 == "nblocks"{ print $2 }'}

# write the free extents to /adm/frees
disk/used $disk > /tmp/used.blocks
disk/updatefrees $disk <{disk/unused $nblocks /tmp/used.blocks}

# change fsok from 0 to 1
disk/fsok $disk
rm /tmp/used.blocks