From owner-freebsd-current@FreeBSD.ORG Sat Apr 3 14:17:12 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 122C5106564A for ; Sat, 3 Apr 2010 14:17:11 +0000 (UTC) (envelope-from onemda@gmail.com) Received: from mail-ww0-f54.google.com (mail-ww0-f54.google.com [74.125.82.54]) by mx1.freebsd.org (Postfix) with ESMTP id 3953E8FC15 for ; Sat, 3 Apr 2010 14:17:10 +0000 (UTC) Received: by wwb24 with SMTP id 24so1804136wwb.13 for ; Sat, 03 Apr 2010 07:17:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:received:message-id:subject:from:to:cc:content-type; bh=UVoyCZViL8V12VNSpOyrbXcWdpPzZxQIq6hjnxJ3T44=; b=P1cqSlw7o0nmCfXkg6SFKKPjagynPo3P3zz5SwMdo7SPzUueQBmqRYDkEN9JG9twxu DIVsrKt2CTMmSL/Af8i6Ro+sNUzp+sP+pnF7oHBU+bhm8SW0gEkfE++twnEC52KLT8BS dF/VmBfXzwsZ3nkgEc22pVQoiivacyabAfofs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=OLLSQ7nUB8AYiGBNsvvL4ehC6skSzAnND6eK8YJtNoygak9g0Bs5NsCoYovyAFWUFS t+vUh+ZsO8PQbeUrIuqG7RMkE1RtEHcbd6CbftfUl3xDIbz7+Fm7miLba5TdfiU/qLE+ Bnz1NNbqT5flbe8P8F54UYmkbDRfp7X7/t1D0= MIME-Version: 1.0 Received: by 10.216.1.70 with HTTP; Sat, 3 Apr 2010 07:17:09 -0700 (PDT) In-Reply-To: <4BB64615.9060601@freebsd.org> References: <3a142e751003190508x6a06868ene2e8fd9ddd977f66@mail.gmail.com> <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> <4BB64615.9060601@freebsd.org> Date: Sat, 3 Apr 2010 14:17:09 +0000 Received: by 10.216.93.79 with SMTP id k57mr2035081wef.161.1270304230055; Sat, 03 Apr 2010 07:17:10 -0700 (PDT) Message-ID: From: Paul B Mahol To: Andriy Gapon Content-Type: text/plain; charset=ISO-8859-1 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: Sat, 03 Apr 2010 14:17:12 -0000 On 4/2/10, Andriy Gapon wrote: > 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; Works for me, thanks! (I will test compatibility with winXP later)