diff options
| author | scw <scw@NetBSD.org> | 2006-11-25 12:29:33 +0000 |
|---|---|---|
| committer | scw <scw@NetBSD.org> | 2006-11-25 12:29:33 +0000 |
| commit | 258fa36dc2011028eae6e368300976ecde3362d1 (patch) | |
| tree | a264190b8da2b02ff8e1c67acf0ba5ea44428802 | |
| parent | 4f0ca2726e3b071d3e1dc30939ef076628f00564 (diff) | |
Don't use negative offsets from "bpb.bps" when writing out values such
as DOSMAGIC in the MBR. In non-512 byte media, the MBR is still 512
bytes in length.
Based on the patches provided in PR kern/17398 by Trevin Beattie.
| -rw-r--r-- | sbin/newfs_msdos/newfs_msdos.8 | 6 | ||||
| -rw-r--r-- | sbin/newfs_msdos/newfs_msdos.c | 16 |
2 files changed, 11 insertions, 11 deletions
diff --git a/sbin/newfs_msdos/newfs_msdos.8 b/sbin/newfs_msdos/newfs_msdos.8 index 51258c3e9d1..3185e2de34a 100644 --- a/sbin/newfs_msdos/newfs_msdos.8 +++ b/sbin/newfs_msdos/newfs_msdos.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: newfs_msdos.8,v 1.14 2004/09/22 23:52:38 thorpej Exp $ +.\" $NetBSD: newfs_msdos.8,v 1.15 2006/11/25 12:29:33 scw Exp $ .\" .\" Copyright (c) 1998 Robert Nordier .\" All rights reserved. @@ -27,7 +27,7 @@ .\" .\" From: $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.8,v 1.13 2001/08/14 10:01:48 ru Exp $ .\" -.Dd September 22, 2004 +.Dd November 25, 2006 .Dt NEWFS_MSDOS 8 .Os .Sh NAME @@ -91,7 +91,7 @@ The default is .Qq Li "NetBSD" . .It Fl S Ar sector-size Number of bytes per sector. -Acceptable values are powers of 2 in the range 128 through 32768. +Acceptable values are powers of 2 in the range 512 through 32768. .It Fl a Ar FAT-size Number of sectors per FAT. .It Fl b Ar block-size diff --git a/sbin/newfs_msdos/newfs_msdos.c b/sbin/newfs_msdos/newfs_msdos.c index 568dd6e96c6..f3a096c04c1 100644 --- a/sbin/newfs_msdos/newfs_msdos.c +++ b/sbin/newfs_msdos/newfs_msdos.c @@ -1,4 +1,4 @@ -/* $NetBSD: newfs_msdos.c,v 1.23 2006/10/16 03:25:21 christos Exp $ */ +/* $NetBSD: newfs_msdos.c,v 1.24 2006/11/25 12:29:33 scw Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -33,7 +33,7 @@ static const char rcsid[] = "$FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $"; #else -__RCSID("$NetBSD: newfs_msdos.c,v 1.23 2006/10/16 03:25:21 christos Exp $"); +__RCSID("$NetBSD: newfs_msdos.c,v 1.24 2006/11/25 12:29:33 scw Exp $"); #endif #endif /* not lint */ @@ -68,7 +68,7 @@ __RCSID("$NetBSD: newfs_msdos.c,v 1.23 2006/10/16 03:25:21 christos Exp $"); #define NPB 2 /* nibbles per byte */ #define DOSMAGIC 0xaa55 /* DOS magic number */ -#define MINBPS 128 /* minimum bytes per sector */ +#define MINBPS 512 /* minimum bytes per sector */ #define MAXSPC 128 /* maximum sectors per cluster */ #define MAXNFT 16 /* maximum number of FATs */ #define DEFBLK 4096 /* default block size */ @@ -671,17 +671,17 @@ main(int argc, char *argv[]) setstr(bs->oem, opt_O ? opt_O : "NetBSD", sizeof(bs->oem)); memcpy(img + x1, bootcode, sizeof(bootcode)); - mk2(img + bpb.bps - 2, DOSMAGIC); + mk2(img + MINBPS - 2, DOSMAGIC); } } else if (fat == 32 && bpb.infs != MAXU16 && (lsn == bpb.infs || (bpb.bkbs != MAXU16 && lsn == bpb.bkbs + bpb.infs))) { mk4(img, 0x41615252); - mk4(img + bpb.bps - 28, 0x61417272); - mk4(img + bpb.bps - 24, 0xffffffff); - mk4(img + bpb.bps - 20, bpb.rdcl); - mk2(img + bpb.bps - 2, DOSMAGIC); + mk4(img + MINBPS - 28, 0x61417272); + mk4(img + MINBPS - 24, 0xffffffff); + mk4(img + MINBPS - 20, bpb.rdcl); + mk2(img + MINBPS - 2, DOSMAGIC); } else if (lsn >= bpb.res && lsn < dir && !((lsn - bpb.res) % (bpb.spf ? bpb.spf : bpb.bspf))) { |
