Plan 9 from Bell Labs’s /usr/web/sources/patch/applied/usbfat/usbfat:

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc
# usbfat: [-fl] [disk [mtpt]] - mount a USB disk's MS FAT file system
rfork e
opts=()
while (! ~ $#* 0 && ~ $1 -*) {
	switch ($1) {
	case -f -l
		opts=($opts $1)
	case -*
		echo usage: $0 '[-fl] [disk [mtpt]]' >[1=2]
		exit usage
	}
	shift
}
disk = /n/disk/0/data
mtpt = /n/usb

switch ($#*) {
case 0
	;
case 1
	disk = $1
case 2
	disk = $1
	mtpt = $2
case *
	echo usage: $0 '[-fl] [disk [mtpt]]' >[1=2]
	exit usage
}

if (! test -e $disk)
	usb/disk $opts || exit 'no disk'
if (! test -f /srv/usbfat.$user) {
	blk = `{disk/fdisk -p $disk | awk '/^part dos / {print $3}'}
	if (~ $#blk 0 || ! ~ $blk [0-9]*) {
		echo $0: no fdisk dos partition found... >[1=2]
		dossrv -f $disk usbfat.$user || exit dossrv
	}
	if not
		dossrv -f $disk:$blk usbfat.$user || exit dossrv
}
mount -c /srv/usbfat.$user $mtpt

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.