tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: mounting wedges by name (Matthew Mondor) writes:

>On Sun, 17 Oct 2010 11:07:40 +0000 (UTC)
> (Michael van Elst) wrote:

>> is a patch
>> to mount(8) that allows you to mount a partition by using the syntax
>> "NAME=string" as the special file where 'string' is the Unicode name
>> of the wedge. The same syntax can be used in fstab.

>I think this is very useful.

>Are disk names provided by sysctl already converted to UTF-8 as
>necessary?  As I see that GPT labels appear to be UTF-16LE encoded.  A
>quick look at kern/subri_iostat.c did not show any encoding conversion
>and I didn't check further yet.  I'm honestly unfamiliar with that code,
>but your comparision code would seem to work for me in the case of
>ASCII or UTF-8 only.

sysctl only delivers the driver instance names ('cd0','sd0','dk0',...)
that I need to list all wedges. I don't think there is any defined
encoding for driver names and so far everything is ascii.

The wedges themselves have a name stored as UTF-8:

struct dkwedge_info {
        char            dkw_devname[16];/* device-style name (e.g. "dk0") */
        uint8_t         dkw_wname[128]; /* wedge name (Unicode, UTF-8) */

For GPT autodiscovered wedges the UTF-8 encoding is converted from
the UTF-16LE data stored in the GPT.

So, my code wants to see partition names in UTF-8.

N.B. so far, only GPT derived wedges have such a name. If you
generate wedges with DKWEDGE_METHOD_BSDLABEL (which is usually a bad
idea) their names will be the same as the traditional partition names,
for example: "sd0a". If you use DKWEDGE_METHOD_MBR you get the
same but starting with partition 'e'.

                                Michael van Elst
                                "A potential Snark may lurk in every tree."

Home | Main Index | Thread Index | Old Index