Date: Mon, 26 Jan 2015 00:22:55 -0700 From: Warner Losh <imp@bsdimp.com> To: Perry Hutchison <perryh@pluto.rain.com> Cc: freebsd-current@freebsd.org, imp@freebsd.org, andrnils@gmail.com Subject: Re: How to read a disklabel (Re: What replaces DIOCGDINFO?) Message-ID: <197159D3-4654-4F2E-A6CB-582029DAF329@bsdimp.com> In-Reply-To: <54c5d75d.vYjlikWm5nAMV9br%perryh@pluto.rain.com> References: <54c4a9f2.T1F%2BE5l9r%2BDbUlmr%perryh@pluto.rain.com> <CAPS9%2BSthFOkpknHbAqYC8LdbUentOCzMsNkbtmo=MWb3UygjnQ@mail.gmail.com> <54c5d75d.vYjlikWm5nAMV9br%perryh@pluto.rain.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> On Jan 25, 2015, at 10:57 PM, Perry Hutchison <perryh@pluto.rain.com> = wrote: >=20 > Andreas Nilsson <andrnils@gmail.com> wrote: >> On Sun, Jan 25, 2015 at 9:31 AM, Perry Hutchison = <perryh@pluto.rain.com> >> wrote: >>> -r276737 removed 4 ioctls, including DIOCGDINFO, from = <sys/disklabel.h>. >>> The commit log entry says only "Remove old ioctl use and support, = once >>> and for all." >>>=20 >>> What are users of that mechanism supposed to use instead? >>=20 >> = http://lists.freebsd.org/pipermail/freebsd-current/2015-January/053960.htm= l >> might have the answer for you. >=20 > Same symptom, but DIOCGMEDIASIZE is not the solution in this case > because the port reads the disklabel to identify the partition that > contains a particular sector of the device. To do that, AFAIK it > needs to actually retrieve and examine the label. The other ioctls > in <sys/disk.h> don't look all that promising, either. Most modern disks don=E2=80=99t even have BSD disk labels. They just = have GPT partitions. So the DIOCGDINFO failed to work an interesting amount of the time. There=E2=80=99s no easy way to fix that, since the disk label = sizes aren=E2=80=99t big enough to return GPT data. gpart list contains the information needed. You can find the source in /usr/src/sbin/geom/class/part/geom_part.c libgeom(3) has some of the info you=E2=80=99ll need as well. However, it is likely easier to pull = it out of either the XML version of the config sysctl (kern.geom.confxml) or the simple text version (kern.geom.conftxt). I imagine the latter is likely best = for finding which partition an absolute sector belongs to. Warner
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?197159D3-4654-4F2E-A6CB-582029DAF329>