newfs_msdos and DVD-RAM

Andriy Gapon avg at freebsd.org
Fri Apr 2 19:26:09 UTC 2010


on 02/04/2010 14:09 Andriy Gapon said the following:
> on 02/04/2010 13:57 Fabian Keil said the following:
>> Andriy Gapon <avg at freebsd.org> wrote:
>>> Anyways, here is a patch that I would use.
>>> Unfortunately, ENOTIME to understand newfs_msdos code and fix it too,
>>>
>>> --- a/sys/fs/msdosfs/msdosfs_vfsops.c
>>> +++ b/sys/fs/msdosfs/msdosfs_vfsops.c
>>> @@ -580,6 +580,7 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp)
>>>  	  || (pmp->pm_BytesPerSec & (pmp->pm_BytesPerSec - 1))
>>>  	  || (pmp->pm_HugeSectors == 0)
>>>  	  || (pmp->pm_FATsecs == 0)
>>> +	  || (SecPerClust * pmp->pm_BlkPerSec > MAXBSIZE / DEV_BSIZE)
>>>  	) {
>>>  		error = EINVAL;
>>>  		goto error_exit;
>> That works, too:
>>
>> fk at r500 ~ $sudo mdconfig -a -t vnode -f /tank/ipod-image-formatiert
>> md0
>> fk at r500 ~ $sudo mount_msdosfs /dev/md0 /mnt/
>> mount_msdosfs: /dev/md0: Invalid argument
>>
>> Is there a chance that this, or some other workaround, could be committed?
> 
> Yes, there is 99.99% chance of this happening :-)
> Now, if someone could fix newfs_msdos issue too.
> I could easily reproduce it this way:
> 
> $ truncate -s 5G test.img
> $ mdconfig -a -t vnode -f test.img -S 2048 -u 0
> $ newfs_msdos -F 32 /dev/md0
> 

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;


-- 
Andriy Gapon


More information about the freebsd-current mailing list