From owner-freebsd-current@FreeBSD.ORG Fri Apr 2 19:31:37 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 306FD1065677 for ; Fri, 2 Apr 2010 19:31:37 +0000 (UTC) (envelope-from avg@freebsd.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 689EA8FC1C for ; Fri, 2 Apr 2010 19:31:35 +0000 (UTC) Received: from porto.topspin.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id WAA03959; Fri, 02 Apr 2010 22:31:34 +0300 (EEST) (envelope-from avg@freebsd.org) Received: from localhost.topspin.kiev.ua ([127.0.0.1]) by porto.topspin.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1Nxmab-0004os-RL; Fri, 02 Apr 2010 22:31:33 +0300 Message-ID: <4BB64615.9060601@freebsd.org> Date: Fri, 02 Apr 2010 22:31:33 +0300 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.24 (X11/20100321) MIME-Version: 1.0 To: Fabian Keil References: <3a142e751003190508x6a06868ene2e8fd9ddd977f66@mail.gmail.com> <3a142e751003191021p141af009m6acf7d160c890cbb@mail.gmail.com> <20100319191133.46fe271c@r500.local> <3a142e751003191126j331e525fwb9e5573bbf6f7d58@mail.gmail.com> <4BAA30CB.1070707@icyb.net.ua> <20100328172537.501ed3d1@r500.local> <4BB0A053.9060007@freebsd.org> <20100329222920.5eef6395@r500.local> <4BB111D4.8060809@freebsd.org> <20100330173637.202b4b1e@r500.local> <4BB21BBA.7030407@freebsd.org> <4BB360A1.7020309@freebsd.org> <20100402125721.50b3ba4f@r500.local> <4BB5D06C.8080902@freebsd.org> <4BB644CA.4000807@freebsd.org> In-Reply-To: <4BB644CA.4000807@freebsd.org> X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Kostik Belousov , freebsd-current@freebsd.org, Bruce Evans Subject: Re: newfs_msdos and DVD-RAM X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Apr 2010 19:31:37 -0000 on 02/04/2010 22:26 Andriy Gapon said the following: > > OK, I did it again. > I tested the below patch using the scenario described above. > Could you please review and/or test this patch? > If you like it and it works, I can commit it. > Thanks! > > --- a/sbin/newfs_msdos/newfs_msdos.c > +++ b/sbin/newfs_msdos/newfs_msdos.c > @@ -427,6 +427,9 @@ main(int argc, char *argv[]) > if (bpb.bpbBytesPerSec < MINBPS) > errx(1, "bytes/sector (%u) is too small; minimum is %u", > bpb.bpbBytesPerSec, MINBPS); > + bpb.bpbSecPerClust /= (bpb.bpbBytesPerSec / MINBPS); > + if (bpb.bpbSecPerClust == 0) > + bpb.bpbSecPerClust = 1; > if (!(fat = opt_F)) { > if (opt_f) > fat = 12; > And here is a safer one (in case of a huge sector size > 32KB). I will appreciate any testing with real media that you might have. diff --git a/sbin/newfs_msdos/newfs_msdos.c b/sbin/newfs_msdos/newfs_msdos.c index 955c3a5..3f2778d 100644 --- a/sbin/newfs_msdos/newfs_msdos.c +++ b/sbin/newfs_msdos/newfs_msdos.c @@ -427,6 +427,12 @@ main(int argc, char *argv[]) if (bpb.bpbBytesPerSec < MINBPS) errx(1, "bytes/sector (%u) is too small; minimum is %u", bpb.bpbBytesPerSec, MINBPS); + bpb.bpbSecPerClust /= (bpb.bpbBytesPerSec / MINBPS); + if (bpb.bpbSecPerClust == 0) + bpb.bpbSecPerClust = 1; + if (bpb.bpbSecPerClust * bpb.bpbBytesPerSec > 32 * 1024) + errx(1, "bytes per sector (%u) is greater than 32k", + bpb.bpbSecPerClust * bpb.bpbBytesPerSec); if (!(fat = opt_F)) { if (opt_f) fat = 12; -- Andriy Gapon