newfs_msdos and DVD-RAM

Paul B Mahol onemda at gmail.com
Sat Apr 3 14:17:12 UTC 2010


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
>> @@ -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)


More information about the freebsd-current mailing list