ref: 04ed928433da0613dca258620c3c68e73a3f3766
parent: a0f4c70c81ce40265aa4ca4e472332564d15399c
author: 9ferno <[email protected]>
date: Sat Dec 3 05:46:38 EST 2022
add mafs to the 9front installer
--- /dev/null
+++ b/9front-installer-supports-mafs.patch
@@ -1,0 +1,164 @@
+From 345185cd5e97d679500b4da354dffb74be22979c Mon Sep 17 00:00:00 2001
+From: 9ferno <[email protected]>
+Date: Sat, 3 Dec 2022 10:44:08 -0700
+Subject: [PATCH] installer supports mafs
+
+---
+ rc/bin/fstype | 5 ++++
+ rc/bin/inst/configfs | 5 +++-
+ rc/bin/inst/mountfs | 2 ++
+ rc/bin/inst/mountmafs | 59 +++++++++++++++++++++++++++++++++++++
+ rc/bin/inst/prepdisk | 2 +-
+ sys/src/9/boot/bootfs.proto | 11 +++++++
+ 6 files changed, 82 insertions(+), 2 deletions(-)
+ create mode 100755 rc/bin/inst/mountmafs
+
+diff --git a/rc/bin/fstype b/rc/bin/fstype
+index 67c3cd20b..673c5ae29 100755
+--- a/rc/bin/fstype
++++ b/rc/bin/fstype
+@@ -29,6 +29,11 @@ if(~ $"m 'kfs wren device'){
+ echo kfs
+ exit
+ }
++m=`{dd -if /env/block -bs 1 -count 11 -skip 184 >[2]/dev/null}
++if(~ $"m 'mafs device'){
++ echo disk/mafs/mafs
++ exit
++}
+ </env/block awk '
+ /^(blocksize|daddrbits|daddrbits|indirblks|dirblks|namelen)/{p[$1]=$2}
+ END{
+diff --git a/rc/bin/inst/configfs b/rc/bin/inst/configfs
+index 8beb1f370..61f066d3e 100755
+--- a/rc/bin/inst/configfs
++++ b/rc/bin/inst/configfs
+@@ -15,8 +15,11 @@ case go
+ echo
+ echo ' cwfs64x the cached-worm file server'
+ echo ' hjfs the new 9front file server (experimental!)'
++ echo ' mafs the newest kid on the block'
+ echo
+- prompt -d cwfs64x 'File system' cwfs64x hjfs
++ prompt -d cwfs64x 'File system' cwfs64x hjfs mafs
+ fstype=$rd
++ if(~ $rd mafs)
++ fstype=disk/mafs/mafs
+ export fstype
+ }
+diff --git a/rc/bin/inst/mountfs b/rc/bin/inst/mountfs
+index 9bfea7fef..7ae04e611 100755
+--- a/rc/bin/inst/mountfs
++++ b/rc/bin/inst/mountfs
+@@ -8,6 +8,8 @@ case cwfs cwfs64 cwfs64x
+ exec ./mountcwfs $*
+ case hjfs
+ exec ./mounthjfs $*
++case disk/mafs/mafs
++ exec ./mountmafs $*
+ case *
+ mountfs=notdone
+ export mountfs
+diff --git a/rc/bin/inst/mountmafs b/rc/bin/inst/mountmafs
+new file mode 100755
+index 000000000..9a73995d0
+--- /dev/null
++++ b/rc/bin/inst/mountmafs
+@@ -0,0 +1,59 @@
++#!/bin/rc
++
++# desc: choose and mount file system partition
++
++sname=mafs_rootfs
++
++switch($1){
++case go
++ echo
++ echo Please choose your $fstype partition
++ echo
++
++ files=(`{ls /dev/sd*/fs* >[2]/dev/null})
++ if(! ~ $#files 0)
++ ls -l $files
++ echo
++ if(~ $#files 1)
++ default=(-d $files)
++ if not
++ default=()
++ prompt $default 'mafs partition' $files
++ fs=$rd
++ export fs
++
++ ream=no
++ if(! ~ $fstype `{fstype $fs})
++ ream=yes
++ prompt -d $ream 'Ream the filesystem?' yes no
++ ream=$rd
++
++ log Starting $fstype file server for $fs
++ echo halt >>/n/^$sname^/adm/ctl >[2]/dev/null
++ unmount /n/^$sname >[2]/dev/null
++ unmount /n/newfs >[2]/dev/null
++ rm -f /srv/^$sname >[2]/dev/null
++
++ if(~ $ream yes){
++ disk/mafs/mafs -r $sname $fsflags $fs
++ }
++ if not {
++ disk/mafs/mafs -n $sname $fsflags $fs
++ }
++
++ log Mounting $fstype file server for $fs
++ while(! logprog mount -c /srv/$sname /n/newfs)
++ sleep 2
++
++case checkready checkdone
++ if(! ~ $fstype '' && ~ $#fs 1 && test -f $fs){
++ if(test -f /srv/$sname && test -d /n/newfs/dist){
++ mountfs=done
++ export mountfs
++ exit
++ }
++ }
++ mountfs=ready
++ export mountfs
++ exit
++}
+diff --git a/rc/bin/inst/prepdisk b/rc/bin/inst/prepdisk
+index 6bf4ec40c..310be21bf 100755
+--- a/rc/bin/inst/prepdisk
++++ b/rc/bin/inst/prepdisk
+@@ -7,7 +7,7 @@ fn autotype {
+ switch($fstype){
+ case cwfs cwfs64 cwfs64x
+ echo -a 9fat -a nvram -a fscache -a fsworm -a other
+- case hjfs
++ case hjfs disk/mafs/mafs
+ echo -a 9fat -a nvram -a fs
+ }
+ }
+diff --git a/sys/src/9/boot/bootfs.proto b/sys/src/9/boot/bootfs.proto
+index c9cf1fbe3..ff7a0709b 100644
+--- a/sys/src/9/boot/bootfs.proto
++++ b/sys/src/9/boot/bootfs.proto
+@@ -17,6 +17,17 @@ $objtype
+ edisk
+ fdisk
+ prep
++ mafs
++ block
++ find
++ free
++ fsck
++ fsok
++ mafs
++ reconcile
++ unused
++ updatefrees
++ used
+ dossrv
+ echo
+ cwfs64x
+--
+2.37.3
+
--- a/mafs.c
+++ b/mafs.c
@@ -50,7 +50,7 @@
ARGBEGIN{
default: usage();
case 'D': chatty9p++; break;
- case 'f': devfile = ARGF(); break;
+ case 'f': /* devfile = ARGF(); */ break; /* to work with bootfs of /sys/src/9/boot/local.rc */
case 'm': nmemunits = atoll(EARGF(usage())); break;
case 'r':
doream = 1;
--- a/mkfile
+++ b/mkfile
@@ -1,6 +1,6 @@
</$objtype/mkfile
-TARG=mafs used reconcile block find free unused updatefrees fsok # mfs
+TARG=mafs block find free fsok reconcile unused updatefrees used # mfs
OFILES=\
9p.$O\
@@ -26,7 +26,7 @@
extents.h\
fns.h\
-BIN=/$objtype/bin/disk
+BIN=/$objtype/bin/disk/mafs
UPDATE=mkfile\
$HFILES\