Re: newfs_msdos and DVD-RAM

From: Paul B Mahol <onemda_at_gmail.com>
Date: Sat, 3 Apr 2010 14:17:09 +0000
On 4/2/10, Andriy Gapon <avg_at_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
>> _at__at_ -427,6 +427,9 _at__at_ 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
> _at__at_ -427,6 +427,12 _at__at_ 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)
Received on Sat Apr 03 2010 - 12:17:12 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:02 UTC