diff --git a/sys/dev/ld.c b/sys/dev/ld.c index 87a32c03803b..b7550f2e799f 100644 --- a/sys/dev/ld.c +++ b/sys/dev/ld.c @@ -1,4 +1,4 @@ -/* $NetBSD: ld.c,v 1.42 2006/11/16 01:32:45 christos Exp $ */ +/* $NetBSD: ld.c,v 1.43 2007/02/08 03:19:42 riz Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.42 2006/11/16 01:32:45 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.43 2007/02/08 03:19:42 riz Exp $"); #include "rnd.h" @@ -69,11 +69,14 @@ __KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.42 2006/11/16 01:32:45 christos Exp $"); #include +#include + static void ldgetdefaultlabel(struct ld_softc *, struct disklabel *); static void ldgetdisklabel(struct ld_softc *); static void ldminphys(struct buf *bp); static void ldshutdown(void *); static void ldstart(struct ld_softc *); +static void ld_set_properties(struct ld_softc *); extern struct cfdriver ld_cd; @@ -146,6 +149,8 @@ ldattach(struct ld_softc *sc) sc->sc_dv.dv_xname, tbuf, sc->sc_ncylinders, sc->sc_nheads, sc->sc_nsectors, sc->sc_secsize, sc->sc_secperunit); + ld_set_properties(sc); + #if NRND > 0 /* Attach the device into the rnd source list. */ rnd_attach_source(&sc->sc_rnd_source, sc->sc_dv.dv_xname, @@ -389,6 +394,10 @@ ldioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct lwp *l) sc = device_lookup(&ld_cd, unit); error = 0; + error = disk_ioctl(&sc->sc_dk, cmd, addr, flag, l); + if (error != EPASSTHROUGH) + return (error); + switch (cmd) { case DIOCGDINFO: memcpy(addr, sc->sc_dk.dk_label, sizeof(struct disklabel)); @@ -824,3 +833,44 @@ ldminphys(struct buf *bp) bp->b_bcount = sc->sc_maxxfer; minphys(bp); } + +static void +ld_set_properties(struct ld_softc *ld) +{ + prop_dictionary_t disk_info, odisk_info, geom; + + disk_info = prop_dictionary_create(); + + geom = prop_dictionary_create(); + + prop_dictionary_set_uint64(geom, "sectors-per-unit", + ld->sc_secperunit); + + prop_dictionary_set_uint32(geom, "sector-size", + ld->sc_secsize); + + prop_dictionary_set_uint16(geom, "sectors-per-track", + ld->sc_nsectors); + + prop_dictionary_set_uint16(geom, "tracks-per-cylinder", + ld->sc_nheads); + + prop_dictionary_set_uint64(geom, "cylinders-per-unit", + ld->sc_ncylinders); + + prop_dictionary_set(disk_info, "geometry", geom); + prop_object_release(geom); + + prop_dictionary_set(device_properties(&ld->sc_dv), + "disk-info", disk_info); + + /* + * Don't release disk_info here; we keep a reference to it. + * disk_detach() will release it when we go away. + */ + + odisk_info = ld->sc_dk.dk_info; + ld->sc_dk.dk_info = disk_info; + if (odisk_info) + prop_object_release(odisk_info); +}