From owner-freebsd-bugs Mon Apr 8 23:50:13 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 0435437B405 for ; Mon, 8 Apr 2002 23:50:02 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g396o1K03345; Mon, 8 Apr 2002 23:50:01 -0700 (PDT) (envelope-from gnats) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id EF1C037B400 for ; Mon, 8 Apr 2002 23:47:52 -0700 (PDT) Received: (from nobody@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g396lqa03072; Mon, 8 Apr 2002 23:47:52 -0700 (PDT) (envelope-from nobody) Message-Id: <200204090647.g396lqa03072@freefall.freebsd.org> Date: Mon, 8 Apr 2002 23:47:52 -0700 (PDT) From: David Xu To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: misc/36916: DOS active partition flag lost in libdisk and sysinstall Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 36916 >Category: misc >Synopsis: DOS active partition flag lost in libdisk and sysinstall >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Apr 08 23:50:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: David Xu >Release: FreeBSD 5.0-CURRENT >Organization: Viatech >Environment: FreeBSD davidbsd.viasoft.com.cn 5.0-CURRENT FreeBSD 5.0-CURRENT #9: Mon Apr 8 13:45:15 CST 2002 root@davidbsd.viasoft.com.cn:/usr/src/sys/i386/compile/xu i386 >Description: When libdisk read DOS partition information from MBR, active partition flag is lost. when sysinstall uses libdisk to read MBR partition information, it can not display active partition flag, if user is installing FreeBSD in multiple boot system, for example installing FreeBSD on a machine which already have Windows/NT installed, and if he don't install FreeBSD boot0 into MBR and keep using Windows/NT boot loader, sysinstall will write partition table without DOS active partition flag set, when Windows/NT boot loader runs, it will die at "Invalid Partition". the problem occurs when newbie wants to install FreeBSD on there Windows/NT machine and forget to set active partition flag. >How-To-Repeat: >Fix: --- /usr/src/lib/libdisk/disk.c.orig Tue Apr 9 12:46:22 2002 +++ /usr/src/lib/libdisk/disk.c Tue Apr 9 14:05:56 2002 @@ -132,7 +132,7 @@ #else p = read_block(fd, 0, sector_size); dp = (struct dos_partition*)(p + DOSPARTOFF); - for (i = 0; i < NDOSPART; i++) { + for (i = 0; i < NDOSPART; i++, dp++) { if (Read_Int32(&dp->dp_start) >= size) continue; if (Read_Int32(&dp->dp_start) + Read_Int32(&dp->dp_size) >= size) @@ -144,9 +144,7 @@ d->flags |= DISK_ON_TRACK; offset = 63; } - } - free(p); #endif d->bios_sect = dl.d_nsectors; @@ -178,11 +176,10 @@ (*(p+1) == 0xff) && (*(p+2) == 0xff)) { Add_Chunk(d, 0, size, name, fat, 0xa0a0, 0, name); - free(p); goto pc98_mo_done; } - free(p); #endif /* PC98 */ + dp = (struct dos_partition*)(p + DOSPARTOFF); for(i=BASE_SLICE;iflags |= CHUNK_ACTIVE; + if (chunk_info[current_chunk]->flags & CHUNK_ACTIVE) + chunk_info[current_chunk]->flags &= ~CHUNK_ACTIVE; + else + chunk_info[current_chunk]->flags |= CHUNK_ACTIVE; break; case 'U': >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message