Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Apr 2010 14:17:09 +0000
From:      Paul B Mahol <onemda@gmail.com>
To:        Andriy Gapon <avg@freebsd.org>
Cc:        Kostik Belousov <kostikbel@gmail.com>, freebsd-current@freebsd.org, Bruce Evans <bde@zeta.org.au>
Subject:   Re: newfs_msdos and DVD-RAM
Message-ID:  <n2v3a142e751004030717nc6322164r2df21921212365d6@mail.gmail.com>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
On 4/2/10, Andriy Gapon <avg@freebsd.org> 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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?n2v3a142e751004030717nc6322164r2df21921212365d6>