code: mafs

Download patch

ref: ecf4e1604eea913c770fa01e00da9cda2ac8537a
parent: 0a0caf0005f106f65da7239ffda825cb53c74a6d
author: 9ferno <gophone2015@gmail.com>
date: Thu Nov 10 05:25:48 EST 2022

updated man pages

--- a/docs/mafs.ms
+++ b/docs/mafs.ms
@@ -1213,7 +1213,7 @@
 Ream and start single process M[a]fs on a disk and also mount it for use.
 .sp
 .nf
-	mount -c <{disk/mafs -s -r mafs_myservice -h 10  mydisk  <[0=1]} /n/mafs_myservice
+	mount -c <{disk/mafs -s -r mafs_myservice -h 10 mydisk <[0=1]} /n/mafs_myservice
 .in 3n
 .br
 	-s: use stdin and stdout for communication
@@ -1226,7 +1226,7 @@
 Ream and start multiple-process mafs on a disk.
 .sp
 .nf
-	disk/mafs -r mafs_myservice -h 10  mydisk
+	disk/mafs -r mafs_myservice mydisk
 	mount -c /srv/mafs_myservice /n/mafs_myservice
 .fi
 .sp
@@ -1235,10 +1235,10 @@
 .sp
 .nf
 	dd -if /dev/zero -of myfile -bs 512 -count 128 # 64KB file
-	mount -c <{disk/mafs -s -r mafs_service -h 10  myfile <[0=1]} /n/mafs_myservice
+	mount -c <{disk/mafs -s -r mafs_service myfile <[0=1]} /n/mafs_myservice
 
 	# to reuse the contents of myfile later, remove -r (ream) from the above command.
-	mount -c <{disk/mafs -s -h 10  myfile <[0=1]} /n/mafs_myservice
+	mount -c <{disk/mafs -s myfile <[0=1]} /n/mafs_myservice
 .fi
 .sp
 Prepare and use a disk (/dev/sdF1) for mafs.
@@ -1292,7 +1292,7 @@
 .sp
 	disk/used  tests/test.0/disk
 .sp
-From the contents of /adm/frees show the list of free blocks. disk/reconcile uses the output of this to reconcile the list of used blocks with the list of free blocks
+From the contents of /adm/frees show the list of free blocks. disk/reconcile uses the output of this to reconcile the list of used blocks with the list of free blocks.
 .sp
 	disk/free  tests/test.0/disk
 .sp
@@ -1299,14 +1299,14 @@
 Read two lists of block numbers and flag the common and missing blocks.
 .sp
 .nf
-	disk/reconcile -u <{disk/used  tests/test.0/disk} \\
+	disk/reconcile -u <{disk/used tests/test.0/disk} \\
 		-F <{disk/free  tests/test.0/disk} 32
 .fi
 .sp
 .ne 3
-Find traverses the heirarchy and identifies the file that a block number belongs to.
+Find traverses the directory heirarchy and identifies the file that a block number belongs to.
 .sp
-	disk/find  disk.file blocknumber
+	disk/find tests/test.0/disk 17
 .sp
 .ne 3
 Find the total number of blocks on a disk.
@@ -1313,6 +1313,8 @@
 .sp
 .nf
 	dd -if /dev/sdF1/fs -bs 512 -iseek 1 -count 1 -quiet 1 | awk '$1 == "nblocks" { print $2 }'
+
+	disk/block /dev/sdF1/fs 1 | awk '$1 == "nblocks" { print $2 }'
 .fi
 .sp
 .ne 5
@@ -1335,7 +1337,7 @@
 A sanity check that the file system is not corrupt by comparing that the unused blocks and free blocks match up. $nblocks is the total number of disk blocks. $disk is the disk.
 .sp
 .nf
-	diff <{disk/unused -l <{disk/used $disk} $nblocks}} <{disk/free $disk}
+	diff <{disk/unused -l <{disk/used tests/test.0/disk} 32}} <{disk/free tests/test.0/disk}
 .fi
 .sp
 Changing the service name without a ream.
--- a/man/mafs.4
+++ b/man/mafs.4
@@ -1,8 +1,9 @@
 .TH MAFS 4
 .SH NAME
-mafs \- file server
+mafs,
+mfs - disk file system servers
 .SH SYNOPSIS
-.B mafs
+.B disk/mafs
 [
 .B -Ds
 ] [
@@ -25,7 +26,8 @@
 .I announce-string
 ]
 .B file
