From 7a222a4140578274da57be5d1488c9d5c6c9c754 Mon Sep 17 00:00:00 2001 From: mlelstv Date: Tue, 29 Mar 2016 04:55:53 +0000 Subject: [PATCH] Initialize disk_geom information, DIOCGPARTINFO relies on it. --- sys/dev/mscp/mscp_disk.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/sys/dev/mscp/mscp_disk.c b/sys/dev/mscp/mscp_disk.c index 2c9ef3f20a51..5b5550750e70 100644 --- a/sys/dev/mscp/mscp_disk.c +++ b/sys/dev/mscp/mscp_disk.c @@ -1,4 +1,4 @@ -/* $NetBSD: mscp_disk.c,v 1.88 2015/04/26 15:15:20 mlelstv Exp $ */ +/* $NetBSD: mscp_disk.c,v 1.89 2016/03/29 04:55:53 mlelstv Exp $ */ /* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. @@ -82,7 +82,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.88 2015/04/26 15:15:20 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89 2016/03/29 04:55:53 mlelstv Exp $"); #include #include @@ -723,6 +723,29 @@ raattach(device_t parent, device_t self, void *aux) } } +/* + * Initialize drive geometry data from disklabel + */ +static void +ra_set_geometry(struct ra_softc *ra) +{ + struct disklabel *dl; + struct disk_geom *dg; + + dl = ra->ra_disk.dk_label; + dg = &ra->ra_disk.dk_geom; + + memset(dg, 0, sizeof(*dg)); + dg->dg_secsize = dl->d_secsize; + dg->dg_nsectors = dl->d_nsectors; + dg->dg_ntracks = dl->d_ntracks; + + dg->dg_ncylinders = dl->d_ncylinders; + dg->dg_secperunit = dl->d_secperunit; + + disk_set_info(ra->ra_dev, &ra->ra_disk, NULL); +} + /* * (Try to) put the drive online. This is done the first time the * drive is opened, or if it har fallen offline. @@ -968,6 +991,7 @@ rronline(device_t usc, struct mscp *mp) dl->d_rpm = 300; } rrmakelabel(dl, ra->ra_mediaid); + ra_set_geometry(ra); return (MSCP_DONE); }