Subject: bin/5534: off_t bug in disklabel
To: None <gnats-bugs@gnats.netbsd.org>
From: None <salvet@ics.muni.cz>
List: netbsd-bugs
Date: 06/03/1998 19:40:12
>Number: 5534
>Category: bin
>Synopsis: disklabel can't write label to partition at 4GB or larger offset
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Jun 3 10:50:01 1998
>Last-Modified:
>Originator: Zdenek Salvet
>Organization:
Masaryk university, Brno, Czech Republic
>Release: 1.3
>Environment:
1.3/i386, current-980520/i386 (probably arm32 too, not tried)
>Description:
Disklabel writes label to incorrect place when NetBSD MBR partition starts
at 4GB or larger offset from begin of the disk because offset arithmetic
is done in ints.
>How-To-Repeat:
create new partition after >4GB of other space
try to set disk label with "disklabel -R -r sd0 file"
"disklabel sd0" says "sd0: no disklabel" (it cannot find the disklabel magic number)
>Fix:
*** disklabel.c.bad Wed Jun 3 19:30:25 1998
--- disklabel.c Wed Jun 3 19:32:04 1998
***************
*** 473,479 ****
if (dosdp) {
if (dosdp->dp_start != pp->p_offset)
confirm("Write outside MBR partition");
! sectoffset = pp->p_offset * lp->d_secsize;
} else {
if (mbrpt_nobsd)
confirm("Erase the previous contents of the disk");
--- 473,479 ----
if (dosdp) {
if (dosdp->dp_start != pp->p_offset)
confirm("Write outside MBR partition");
! sectoffset = (off_t)pp->p_offset * lp->d_secsize;
} else {
if (mbrpt_nobsd)
confirm("Erase the previous contents of the disk");
***************
*** 482,488 ****
#endif
#ifdef __arm32__
/* XXX */
! sectoffset = filecore_partition_offset * DEV_BSIZE;
#endif /* __arm32__ */
/*
* First set the kernel disk label,
--- 482,488 ----
#endif
#ifdef __arm32__
/* XXX */
! sectoffset = (off_t)filecore_partition_offset * DEV_BSIZE;
#endif /* __arm32__ */
/*
* First set the kernel disk label,
***************
*** 779,789 ****
#ifdef __i386__
if (dosdp)
! sectoffset = dosdp->dp_start * DEV_BSIZE;
#endif
#ifdef __arm32__
/* XXX */
! sectoffset = filecore_partition_offset * DEV_BSIZE;
#endif /* __arm32__ */
if (lseek(f, sectoffset, SEEK_SET) < 0 ||
read(f, bootarea, BBSIZE) < BBSIZE)
--- 779,789 ----
#ifdef __i386__
if (dosdp)
! sectoffset = (off_t)dosdp->dp_start * DEV_BSIZE;
#endif
#ifdef __arm32__
/* XXX */
! sectoffset = (off_t)filecore_partition_offset * DEV_BSIZE;
#endif /* __arm32__ */
if (lseek(f, sectoffset, SEEK_SET) < 0 ||
read(f, bootarea, BBSIZE) < BBSIZE)
***************
*** 850,860 ****
#ifdef __i386__
if (dosdp)
! sectoffset = dosdp->dp_start * DEV_BSIZE;
#endif
#ifdef __arm32__
/* XXX */
! sectoffset = filecore_partition_offset * DEV_BSIZE;
#endif /* __arm32__ */
if (lseek(f, sectoffset, SEEK_SET) < 0 ||
read(f, boot, BBSIZE) < BBSIZE)
--- 850,860 ----
#ifdef __i386__
if (dosdp)
! sectoffset = (off_t)dosdp->dp_start * DEV_BSIZE;
#endif
#ifdef __arm32__
/* XXX */
! sectoffset = (off_t)filecore_partition_offset * DEV_BSIZE;
#endif /* __arm32__ */
if (lseek(f, sectoffset, SEEK_SET) < 0 ||
read(f, boot, BBSIZE) < BBSIZE)
>Audit-Trail:
>Unformatted: