Subject: Re: Disklabel and non 512-byte media
To: Steve Woodford <scw@netbsd.org>
From: Reinoud Zandijk <reinoud@netbsd.org>
List: tech-kern
Date: 10/16/2006 13:30:54
--5vNYLRcllDrimb99
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Dear folks,

On Fri, Oct 13, 2006 at 11:05:44PM +0100, Steve Woodford wrote:
> I've noticed an interesting oddity with disklabels on media with 
> physical sector size != DEV_BSIZE. Here's one I prepared earlier based 
> on a Samsung YP-U2 USB MP3 player:
> 
> sd0 at scsibus0 target 0 lun 0: <Samsung, YP-U2, 0100> disk removable
> sd0: fabricating a geometry
> sd0: 999 MB, 249 cyl, 64 head, 32 sec, 2048 bytes/sect x 511616 sectors
> 
> # disklabel sd0
> ...
> bytes/sector: 2048
> ...
> 5 partitions:
> #        size  offset   fstype [fsize bsize cpg/sgs]
>  d:   2046464       0   unused      0     0        # (Cyl. 0 - 999+)
>  e:    511560      56    MSDOS                     # (Cyl. 0*- 249*)

I've encountered the same problem with UDF and CD's. The disclabel's sector 
size is 2048 but the drive's disklabels are to be specified in 
DEV_BLKSIZE or it will go wrong.

The main curlpits are the disk partition range checking functions (check 
with label etc.) in the device drivers. They ought to honour the 
sectorsize. I've patched them once but for some reason i can't remember 
they never got committed. Maybe the mail archives will tell us why.

As for msdosfs on USB sticks, i think you'd have to look at 
dev/scsipi/sd.c's default label generation.

With regards,
Reinoud


--5vNYLRcllDrimb99
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (NetBSD)

iQEVAwUBRTNtZ4KcNwBDyKpoAQLLmAgAqwkt1yI4mRwkivyRMMq9/GAAnOAFqRrf
/mozPBKCFSlLAQ3WimXrmYKyqWyuc6W8R+c2dF3UgA/AjOAN6hP2HS4kZmcc3165
8jp4BYhVnLttlRgMgkBWGhLwMk2mmBTCMxKLoFtl1XkkS9RSALhGqKKibLV0OoqK
o/tGgccsoTwALwrcMA6dCu2ssAw8cTj2AGPL8HybPQ/rvbKBmDKDINVvoGV5h5wB
55PWW/1Z6ht6KbvFI30frJs5qB8MrXjCaOEwaCuVz0gc4emMPkQBd9mlieT5DVE4
c2s7iZgnBoU+2p4RQSiTL/L1MJUC8gpb3BRHeBlMJSrg6/82ybrcqQ==
=0rYP
-----END PGP SIGNATURE-----

--5vNYLRcllDrimb99--