Date: Sun, 10 Jul 2005 19:55:46 +0200 From: "Simon L. Nielsen" <simon@FreeBSD.org> To: Poul-Henning Kamp <phk@phk.freebsd.dk> Cc: current@freebsd.org Subject: Re: [TEST/REVIEW] boot0cfg/fdisk issue fix Message-ID: <20050710175545.GC868@zaphod.nitro.dk> In-Reply-To: <20050710174348.GB868@zaphod.nitro.dk> References: <1919.1120596290@phk.freebsd.dk> <20050710174348.GB868@zaphod.nitro.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
--FeAIMMcddNRN4P4/ Content-Type: multipart/mixed; boundary="CGDBiGfvSTbxKZlW" Content-Disposition: inline --CGDBiGfvSTbxKZlW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2005.07.10 19:43:48 +0200, Simon L. Nielsen wrote: > On 2005.07.05 22:44:50 +0200, Poul-Henning Kamp wrote: >=20 > > This is an attempt to fix an boot0cfg/fdisk issue which I have > > overlooked. > >=20 > > The patch adds a g_ctl method to geom_mbr and makes boot0cfg and > > fdisk use it to modify the MBR if possible. > >=20 > > Please test and report ASAP in order to get this solution into > > RELENG_6 >=20 > I played around with this and made the attached regression test script > and your patch seems to work fine, except for the "fdisk: Geom not > found" output from fdisk (which I already mentioned to you) when it's > not using the GEOM API. Mailman removed the attachment so I will try once more. I also put it at http://people.freebsd.org/~simon/tmp/geom_mbr.t . --=20 Simon L. Nielsen --CGDBiGfvSTbxKZlW Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="geom_mbr.t" #!/bin/sh # # Copyright (c) 2005 Simon L. Nielsen <simon@nitro.dk> # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # Note, set the DEBUG environment variable for some debug output. # Simple error "handling" during setup set -e name="test" base=`basename $0` mdbacking=`mktemp -t ${base}` tmpfile=`mktemp -t ${base}` tmpmnt=`mktemp -d -t ${base}` # Slice entries for disk p1="p 1 165 0 4032" p1_0="p 1 0 0 0" p2="p 2 165 4095 3969" p3="p 3 165 8127 3969" p4="p 4 165 12096 4032" actpar=1 nr=1 expectstr() { expect=$1 txt=$2 tname=$3 if [ x"$tname" != x ]; then tname="- $tname" fi if [ x"$expect" = x"$txt" ]; then echo "ok $nr" $tname else echo "not ok $nr" $tname [ -n "$DEBUG" ] && echo "$expect" != "$txt" >&2 fi nr=$(($nr + 1)) } expectdevs() { expect=$1 tname=$2 devs=$(cd /dev && echo ${dev}*) expectstr "$expect" "$devs" "$tname" } expectslices() { expect=$1 tname=$2 devs=$(cd /dev && echo ${dev}* | sed -e s/${dev}//g -e 's/ / /g' \ -e 's/^ //g') expectstr "$expect" "$devs" "$tname" } fdiskf() { p=$1 expect=$2 tname=$3 printf "$p\n" > ${tmpfile} if [ -z "$DEBUG" ]; then fdisk -f ${tmpfile} -i ${dev} >/dev/null 2>&1 | \ grep -v "^fdisk: Geom not found" else fdisk -f ${tmpfile} -i ${dev} fi expectslices "$expect" "$tname" } boot0tests() { tnameextra=$1 boot0cfg -B $dev >/dev/null 2>&1 expectstr "0" "$?" "reinstall boot0 bootblock${tnameextra}" boot0cfg -s ${actpar} $dev >/dev/null 2>&1 expectstr "0" "$?" "set active slice${tnameextra}" if [ $actpar = 2 ]; then actpar=1 else actpar=2 fi } echo '1..38' # Init md dd if=/dev/zero of=${mdbacking} bs=1m count=5 >/dev/null 2>&1 dev=`mdconfig -a -t vnode -f ${mdbacking} -x 63 -y 16` || exit 1 [ -n "${dev}" ] || exit 1 # Init done set +e # Init disk, no slices fdisk -f /dev/null -i ${dev} > /dev/null 2>&1 \ | grep -v "fdisk: invalid fdisk partition table found" expectdevs "$dev" "MBR init" # First basic tests without any RW consumers of the MBR boot0tests "; no slices" fdiskf "$p1" "s1" "add slice 1" boot0tests "; one slice" fdiskf "$p1\n$p2" "s1 s2" "add slice 2" boot0tests "; two slices" fdiskf "$p1\n$p2\n$p3" "s1 s2 s3" "add slice 3" boot0tests "; three slices" fdiskf "$p1\n$p2\n$p3\n$p4" "s1 s2 s3 s4" "add slice 4" boot0tests "; four slices" fdiskf "$p1\n$p2\n$p3" "s1 s2 s3" "del slice 4" fdiskf "$p1\n$p2" "s1 s2" "del slice 3" fdiskf "$p1" "s1" "del slice 2" boot0tests "" # Now try to do stuff with a mounted FS, IE. we have a RW consumer of the MBR newfs /dev/${dev}s1 >/dev/null 2>&1 mount /dev/${dev}s1 ${tmpmnt} boot0tests "; one slice; mounted FS" fdiskf "$p1\n$p2" "s1 s2" "add slice 2; mounted FS" boot0tests "; two slices; mounted FS" fdiskf "$p1\n$p2\n$p3" "s1 s2 s3" "add slice 3; mounted FS" boot0tests "; three slices; mounted FS" fdiskf "$p1\n$p2\n$p3\n$p4" "s1 s2 s3 s4" "add slice 4; mounted FS" boot0tests "; four slices; mounted FS" fdiskf "$p1\n$p2\n$p3" "s1 s2 s3" "del slice 4; mounted FS" fdiskf "$p1\n$p2" "s1 s2" "del slice 3; mounted FS" fdiskf "$p1" "s1" "del slice 2; mounted FS" # Now try to shoot our foot off and hope GEOM saves us: fdiskf "${p1_0}" "s1" "del all slices, with mounted FS" # Now prepare so we can test if md reattach will pick stuff up fdiskf "$p1\n$p2\n$p3\n$p4" "s1 s2 s3 s4" "add slice 1-4, with mounted FS" umount ${tmpmnt} expectstr "0" "$?" "unmount FS" # Reattach md device so we _really_ pick up any change mdconfig -d -u $dev dev=`mdconfig -a -t vnode -f ${mdbacking} -x 63 -y 16` || exit 1 expectslices "s1 s2 s3 s4" "post md reconfig" # Cleanup rm -f ${tmpfile} rmdir ${tmpmnt} mdconfig -d -u $dev rm -f ${mdbacking} --CGDBiGfvSTbxKZlW-- --FeAIMMcddNRN4P4/ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (FreeBSD) iD8DBQFC0WEhh9pcDSc1mlERAqK7AKC2ChyEtSDqHsuSPyW92jTRPvd+fQCffZSZ vfhgORTQnveq5TADrkAN3nw= =V1Hq -----END PGP SIGNATURE----- --FeAIMMcddNRN4P4/--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050710175545.GC868>