Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/newfs_msdos Use the same defaults for cluster sizes as ...
details: https://anonhg.NetBSD.org/src/rev/8993d7f4643e
branches: trunk
changeset: 344532:8993d7f4643e
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sun Apr 03 11:00:13 2016 +0000
description:
Use the same defaults for cluster sizes as Windows.
diffstat:
sbin/newfs_msdos/mkfs_msdos.c | 34 ++++++++++++++++++++++------------
1 files changed, 22 insertions(+), 12 deletions(-)
diffs (55 lines):
diff -r 78a6669b5a96 -r 8993d7f4643e sbin/newfs_msdos/mkfs_msdos.c
--- a/sbin/newfs_msdos/mkfs_msdos.c Sun Apr 03 10:36:00 2016 +0000
+++ b/sbin/newfs_msdos/mkfs_msdos.c Sun Apr 03 11:00:13 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mkfs_msdos.c,v 1.9 2014/01/05 12:52:39 martin Exp $ */
+/* $NetBSD: mkfs_msdos.c,v 1.10 2016/04/03 11:00:13 mlelstv Exp $ */
/*
* Copyright (c) 1998 Robert Nordier
@@ -37,7 +37,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: mkfs_msdos.c,v 1.9 2014/01/05 12:52:39 martin Exp $");
+__RCSID("$NetBSD: mkfs_msdos.c,v 1.10 2016/04/03 11:00:13 mlelstv Exp $");
#endif
#endif /* not lint */
@@ -335,16 +335,26 @@
return -1;
bpb.bsec -= (o.offset / bpb.bps);
if (bpb.spc == 0) { /* set defaults */
- if (bpb.bsec <= 6000) /* about 3MB -> 512 bytes */
- bpb.spc = 1;
- else if (bpb.bsec <= (1<<17)) /* 64M -> 4k */
- bpb.spc = 8;
- else if (bpb.bsec <= (1<<19)) /* 256M -> 8k */
- bpb.spc = 16;
- else if (bpb.bsec <= (1<<21)) /* 1G -> 16k */
- bpb.spc = 32;
- else
- bpb.spc = 64; /* otherwise 32k */
+ /* minimum cluster size */
+ switch (o.fat_type) {
+ case 12:
+ bpb.spc = 1; /* use 512 bytes */
+ x = 2; /* up to 2MB */
+ break;
+ case 16:
+ bpb.spc = 1; /* use 512 bytes */
+ x = 32; /* up to 32MB */
+ break;
+ default:
+ bpb.spc = 8; /* use 4k */
+ x = 8192; /* up to 8GB */
+ break;
+ }
+ x1 = howmany(bpb.bsec, (1048576 / 512)); /* -> MB */
+ while (bpb.spc < 128 && x < x1) {
+ x *= 2;
+ bpb.spc *= 2;
+ }
}
}
Home |
Main Index |
Thread Index |
Old Index