eliminare dk_geom
This commit is contained in:
parent
cfef8e95ca
commit
1af75d448c
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cgd.c,v 1.79 2013/05/29 00:47:48 christos Exp $ */
|
||||
/* $NetBSD: cgd.c,v 1.80 2013/05/29 23:25:39 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.79 2013/05/29 00:47:48 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.80 2013/05/29 23:25:39 christos Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
@ -610,6 +610,7 @@ cgd_ioctl_set(struct cgd_softc *cs, void *data, struct lwp *l)
|
|||
const char *cp;
|
||||
struct pathbuf *pb;
|
||||
char *inbuf;
|
||||
struct dk_softc *dksc = &cs->sc_dksc;
|
||||
|
||||
cp = ci->ci_disk;
|
||||
|
||||
|
@ -687,23 +688,23 @@ cgd_ioctl_set(struct cgd_softc *cs, void *data, struct lwp *l)
|
|||
}
|
||||
free(inbuf, M_TEMP);
|
||||
|
||||
bufq_alloc(&cs->sc_dksc.sc_bufq, "fcfs", 0);
|
||||
bufq_alloc(&dksc->sc_bufq, "fcfs", 0);
|
||||
|
||||
cs->sc_data = malloc(MAXPHYS, M_DEVBUF, M_WAITOK);
|
||||
cs->sc_data_used = 0;
|
||||
|
||||
cs->sc_dksc.sc_flags |= DKF_INITED;
|
||||
dksc->sc_flags |= DKF_INITED;
|
||||
|
||||
dk_set_geometry(di, &cs->sc_dksc);
|
||||
disk_set_info(dksc->sc_dev, &dksc->sc_dkdev, NULL);
|
||||
|
||||
/* Attach the disk. */
|
||||
disk_attach(&cs->sc_dksc.sc_dkdev);
|
||||
disk_attach(&dksc->sc_dkdev);
|
||||
|
||||
/* Try and read the disklabel. */
|
||||
dk_getdisklabel(di, &cs->sc_dksc, 0 /* XXX ? (cause of PR 41704) */);
|
||||
dk_getdisklabel(di, dksc, 0 /* XXX ? (cause of PR 41704) */);
|
||||
|
||||
/* Discover wedges on this disk. */
|
||||
dkwedge_discover(&cs->sc_dksc.sc_dkdev);
|
||||
dkwedge_discover(&dksc->sc_dkdev);
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -718,29 +719,27 @@ static int
|
|||
cgd_ioctl_clr(struct cgd_softc *cs, struct lwp *l)
|
||||
{
|
||||
int s;
|
||||
struct dk_softc *dksc;
|
||||
|
||||
dksc = &cs->sc_dksc;
|
||||
struct dk_softc *dksc = &cs->sc_dksc;
|
||||
|
||||
if ((dksc->sc_flags & DKF_INITED) == 0)
|
||||
return ENXIO;
|
||||
|
||||
/* Delete all of our wedges. */
|
||||
dkwedge_delall(&cs->sc_dksc.sc_dkdev);
|
||||
dkwedge_delall(&dksc->sc_dkdev);
|
||||
|
||||
/* Kill off any queued buffers. */
|
||||
s = splbio();
|
||||
bufq_drain(cs->sc_dksc.sc_bufq);
|
||||
bufq_drain(dksc->sc_bufq);
|
||||
splx(s);
|
||||
bufq_free(cs->sc_dksc.sc_bufq);
|
||||
bufq_free(dksc->sc_bufq);
|
||||
|
||||
(void)vn_close(cs->sc_tvn, FREAD|FWRITE, l->l_cred);
|
||||
cs->sc_cfuncs->cf_destroy(cs->sc_cdata.cf_priv);
|
||||
free(cs->sc_tpath, M_DEVBUF);
|
||||
free(cs->sc_data, M_DEVBUF);
|
||||
cs->sc_data_used = 0;
|
||||
cs->sc_dksc.sc_flags &= ~DKF_INITED;
|
||||
disk_detach(&cs->sc_dksc.sc_dkdev);
|
||||
dksc->sc_flags &= ~DKF_INITED;
|
||||
disk_detach(&dksc->sc_dkdev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -751,6 +750,7 @@ cgd_ioctl_get(dev_t dev, void *data, struct lwp *l)
|
|||
struct cgd_softc *cs;
|
||||
struct cgd_user *cgu;
|
||||
int unit;
|
||||
struct dk_softc *dksc = &cs->sc_dksc;
|
||||
|
||||
unit = CGDUNIT(dev);
|
||||
cgu = (struct cgd_user *)data;
|
||||
|
@ -765,7 +765,7 @@ cgd_ioctl_get(dev_t dev, void *data, struct lwp *l)
|
|||
return EINVAL; /* XXX: should this be ENXIO? */
|
||||
|
||||
cs = device_lookup_private(&cgd_cd, unit);
|
||||
if (cs == NULL || (cs->sc_dksc.sc_flags & DKF_INITED) == 0) {
|
||||
if (cs == NULL || (dksc->sc_flags & DKF_INITED) == 0) {
|
||||
cgu->cgu_dev = 0;
|
||||
cgu->cgu_alg[0] = '\0';
|
||||
cgu->cgu_blocksize = 0;
|
||||
|
@ -787,14 +787,14 @@ static int
|
|||
cgdinit(struct cgd_softc *cs, const char *cpath, struct vnode *vp,
|
||||
struct lwp *l)
|
||||
{
|
||||
struct dk_geom *pdg;
|
||||
struct disk_geom *dg;
|
||||
struct vattr va;
|
||||
int ret;
|
||||
char *tmppath;
|
||||
uint64_t psize;
|
||||
unsigned secsize;
|
||||
struct dk_softc *dksc = &cs->sc_dksc;
|
||||
|
||||
cs->sc_dksc.sc_size = 0;
|
||||
cs->sc_tvn = vp;
|
||||
cs->sc_tpath = NULL;
|
||||
|
||||
|
@ -821,19 +821,20 @@ cgdinit(struct cgd_softc *cs, const char *cpath, struct vnode *vp,
|
|||
goto bail;
|
||||
}
|
||||
|
||||
cs->sc_dksc.sc_size = psize;
|
||||
|
||||
/*
|
||||
* XXX here we should probe the underlying device. If we
|
||||
* are accessing a partition of type RAW_PART, then
|
||||
* we should populate our initial geometry with the
|
||||
* geometry that we discover from the device.
|
||||
*/
|
||||
pdg = &cs->sc_dksc.sc_geom;
|
||||
pdg->pdg_secsize = DEV_BSIZE;
|
||||
pdg->pdg_ntracks = 1;
|
||||
pdg->pdg_nsectors = 1024 * (1024 / pdg->pdg_secsize);
|
||||
pdg->pdg_ncylinders = cs->sc_dksc.sc_size / pdg->pdg_nsectors;
|
||||
dg = &dksc->sc_dkdev.dk_geom;
|
||||
memset(dg, 0, sizeof(*dg));
|
||||
dg->dg_secperunit = psize;
|
||||
// XXX: Inherit?
|
||||
dg->dg_secsize = DEV_BSIZE;
|
||||
dg->dg_ntracks = 1;
|
||||
dg->dg_nsectors = 1024 * (1024 / dg->dg_secsize);
|
||||
dg->dg_ncylinders = dg->dg_secperunit / dg->dg_nsectors;
|
||||
|
||||
bail:
|
||||
free(tmppath, M_TEMP);
|
||||
|
|
Loading…
Reference in New Issue