Date: Mon, 8 Apr 2002 23:54:42 -0700 (PDT) From: David Xu <davidx@viasoft.com.cn> To: freebsd-gnats-submit@FreeBSD.org Subject: misc/36917: DOS active partition flag lost in libdisk and sysinstall Message-ID: <200204090654.g396sgl04219@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 36917
>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: Tue Apr 09 00:00:04 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;i<ds.dss_nslices;i++) {
char sname[20];
chunk_e ce;
@@ -230,6 +227,9 @@
ce = unknown;
break;
}
+ if (i-BASE_SLICE < NDOSPART &&
+ dp[i-BASE_SLICE].dp_flag == 0x80)
+ flags |= CHUNK_ACTIVE;
#ifdef PC98
if (Add_Chunk(d, ds.dss_slices[i].ds_offset,
ds.dss_slices[i].ds_size, sname, ce, subtype, flags,
@@ -377,6 +377,7 @@
#ifdef PC98
pc98_mo_done:
#endif
+ free(p);
close(fd);
Fixup_Names(d);
return d;
--- /usr/src/usr.sbin/sysinstall/disks.c.orig Tue Apr 9 12:21:26 2002
+++ /usr/src/usr.sbin/sysinstall/disks.c Tue Apr 9 14:08:02 2002
@@ -528,7 +528,10 @@
case 'S':
/* Set Bootable */
- chunk_info[current_chunk]->flags |= 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200204090654.g396sgl04219>