-.B mfs
+.PP
+.B disk/mfs
 [
 .B -Ds
 ] [
@@ -92,12 +94,66 @@
 .BI "-a " announce-string
 will announce and listen on the specified network address.
 .PD
+.SH EXAMPLES
+Ream and start single process M[a]fs on a disk and also mount it for use.
+.IP
+.EX
+mount -c \\
+	<{disk/mafs -s -r mafs_myservice mydisk <[0=1]} \\
+	/n/mafs_myservice
+.EE
+.PP
+Ream and start multiple-process mafs on a disk.
+.IP
+.EX
+disk/mafs -r mafs_myservice mydisk
+mount -c /srv/mafs_myservice /n/mafs_myservice
+.EE
+.PP
+Ream and start mafs on a file. Also, mount thet filesystem at /n/mafs_myservice.
+.IP
+.EX
+dd -if /dev/zero -of myfile -bs 512 -count 128 # 64KB file
+mount -c \\
+	<{disk/mafs -s -r mafs_service myfile <[0=1]} \\
+	/n/mafs_myservice
+
+# to reuse the contents of myfile later, remove -r (ream).
+mount -c <{disk/mafs -s myfile <[0=1]} /n/mafs_myservice
+.EE
+.PP
+Prepare and use a disk (/dev/sdF1) for mafs.
+.IP
+.EX
+disk/fdisk -bawp /dev/sdF1/data	# partition the disk
+# add an fs plan 9 partition to the disk
+echo '
+a fs 9  $-7
+w
+p
+q' | disk/prep -b  /dev/sdF1/plan9
+disk/mafs -r mafs_sdF1 /dev/sdF1/fs	# -r to ream the disk
+mount -c /srv/mafs_sdF1 /n/mafs_sdF1
+
+# for using the mafs file system on the disk later on
+disk/mafs  /dev/sdF1/fs	# no -r
+mount -c /srv/mafs_sdF1 /n/mafs_sdF1
+.EE
+.PP
+Starting mafs on a RAM file. The below commands create a ramfs filesystem to use as a disk.
+.IP
+.EX
+ramfs -m /n/mafs_ramfs
+touch /n/mafs_ramfs/file
+dd -if /dev/zero -of /n/mafs_ramfs/file -count 700 -bs 1m
+disk/mafs -r mafs_ramfs_file /n/mafs_ramfs/file
+mount -c /srv/mafs_ramfs_file /n/mafs_ramfs_file
+.EE
 .SH SOURCE
 .B /sys/src/cmd/mafs
-.B /sys/src/cmd/mfs
 .SH "SEE ALSO"
 .IR mafs (8),
 .IR prep (8),
 .IR sd (3)
 .br
-Mafs - Plan 9 userspace file system
+M[a]fs - Plan 9 userspace file system
--- a/man/mafs.8
+++ b/man/mafs.8
@@ -1,6 +1,6 @@
 .TH MAFS 8
 .SH NAME
-mafs \- file server maintenance
+block, find, free, reconcile, unused, updatefrees, used - file server maintenance
 .SH SYNOPSIS
 .PD 0
 .PP
@@ -7,11 +7,39 @@
 .B halt
 .PP
 .B sync
-.sp
+.PD
 .PP
 .B newuser
 .I name
 .RI [ options ]
+.PP
+.B disk/block
+.I drive
+.I block_number
+.PP
+.B disk/find
+.I drive
+.I block_number
+.PP
+.B disk/free
+.I drive
+.PP
+.B disk/reconcile
+.I -u used_blocks_list_file
+.I -F free_blocks_list_file
+.I nblocks
+.PP
+.B disk/unused
+.I used_blocks
+.I nblocks
+.PP
+.B disk/used
+.I drive
+.PP
+.B disk/updatefrees
+.I drive
+.I free_blocks_list_file
+.I nblocks
 .SH DESCRIPTION
 Reading /adm/ctl prints the number of free, used and total blocks/megabytes. The following commands should be written to /adm/ctl of a
 .IR mafs (4)
@@ -83,15 +111,93 @@
 command the file server overwrites
 .B /adm/users
 to reflect the internal state of the user table.
+.PD
+.PP
+.I disk/block
+Interpret the contents of a block based on the tag and write out a single formatted block based on the tag.
+.PP
+.I disk/find
+traverses the directory heirarchy and identifies the file that a block number belongs to.
+.PP
+.I disk/find
+traverses the directory heirarchy and identifies the file that a block number belongs to.
+.PP
+.I disk/free
+shows the list of free blocks from the contents of /adm/frees.
+.PP
+.I disk/reconcile
+reads two lists of block numbers and flags the common and missing blocks.
+.PP
+.I disk/unused
+builds the list of free blocks. This should match the contents of /adm/frees.
+.PP
+.I disk/used
+traverses the directory heirarchy and writes out all the used block numbers.
+.PP
+.I disk/updatefrees
+changes the contents of /adm/frees.
 .SH EXAMPLES
 Check disk usage (traditional df) of a mafs mounted at /n/mafs_myservice.
 .IP
 .EX
-% cat /n/myservice/adm/ctl
+cat /n/myservice/adm/ctl
 .EE
+.PP
+Show the contents of block 22 in disk, tests/test.0/disk.
+.IP
+.EX
+disk/block tests/test.0/disk 22
+.EE
+.PP
+Find the file using block 17 in disk, tests/test.0/disk.
+.IP
+.EX
+disk/find  tests/test.0/disk 17
+.EE
+.PP
+From the contents of /adm/frees show the list of free blocks. disk/reconcile uses the output of this to reconcile the list of used blocks with the list of free blocks.
+.IP
+.EX
+disk/free  tests/test.0/disk
+.EE
+.PP
+Read two lists of block numbers and flag the common and missing blocks.
+.IP
+.EX
+disk/reconcile -u <{disk/used  tests/test.0/disk} \\
+	-F <{disk/free  tests/test.0/disk} 32
+.EE
+.PP
+Build the list of free blocks. This should match the contents of /adm/frees.
+.IP
+.EX
+disk/unused <{disk/used test.0/disk} 32
+.EE
+.PP
+Traverse the directory heirarchy and write out all the used block numbers.
+.IP
+.EX
+disk/used  tests/test.0/disk
+.EE
+.PP
+Change the contents of /adm/frees.
+.IP
+.EX
+disk/updatefrees tests/test.0/disk \\
+	<{disk/unused <{disk/used tests/test.0/disk} 32}
+.EE
+.PP
+A sanity check that the file system is not corrupt by comparing that the unused blocks and free blocks match up. $nblocks is the total number of disk blocks. $disk is the disk.
+.IP
+.EX
+diff <{disk/unused -l <{disk/used tests/test.0/disk} 32}} \\
+	<{disk/free tests/test.0/disk}
+.EE
+.SH SOURCE
+.B /sys/src/cmd/mafs
 .SH SEE ALSO
 .IR mafs (4)
 .br
-Mafs - Plan 9 userspace file system
+M[a]fs - Plan 9 userspace file system
 .SH SOURCE
 .B /sys/src/cmd/mafs