From owner-freebsd-scsi Thu Oct 22 03:28:24 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id DAA17983 for freebsd-scsi-outgoing; Thu, 22 Oct 1998 03:28:24 -0700 (PDT) (envelope-from owner-freebsd-scsi@FreeBSD.ORG) Received: from vader.cs.berkeley.edu (vader.CS.Berkeley.EDU [128.32.38.234]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id DAA17978 for ; Thu, 22 Oct 1998 03:28:23 -0700 (PDT) (envelope-from asami@vader.cs.berkeley.edu) Received: from silvia.hip.berkeley.edu (sjx-ca115-21.ix.netcom.com [207.223.162.85]) by vader.cs.berkeley.edu (8.8.7/8.7.3) with ESMTP id DAA18942; Thu, 22 Oct 1998 03:27:53 -0700 (PDT) Received: (from asami@localhost) by silvia.hip.berkeley.edu (8.8.8/8.6.9) id DAA21738; Thu, 22 Oct 1998 03:27:50 -0700 (PDT) Date: Thu, 22 Oct 1998 03:27:50 -0700 (PDT) Message-Id: <199810221027.DAA21738@silvia.hip.berkeley.edu> To: tbuswell@mediaone.net CC: scsi@FreeBSD.ORG In-reply-to: <13870.3656.235875.122481@tbuswell.ne.mediaone.net> (message from Ted Buswell on Wed, 21 Oct 1998 12:45:54 -0400 (EDT)) Subject: Re: for i in disks From: asami@FreeBSD.ORG (Satoshi Asami) Sender: owner-freebsd-scsi@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org * I haven't been following this thread closely, but unless I'm * missing something, I think the Disk_Names() function from libdisk(3) * is what you're looking for.. [assuming compiled C code is OK]. * -Ted * * /* gcc x.c -ldisk */ * extern char **Disk_Names(); * main() { * char **p = Disk_Names(); * while(*p) puts(*p++); * } Oooh. This is very nice and simple. :) It works on my recent CAM system but not on my old one. Thanks though. By the way, in case anyone is interested, this is what I came up with. I can now move disks around and still have them mounted correctly. :) /etc/rc.disk (called from /etc/rc, right after clean_var): === # # disk setups # # $Id$ # dir=/mnt echo "setting up disks" found=0 for i in /dev/sd*a; do if ! mount -o ro $i $dir 2>/dev/null; then continue fi if [ -f $dir/autorun.sh ]; then echo "running $i's autorun script" found=1 sh $dir/autorun.sh $dir $i fi if ! umount $dir; then echo "error unmounting $i" exit 1 fi done if [ $found = 1 -a -f /var/run/autorun.sh ]; then echo "running /var/run/autorun.sh" sh /var/run/autorun.sh fi echo "done" === For a simple mount, this will be the autorun.sh: === #!/bin/sh unit=$(/usr/bin/printf "%02x" $(echo $2 | sed -e 's./dev/sd..' -e 's/a$//')) fsck -p /dev/dsk/sd${unit}h || exit 1 mount /dev/dsk/sd${unit}h /MOUNTPOINT === The black magic about unit and /dev/dsk is our peciluar setup -- I have all disks wired to "B * 16 + I" where B is bus number and I is SCSI ID, and have a bunch of symlinks from /dev/dsk/sd* to /dev/sd* to make them easier to read. The links in /dev/dsk/sd* are named as "sdBIP" where I is represented in hexadecimal (0-f) and P is the partition name. For a ccd array, use this one: === #!/bin/sh unit=$(/usr/bin/printf "%02x" $(echo $2 | sed -e 's./dev/sd..' -e 's/a$//')) echo /dev/dsk/sd${unit}h > /tmp/$(cat $1/diskid)-$(cat $1/ccdno) cp $1/mountpoint /tmp/$(cat $1/ccdno)-mountpoint cp $1/var-autorun.sh /var/run/autorun.sh === and this var-autorun.sh: === #!/bin/sh for ccd in 0 1; do if [ $(echo $(echo /tmp/*-ccd$ccd | wc -w)) = 13 ]; then echo "found 13 disks, making ccd" echo -n "ccd$ccd 128 none " > /tmp/ccd.conf echo $(cat /tmp/*-ccd$ccd) >> /tmp/ccd.conf ccdconfig -Cv -f /tmp/ccd.conf fsck -p /dev/ccd${ccd}c mount /dev/ccd${ccd}c $(cat /tmp/ccd${ccd}-mountpoint) rm -f /tmp/ccd.conf /tmp/ccd${ccd}-mountpoint rm -f /tmp/*-ccd${ccd} else echo "error" fi done === Obviously things like "13" and "128" should be on the disks somewhere, we need better error handling, but it's a start. :) Satoshi To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-scsi" in the body of the message