Maxime Villard <max%M00nBSD.net@localhost> writes: > Le 15/07/2014 17:57, Martin Husemann a écrit : >> >> On Tue, Jul 15, 2014 at 03:27:08PM +0200, Maxime Villard wrote: >>> 'secsize' is retrieved through getdisksize(), via an ioctl on the device. >> >> force it to be 512 bytes minimum? >> >> Martin >> > > I thought about that. I haven't found a clear spec on this, but it is > implicitly suggested that 512 is the minimal size (from what I've seen > here and there). And the smallest BytesPerSec allowed for fat devices > is 512. But still, nothing really clear. > > Index: msdosfs_vfsops.c > =================================================================== > RCS file: /cvsroot/src/sys/fs/msdosfs/msdosfs_vfsops.c,v > retrieving revision 1.113 > diff -u -r1.113 msdosfs_vfsops.c > --- msdosfs_vfsops.c 15 Jul 2014 11:43:54 -0000 1.113 > +++ msdosfs_vfsops.c 16 Jul 2014 12:58:52 -0000 > @@ -493,6 +493,13 @@ > psize = 0; > error = 0; > } > + if (secsize < DEV_BSIZE) { > +#ifdef DIAGNOSTIC > + printf("Invalid block secsize %d\n", secsize); > +#endif > + error = EINVAL; > + goto error_exit; > + } > > if (argp->flags & MSDOSFSMNT_GEMDOSFS) { > if (secsize != GEMDOSFS_BSIZE) { That's an abuse of DIAGNOSTIC. It should only be used to control whether to assert on things that cannot happen. (Bad data on a mount point is not a software invariant.) I don't object to having an error message, but it might be nice to have the device included, and to say that it's in msdosfs_mount. I also agree that a value < 512 is almost certainly wrong and it's fine to error out until there's a valid use case and spec saying smaller is ok.
Attachment:
pgpqOhMvXMJvA.pgp
Description: PGP signature