Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/sbin/newfs_msdos Pull up following revision(s) (requested...



details:   https://anonhg.NetBSD.org/src/rev/09dde54a6607
branches:  netbsd-9
changeset: 455267:09dde54a6607
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sat Oct 12 15:11:42 2019 +0000

description:
Pull up following revision(s) (requested by martin in ticket #303):
        sbin/newfs_msdos/mkfs_msdos.c: revision 1.15
When we end up with too few clusters for the requested FAT type after
configuring default values, retry with a smaller cluster size.
This makes the typical invocation to create a spec conformant EFI boot
partition work out of the box.

diffstat:

 sbin/newfs_msdos/mkfs_msdos.c |  13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diffs (49 lines):

diff -r a7a48d4c0cb3 -r 09dde54a6607 sbin/newfs_msdos/mkfs_msdos.c
--- a/sbin/newfs_msdos/mkfs_msdos.c     Sat Oct 12 14:49:29 2019 +0000
+++ b/sbin/newfs_msdos/mkfs_msdos.c     Sat Oct 12 15:11:42 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkfs_msdos.c,v 1.14 2018/02/04 09:03:23 mrg Exp $      */
+/*     $NetBSD: mkfs_msdos.c,v 1.14.6.1 2019/10/12 15:11:42 bouyer 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.14 2018/02/04 09:03:23 mrg Exp $");
+__RCSID("$NetBSD: mkfs_msdos.c,v 1.14.6.1 2019/10/12 15:11:42 bouyer Exp $");
 #endif
 #endif /* not lint */
 
@@ -264,7 +264,10 @@
     int ch, fd, fd1;
     struct msdos_options o = *op;
     int oflags = O_RDWR | O_CREAT;
+    bool bspf_is_calculated;
 
+again:
+    bspf_is_calculated = false;
     if (o.block_size && o.sectors_per_cluster) {
        warnx("Cannot specify both block size and sectors per cluster");
        return -1;
@@ -556,6 +559,7 @@
     x2 = howmany((RESFTE + MIN(x, maxcls(o.fat_type))) * (o.fat_type / BPN),
                 bpb.bps * NPB);
     if (!bpb.bspf) {
+       bspf_is_calculated = true;
        bpb.bspf = x2;
        x1 += (bpb.bspf - 1) * bpb.nft;
     }
@@ -569,6 +573,11 @@
        return -1;
     }
     if (cls < mincls(o.fat_type)) {
+       if (bspf_is_calculated && o.sectors_per_cluster == 0 && bpb.spc > 2) {
+               /* retry with smaller cluster size */
+               o.sectors_per_cluster = 2;
+               goto again;
+       }
        warnx("%u clusters too few clusters for FAT%u, need %u", cls,
            o.fat_type, mincls(o.fat_type));
        return -1;



Home | Main Index | Thread Index | Old Index