From owner-freebsd-usb@FreeBSD.ORG Mon Nov 8 17:20:21 2004 Return-Path: Delivered-To: freebsd-usb@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9E4D716A4CE for ; Mon, 8 Nov 2004 17:20:21 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7115143D58 for ; Mon, 8 Nov 2004 17:20:21 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id iA8HKL3m058797 for ; Mon, 8 Nov 2004 17:20:21 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id iA8HKL4g058796; Mon, 8 Nov 2004 17:20:21 GMT (envelope-from gnats) Date: Mon, 8 Nov 2004 17:20:21 GMT Message-Id: <200411081720.iA8HKL4g058796@freefall.freebsd.org> To: freebsd-usb@FreeBSD.org From: Hans Petter Selasky Subject: Re: kern/66248: [panic] bootloader is confused by booting from USB flash, trashes main drives boot block X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Hans Petter Selasky List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Nov 2004 17:20:21 -0000 The following reply was made to PR kern/66248; it has been noted by GNATS. From: Hans Petter Selasky To: jhb@freebsd.org, freebsd-gnats-submit@freebsd.org, bremner@unb.ca Cc: Subject: Re: kern/66248: [panic] bootloader is confused by booting from USB flash, trashes main drives boot block Date: Mon, 8 Nov 2004 18:24:03 +0100 --SUOF0GtieIMvvwua Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, Attached patch for /src/sys/boot/i386/boot0/boot0.S closes kern/66248 Apply using: cat boot0.S.diff | patch -N -l When the boot0 boot-manager is used on a floppy or USB drive, the floppy's or USB's boot-sector gets written to the hdd! Solution: Only update the boot-sector when there is a valid drive number or the drive number is set manually. To make the patch fit into the code I had to disable the "beep-signal". Yours -HPS --SUOF0GtieIMvvwua Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="boot0.S.diff" *** boot0.S.ref Wed Oct 20 17:24:19 2004 --- boot0.S Wed Oct 20 17:30:56 2004 *************** *** 103,112 **** * Check what flags were loaded with us, specifically, Use a predefined Drive. * If what the bios gives us is bad, use the '0' in the block instead, as well. */ ! testb $0x20,_FLAGS(%bp) # Set number drive? jnz main.1 # Yes testb %dl,%dl # Drive number valid? js main.2 # Possibly (0x80 set) main.1: movb _SETDRV(%bp),%dl # Drive number to use /* * Whatever we decided to use, now store it into the fake --- 103,117 ---- * Check what flags were loaded with us, specifically, Use a predefined Drive. * If what the bios gives us is bad, use the '0' in the block instead, as well. */ ! testb $0x20,_FLAGS(%bp) # Set drive number? jnz main.1 # Yes testb %dl,%dl # Drive number valid? js main.2 # Possibly (0x80 set) + /* + * Only update the boot-sector when there is a valid drive number or + * the drive number is set manually. + */ + orb $0x40,_FLAGS(%bp) # Disable updates main.1: movb _SETDRV(%bp),%dl # Drive number to use /* * Whatever we decided to use, now store it into the fake *************** *** 203,210 **** /* * Start of input loop. Beep and take note of time */ ! main.10: movb $ASCII_BEL,%al # Signal callw putchr # beep! xorb %ah,%ah # BIOS: Get int $0x1a # system time movw %dx,%di # Ticks when --- 208,218 ---- /* * Start of input loop. Beep and take note of time */ ! main.10: ! #ifdef BEL ! movb $ASCII_BEL,%al # Signal callw putchr # beep! + #endif xorb %ah,%ah # BIOS: Get int $0x1a # system time movw %dx,%di # Ticks when --SUOF0GtieIMvvwua--