From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <92b8bfc5dfedbeaec3bb6f6c0df2653c@quanstro.net> From: erik quanstrom Date: Mon, 8 Jun 2009 20:54:05 -0400 To: 9fans@9fans.net In-Reply-To: <599f06db0906081203x32cd8641i1e79c469c4a6ee83@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-qhjvgieeufvyajsyiqprhycyvj" Subject: Re: [9fans] new usb implementation Topicbox-Message-UUID: 078c1858-ead5-11e9-9d60-3106f5b1d025 This is a multi-part message in MIME format. --upas-qhjvgieeufvyajsyiqprhycyvj Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit > > Didn't say impossible, I said tricky. here's the code. it's not hard at all. the meat of the code just is one line. the rest is error checking. a very similar script would turn all aoe devices into sd devices via sdaoe, though i always end up doing that by hand. - erik --upas-qhjvgieeufvyajsyiqprhycyvj Content-Disposition: attachment; filename=usbsd Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit #!/bin/rc # turn usb disks into sd devices via sdloop(3) rfork e disk = () disks=() name=() fn picksd{ p=`{awk '{print $1}' < /dev/sdctl} r=() for(i in u v w x y z) if(~ $#r 0 && ! ~ sd$i $p) r = $i echo $r } test -e /dev/usb || bind -a '#u' /dev || { echo no '#u/usb' >[1=2] exit nousb } test -e /dev/usbdctl || mount -a /srv/usb /dev || { echo cannot mount /srv/usb >[1=2] exit nousbd } switch($#*){ case 0 ; case 1 disks = $1 case 2 disks = $1 name = $2 case * echo usage: usbsd ' [disk [sdname]]' >[1=2] exit usage } if(~ $#disks 0){ if(! test -e /dev/sdU*/data){ echo no usb disks >[1=2] exit nodisk } disks = `{echo /dev/sdU*/data} } for(d in $disks){ if(~ $d /dev/sdU*.[0-9]*/data && test -e $d){ if(~ $#name 0) name=`{picksd u} if(~ $#name 0){ echo no available devices >[2=1]; exit nodev } echo config switch on spec $name type loop/$d >/dev/sdctl } if not echo $d does not exist >[2=1] } exit '' --upas-qhjvgieeufvyajsyiqprhycyvj--