From owner-freebsd-bugs Fri Jun 9 15:10:12 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 404E937B756 for ; Fri, 9 Jun 2000 15:10:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id PAA92605; Fri, 9 Jun 2000 15:10:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from modemcable127.61-201-24.mtl.mc.videotron.net (modemcable127.61-201-24.mtl.mc.videotron.net [24.201.61.127]) by hub.freebsd.org (Postfix) with SMTP id A21C937B756 for ; Fri, 9 Jun 2000 15:05:28 -0700 (PDT) (envelope-from patrick@mindstep.com) Received: (qmail 80658 invoked by alias); 9 Jun 2000 22:05:26 -0000 Received: (qmail 80654 invoked from network); 9 Jun 2000 22:05:26 -0000 Received: from nitro.local.mindstep.com (qmailr@192.168.10.2) by jacuzzi.local.mindstep.com with SMTP; 9 Jun 2000 22:05:26 -0000 Received: (qmail 70888 invoked by uid 0); 9 Jun 2000 22:08:07 -0000 Message-Id: <20000609220807.70887.qmail@nitro.local.mindstep.com> Date: 9 Jun 2000 22:08:07 -0000 From: patrick@mindstep.com Reply-To: patrick@mindstep.com To: freefall-gnats@mindstep.com X-Send-Pr-Version: 3.2 Subject: kern/19156: Enable the doFS.sh to run in arbitrary locations Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 19156 >Category: kern >Synopsis: Enable the doFS.sh to run in arbitrary locations >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Jun 09 15:10:00 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Patrick Bihan-Faou >Release: FreeBSD 4.0-STABLE i386 >Organization: MindStep Corporation >Environment: Source code for RELENG_4 as of June 5, 2000 >Description: The doFS.sh script in /usr/src/release/scripts can only work in a chrooted environment because it references /dev directly to access the vnode device being built. This makes it difficult to use the script outside the scope of a make from the /usr/src/release directory (which runs it in a chroot'd dir). Also the mount point has to be specified as an absolute path. >How-To-Repeat: n/a >Fix: The following patch transform the path for the mount point to a absolute path and gets the location of the device directory to use from the command line (following the mount path argument). The device path is also canonicalized to an absolute path. If needed the script will also create the devices and mount directories. If the directories were created by doFS.sh, they will be removed after the script is done. The /usr/src/release/Makefile is updated to provide the location of the devices directory to the doFS.sh script. --- Makefile.orig Fri Jun 9 16:48:26 2000 +++ Makefile Fri Jun 9 16:49:15 2000 @@ -510,11 +510,11 @@ tar xf - -C ${RD}/mfsfd/stand @echo "Compressing doc files..." @gzip -9 ${RD}/mfsfd/stand/help/*.hlp - sh -e ${.CURDIR}/scripts/doFS.sh -s mfsroot ${RD} ${MNT} \ + sh -e ${.CURDIR}/scripts/doFS.sh -s mfsroot ${RD} ${MNT} /dev \ ${MFSSIZE} ${RD}/mfsfd ${MFSINODE} ${MFSLABEL} @gzip -9vc mfsroot > mfsroot.gz @sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/mfsroot.flp \ - ${RD} ${MNT} ${BOOTSIZE} mfsroot.gz ${BOOTINODE} ${BOOTLABEL} + ${RD} ${MNT} /dev ${BOOTSIZE} mfsroot.gz ${BOOTINODE} ${BOOTLABEL} @cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=kern @cd ${.CURDIR} && ${MAKE} doMFSKERN FSIMAGE=boot BIGBOOT=YES @rm mfsroot mfsroot.gz mfsroot.size @@ -546,7 +546,7 @@ @cp ${.CURDIR}/scripts/tar.sh ${RD}/fixitfd/stand/tar @chmod 555 ${RD}/fixitfd/stand/tar @sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/fixit.flp ${RD} \ - ${MNT} ${FIXITSIZE} ${RD}/fixitfd ${FIXITINODE} ${FIXITLABEL} + ${MNT} /dev ${FIXITSIZE} ${RD}/fixitfd ${FIXITINODE} ${FIXITLABEL} # Do our last minute floppies directory setup in a convenient place. @cp ${.CURDIR}/texts/FLOPPIES.TXT ${RD}/floppies/README.TXT @(cd ${RD}/floppies; md5 README.TXT *.flp > CHECKSUM.MD5) @@ -777,11 +777,11 @@ @rm -f ${RD}/floppies/${FSIMAGE}.flp .if defined(BIGBOOT) sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \ - ${RD} ${MNT} ${BIGBOOTSIZE} ${RD}/image.${FSIMAGE} \ + ${RD} ${MNT} /dev ${BIGBOOTSIZE} ${RD}/image.${FSIMAGE} \ ${BOOTINODE} ${BIGBOOTLABEL} .else sh -e ${.CURDIR}/scripts/doFS.sh ${RD}/floppies/${FSIMAGE}.flp \ - ${RD} ${MNT} ${BOOTSIZE} ${RD}/image.${FSIMAGE} \ + ${RD} ${MNT} /dev ${BOOTSIZE} ${RD}/image.${FSIMAGE} \ ${BOOTINODE} ${BOOTLABEL} .endif @echo "Created ${RD}/floppies/${FSIMAGE}.flp" --- scripts/doFS.sh.orig Thu Jun 8 22:23:34 2000 +++ scripts/doFS.sh Fri Jun 9 16:46:56 2000 @@ -15,41 +15,63 @@ FSIMG=$1; shift RD=$1 ; shift MNT=$1 ; shift +DEV=$1 ; shift FSSIZE=$1 ; shift FSPROTO=$1 ; shift FSINODE=$1 ; shift FSLABEL=$1 ; shift deadlock=20 +created_mnt=0 +created_dev=0 + +[ -d ${MNT} ] || +{ + mkdir -p ${MNT} || { echo "unable to create ${MNT} directory"; exit 1; } + created_mnt=1 +} +CUR=`pwd` +cd ${MNT} +MNT=`pwd` +cd ${CUR} + +[ -d ${DEV} ] || +{ + mkdir -p ${DEV} || { echo "unable to create ${DEV} directory"; exit 1; } + created_dev=1 +} +cd ${DEV} +DEV=`pwd` +cd ${CUR} u=`expr $VNDEVICE : 'vn\([0-9]*\)' || true` -rm -f /dev/*vnn* -mknod /dev/vnn${u} b 15 `expr 65538 + $u '*' 8` -mknod /dev/rvnn${u} c 43 `expr 65538 + $u '*' 8` -mknod /dev/vnn${u}c b 15 `expr 2 + $u '*' 8` -mknod /dev/rvnn${u}c c 43 `expr 2 + $u '*' 8` +rm -f ${DEV}/*vnn* +mknod ${DEV}/vnn${u} b 15 `expr 65538 + $u '*' 8` +mknod ${DEV}/rvnn${u} c 43 `expr 65538 + $u '*' 8` +mknod ${DEV}/vnn${u}c b 15 `expr 2 + $u '*' 8` +mknod ${DEV}/rvnn${u}c c 43 `expr 2 + $u '*' 8` VNDEVICE=vnn$u while true do rm -f ${FSIMG} - umount /dev/${VNDEVICE} 2>/dev/null || true + umount ${DEV}/${VNDEVICE} 2>/dev/null || true umount ${MNT} 2>/dev/null || true - vnconfig -u /dev/r${VNDEVICE} 2>/dev/null || true + vnconfig -u ${DEV}/r${VNDEVICE} 2>/dev/null || true dd of=${FSIMG} if=/dev/zero count=${FSSIZE} bs=1k 2>/dev/null # this suppresses the `invalid primary partition table: no magic' awk 'BEGIN {printf "%c%c", 85, 170}' |\ dd of=${FSIMG} obs=1 seek=510 conv=notrunc 2>/dev/null - vnconfig -s labels -c /dev/r${VNDEVICE} ${FSIMG} - disklabel -Brw /dev/r${VNDEVICE} ${FSLABEL} - newfs -i ${FSINODE} -T ${FSLABEL} -o space /dev/r${VNDEVICE}c + vnconfig -s labels -c ${DEV}/r${VNDEVICE} ${FSIMG} + disklabel -Brw ${DEV}/r${VNDEVICE} ${FSLABEL} + newfs -i ${FSINODE} -T ${FSLABEL} -o space ${DEV}/r${VNDEVICE}c - mount /dev/${VNDEVICE}c ${MNT} + mount ${DEV}/${VNDEVICE}c ${MNT} if [ -d ${FSPROTO} ]; then (set -e && cd ${FSPROTO} && find . -print | cpio -dump ${MNT}) @@ -62,7 +84,7 @@ set `df -ki ${MNT} | tail -1` umount ${MNT} - vnconfig -u /dev/r${VNDEVICE} 2>/dev/null || true + vnconfig -u ${DEV}/r${VNDEVICE} 2>/dev/null || true echo ">>> Filesystem is ${FSSIZE} K, $4 left" echo ">>> ${FSINODE} bytes/inode, $7 left" @@ -71,4 +93,8 @@ fi break; done -rm -f /dev/*vnn* +rm -f ${DEV}/*vnn* + +[ ${created_mnt} -eq 0 ] || { rmdir ${MNT}; } +[ ${created_dev} -eq 0 ] || { rmdir ${DEV}; } + >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message