Centralize wedge ioctls in disk_ioctl.

This commit is contained in:
christos 2014-12-31 17:06:48 +00:00
parent 457507773a
commit 3be6bb2414
14 changed files with 118 additions and 566 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ace_ebus.c,v 1.14 2014/11/09 10:10:08 mlelstv Exp $ */
/* $NetBSD: ace_ebus.c,v 1.15 2014/12/31 17:06:48 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ace_ebus.c,v 1.14 2014/11/09 10:10:08 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: ace_ebus.c,v 1.15 2014/12/31 17:06:48 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -2247,46 +2247,6 @@ aceioctl(dev_t dev, u_long xfer, void *addr, int flag, struct lwp *l)
case DIOCCACHESYNC:
return 0;
case DIOCAWEDGE:
{
struct dkwedge_info *dkw = (void *) addr;
if ((flag & FWRITE) == 0)
return EBADF;
/* If the ioctl happens here, the parent is us. */
strcpy(dkw->dkw_parent, device_xname(ace->sc_dev));
return dkwedge_add(dkw);
}
case DIOCDWEDGE:
{
struct dkwedge_info *dkw = (void *) addr;
if ((flag & FWRITE) == 0)
return EBADF;
/* If the ioctl happens here, the parent is us. */
strcpy(dkw->dkw_parent, device_xname(ace->sc_dev));
return dkwedge_del(dkw);
}
case DIOCLWEDGES:
{
struct dkwedge_list *dkwl = (void *) addr;
return dkwedge_list(&ace->sc_dk, dkwl, l);
}
case DIOCMWEDGES:
{
if ((flag & FWRITE) == 0)
return EBADF;
dkwedge_discover(&ace->sc_dk);
return 0;
}
case DIOCGSTRATEGY:
{
struct disk_strategy *dks = (void *)addr;

View File

@ -1,4 +1,4 @@
/* $NetBSD: flash_ebus.c,v 1.12 2014/11/09 10:10:08 mlelstv Exp $ */
/* $NetBSD: flash_ebus.c,v 1.13 2014/12/31 17:06:48 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: flash_ebus.c,v 1.12 2014/11/09 10:10:08 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: flash_ebus.c,v 1.13 2014/12/31 17:06:48 christos Exp $");
/* Driver for the Intel 28F320/640/128 (J3A150) StrataFlash memory device
* Extended to include the Intel JS28F256P30T95.
@ -2164,46 +2164,6 @@ eflashioctl(dev_t dev, u_long xfer, void *addr, int flag, struct lwp *l)
case DIOCCACHESYNC:
return 0;
case DIOCAWEDGE:
{
struct dkwedge_info *dkw = (void *) addr;
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strcpy(dkw->dkw_parent, device_xname(sc->sc_dev));
return (dkwedge_add(dkw));
}
case DIOCDWEDGE:
{
struct dkwedge_info *dkw = (void *) addr;
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strcpy(dkw->dkw_parent, device_xname(sc->sc_dev));
return (dkwedge_del(dkw));
}
case DIOCLWEDGES:
{
struct dkwedge_list *dkwl = (void *) addr;
return (dkwedge_list(&sc->sc_dk, dkwl, l));
}
case DIOCMWEDGES:
{
if ((flag & FWRITE) == 0)
return (EBADF);
dkwedge_discover(&sc->sc_dk);
return 0;
}
case DIOCGSTRATEGY:
{
struct disk_strategy *dks = (void *)addr;

View File

@ -1,4 +1,4 @@
/* $NetBSD: wd.c,v 1.415 2014/11/04 07:51:55 mlelstv Exp $ */
/* $NetBSD: wd.c,v 1.416 2014/12/31 17:06:48 christos Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved.
@ -54,7 +54,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.415 2014/11/04 07:51:55 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.416 2014/12/31 17:06:48 christos Exp $");
#include "opt_ata.h"
@ -1479,46 +1479,6 @@ wdioctl(dev_t dev, u_long xfer, void *addr, int flag, struct lwp *l)
return(error1);
}
case DIOCAWEDGE:
{
struct dkwedge_info *dkw = (void *) addr;
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strcpy(dkw->dkw_parent, device_xname(wd->sc_dev));
return (dkwedge_add(dkw));
}
case DIOCDWEDGE:
{
struct dkwedge_info *dkw = (void *) addr;
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strcpy(dkw->dkw_parent, device_xname(wd->sc_dev));
return (dkwedge_del(dkw));
}
case DIOCLWEDGES:
{
struct dkwedge_list *dkwl = (void *) addr;
return (dkwedge_list(&wd->sc_dk, dkwl, l));
}
case DIOCMWEDGES:
{
if ((flag & FWRITE) == 0)
return (EBADF);
dkwedge_discover(&wd->sc_dk);
return 0;
}
case DIOCGSTRATEGY:
{
struct disk_strategy *dks = (void *)addr;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ccd.c,v 1.159 2014/12/30 20:57:37 christos Exp $ */
/* $NetBSD: ccd.c,v 1.160 2014/12/31 17:06:48 christos Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@ -88,7 +88,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.159 2014/12/30 20:57:37 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.160 2014/12/31 17:06:48 christos Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@ -1415,42 +1415,6 @@ ccdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
}
break;
case DIOCAWEDGE:
{
struct dkwedge_info *dkw = (void *) data;
/* If the ioctl happens here, the parent is us. */
strlcpy(dkw->dkw_parent, cs->sc_xname,
sizeof(dkw->dkw_parent));
error = dkwedge_add(dkw);
break;
}
case DIOCDWEDGE:
{
struct dkwedge_info *dkw = (void *) data;
/* If the ioctl happens here, the parent is us. */
strlcpy(dkw->dkw_parent, cs->sc_xname,
sizeof(dkw->dkw_parent));
error = dkwedge_del(dkw);
break;
}
case DIOCLWEDGES:
{
struct dkwedge_list *dkwl = (void *) data;
error = dkwedge_list(&cs->sc_dkdev, dkwl, l);
break;
}
case DIOCMWEDGES:
{
dkwedge_discover(&cs->sc_dkdev);
break;
}
case DIOCWDINFO:
case DIOCSDINFO:
#ifdef __HAVE_OLD_DISKLABEL

View File

@ -1,4 +1,4 @@
/* $NetBSD: dksubr.c,v 1.56 2014/12/29 18:41:20 mlelstv Exp $ */
/* $NetBSD: dksubr.c,v 1.57 2014/12/31 17:06:48 christos Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.56 2014/12/29 18:41:20 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.57 2014/12/31 17:06:48 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -285,11 +285,11 @@ dk_ioctl(struct dk_intf *di, struct dk_softc *dksc, dev_t dev,
u_long cmd, void *data, int flag, struct lwp *l)
{
struct disklabel *lp;
struct disk *dk;
struct disk *dk = &dksc->sc_dkdev;
#ifdef __HAVE_OLD_DISKLABEL
struct disklabel newlabel;
#endif
int error = 0;
int error;
DPRINTF_FOLLOW(("dk_ioctl(%s, %p, 0x%"PRIx64", 0x%lx)\n",
di->di_dkname, dksc, dev, cmd));
@ -332,6 +332,12 @@ dk_ioctl(struct dk_intf *di, struct dk_softc *dksc, dev_t dev,
return ENXIO;
}
error = disk_ioctl(dk, cmd, data, flag, l);
if (error != EPASSTHROUGH)
return error;
else
error = 0;
switch (cmd) {
case DIOCGDINFO:
*(struct disklabel *)data = *(dksc->sc_dkdev.dk_label);
@ -367,7 +373,6 @@ dk_ioctl(struct dk_intf *di, struct dk_softc *dksc, dev_t dev,
#endif
lp = (struct disklabel *)data;
dk = &dksc->sc_dkdev;
mutex_enter(&dk->dk_openlock);
dksc->sc_flags |= DKF_LABELLING;
@ -408,46 +413,6 @@ dk_ioctl(struct dk_intf *di, struct dk_softc *dksc, dev_t dev,
break;
#endif
case DIOCAWEDGE:
{
struct dkwedge_info *dkw = (void *)data;
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strcpy(dkw->dkw_parent, dksc->sc_dkdev.dk_name);
return (dkwedge_add(dkw));
}
case DIOCDWEDGE:
{
struct dkwedge_info *dkw = (void *)data;
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strcpy(dkw->dkw_parent, dksc->sc_dkdev.dk_name);
return (dkwedge_del(dkw));
}
case DIOCLWEDGES:
{
struct dkwedge_list *dkwl = (void *)data;
return (dkwedge_list(&dksc->sc_dkdev, dkwl, l));
}
case DIOCMWEDGES:
{
if ((flag & FWRITE) == 0)
return (EBADF);
dkwedge_discover(&dksc->sc_dkdev);
return 0;
}
case DIOCGSTRATEGY:
{
struct disk_strategy *dks = (void *)data;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ld.c,v 1.78 2014/11/04 07:51:54 mlelstv Exp $ */
/* $NetBSD: ld.c,v 1.79 2014/12/31 17:06:48 christos Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.78 2014/11/04 07:51:54 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.79 2014/12/31 17:06:48 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -523,48 +523,6 @@ ldioctl(dev_t dev, u_long cmd, void *addr, int32_t flag, struct lwp *l)
error = 0; /* XXX Error out instead? */
break;
case DIOCAWEDGE:
{
struct dkwedge_info *dkw = (void *) addr;
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strlcpy(dkw->dkw_parent, device_xname(sc->sc_dv),
sizeof(dkw->dkw_parent));
return (dkwedge_add(dkw));
}
case DIOCDWEDGE:
{
struct dkwedge_info *dkw = (void *) addr;
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strlcpy(dkw->dkw_parent, device_xname(sc->sc_dv),
sizeof(dkw->dkw_parent));
return (dkwedge_del(dkw));
}
case DIOCLWEDGES:
{
struct dkwedge_list *dkwl = (void *) addr;
return (dkwedge_list(&sc->sc_dk, dkwl, l));
}
case DIOCMWEDGES:
{
if ((flag & FWRITE) == 0)
return (EBADF);
dkwedge_discover(&sc->sc_dk);
return 0;
}
case DIOCGSTRATEGY:
{
struct disk_strategy *dks = (void *)addr;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ed_mca.c,v 1.59 2014/11/09 10:10:08 mlelstv Exp $ */
/* $NetBSD: ed_mca.c,v 1.60 2014/12/31 17:06:48 christos Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ed_mca.c,v 1.59 2014/11/09 10:10:08 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: ed_mca.c,v 1.60 2014/12/31 17:06:48 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -478,6 +478,10 @@ edmcaioctl(dev_t dev, u_long xfer, void *addr, int flag, struct lwp *l)
if ((ed->sc_flags & WDF_LOADED) == 0)
return EIO;
error = disk_ioctl(&ed->sc_dk, xfer, addr, flag, l);
if (error != EPASSTHROUGH)
return error;
switch (xfer) {
case DIOCGDINFO:
*(struct disklabel *)addr = *(ed->sc_dk.dk_label);
@ -569,48 +573,6 @@ edmcaioctl(dev_t dev, u_long xfer, void *addr, int flag, struct lwp *l)
}
#endif
case DIOCAWEDGE:
{
struct dkwedge_info *dkw = (void *) addr;
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strlcpy(dkw->dkw_parent, device_xname(ed->sc_dev),
sizeof(dkw->dkw_parent));
return (dkwedge_add(dkw));
}
case DIOCDWEDGE:
{
struct dkwedge_info *dkw = (void *) addr;
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strlcpy(dkw->dkw_parent, device_xname(ed->sc_dev),
sizeof(dkw->dkw_parent));
return (dkwedge_del(dkw));
}
case DIOCLWEDGES:
{
struct dkwedge_list *dkwl = (void *) addr;
return (dkwedge_list(&ed->sc_dk, dkwl, l));
}
case DIOCMWEDGES:
{
if ((flag & FWRITE) == 0)
return (EBADF);
dkwedge_discover(&ed->sc_dk);
return 0;
}
default:
return ENOTTY;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mscp_disk.c,v 1.82 2014/11/09 10:10:08 mlelstv Exp $ */
/* $NetBSD: mscp_disk.c,v 1.83 2014/12/31 17:06:48 christos Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
@ -82,7 +82,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.82 2014/11/09 10:10:08 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.83 2014/12/31 17:06:48 christos Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@ -405,13 +405,19 @@ raioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
{
struct disklabel *lp, *tp;
struct ra_softc *ra = mscp_device_lookup(dev);
int error = 0;
int error;
#ifdef __HAVE_OLD_DISKLABEL
struct disklabel newlabel;
#endif
lp = ra->ra_disk.dk_label;
error = disk_ioctl(&ra->ra_disk, cmd, data, flag, l);
if (error != EPASSTHROUGH)
return error;
else
error = 0;
switch (cmd) {
case DIOCGDINFO:
@ -497,48 +503,6 @@ raioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
#endif
break;
case DIOCAWEDGE:
{
struct dkwedge_info *dkw = (void *) data;
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strlcpy(dkw->dkw_parent, device_xname(ra->ra_dev),
sizeof(dkw->dkw_parent));
return (dkwedge_add(dkw));
}
case DIOCDWEDGE:
{
struct dkwedge_info *dkw = (void *) data;
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strlcpy(dkw->dkw_parent, device_xname(ra->ra_dev),
sizeof(dkw->dkw_parent));
return (dkwedge_del(dkw));
}
case DIOCLWEDGES:
{
struct dkwedge_list *dkwl = (void *) data;
return (dkwedge_list(&ra->ra_disk, dkwl, l));
}
case DIOCMWEDGES:
{
if ((flag & FWRITE) == 0)
return (EBADF);
dkwedge_discover(&ra->ra_disk);
return 0;
}
default:
error = ENOTTY;
break;
@ -909,10 +873,16 @@ rxioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
int unit = DISKUNIT(dev);
struct disklabel *lp;
struct rx_softc *rx = device_lookup_private(&rx_cd, unit);
int error = 0;
int error;
lp = rx->ra_disk.dk_label;
error = disk_ioctl(&rx->ra_disk, cmd, data, flag, l);
if (error != EPASSTHROUGH)
return error;
else
error = 0;
switch (cmd) {
case DIOCGDINFO:

View File

@ -1,4 +1,4 @@
/* $NetBSD: ofdisk.c,v 1.48 2014/11/09 10:10:08 mlelstv Exp $ */
/* $NetBSD: ofdisk.c,v 1.49 2014/12/31 17:06:48 christos Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ofdisk.c,v 1.48 2014/11/09 10:10:08 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: ofdisk.c,v 1.49 2014/12/31 17:06:48 christos Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@ -359,6 +359,19 @@ ofdisk_ioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
#ifdef __HAVE_OLD_DISKLABEL
struct disklabel newlabel;
#endif
/* XXX: Why not allow wedges on floppy? */
switch (cmd) {
case DIOCDWEDGE:
case DIOCAWEDGE:
case DIOCLWEDGES:
case DIOCMWEDGES:
if (OFDISK_FLOPPY_P(of))
return ENOTTY;
}
error = disk_ioctl(&of->sc_dk, cmd, data, flag, l);
if (error != EPASSTHROUGH)
return error;
switch (cmd) {
case DIOCGDINFO:
@ -431,60 +444,6 @@ ofdisk_ioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
return 0;
#endif
case DIOCAWEDGE:
{
struct dkwedge_info *dkw = (void *) data;
if (OFDISK_FLOPPY_P(of))
return (ENOTTY);
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strlcpy(dkw->dkw_parent, device_xname(of->sc_dev),
sizeof(dkw->dkw_parent));
return (dkwedge_add(dkw));
}
case DIOCDWEDGE:
{
struct dkwedge_info *dkw = (void *) data;
if (OFDISK_FLOPPY_P(of))
return (ENOTTY);
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strlcpy(dkw->dkw_parent, device_xname(of->sc_dev),
sizeof(dkw->dkw_parent));
return (dkwedge_del(dkw));
}
case DIOCLWEDGES:
{
struct dkwedge_list *dkwl = (void *) data;
if (OFDISK_FLOPPY_P(of))
return (ENOTTY);
return (dkwedge_list(&of->sc_dk, dkwl, l));
}
case DIOCMWEDGES:
{
if (OFDISK_FLOPPY_P(of))
return (ENOTTY);
if ((flag & FWRITE) == 0)
return (EBADF);
dkwedge_discover(&of->sc_dk);
return 0;
}
default:
return ENOTTY;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rl.c,v 1.46 2014/11/09 10:10:08 mlelstv Exp $ */
/* $NetBSD: rl.c,v 1.47 2014/12/31 17:06:48 christos Exp $ */
/*
* Copyright (c) 2000 Ludd, University of Lule}, Sweden. All rights reserved.
@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rl.c,v 1.46 2014/11/09 10:10:08 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: rl.c,v 1.47 2014/12/31 17:06:48 christos Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -443,11 +443,17 @@ rlioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
{
struct rl_softc *rc = device_lookup_private(&rl_cd, DISKUNIT(dev));
struct disklabel *lp = rc->rc_disk.dk_label;
int err = 0;
int error;
#ifdef __HAVE_OLD_DISKLABEL
struct disklabel newlabel;
struct diklabel newlabel;
#endif
error = disk_ioctl(&rc->rc_disk, xfer, addr, flag, l);
if (error != EPASSTHROUGH)
return error;
else
error = 0;
switch (cmd) {
case DIOCGDINFO:
memcpy(addr, lp, sizeof (struct disklabel));
@ -487,10 +493,10 @@ rlioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
tp = (struct disklabel *)addr;
if ((flag & FWRITE) == 0)
err = EBADF;
error = EBADF;
else {
mutex_enter(&rc->rc_disk.dk_openlock);
err = ((
error = ((
#ifdef __HAVE_OLD_DISKLABEL
cmd == ODIOCSDINFO ||
#endif
@ -504,50 +510,14 @@ rlioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
case DIOCWLABEL:
if ((flag & FWRITE) == 0)
err = EBADF;
error = EBADF;
break;
case DIOCAWEDGE: {
struct dkwedge_info *dkw = (void *) addr;
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strcpy(dkw->dkw_parent, device_xname(rc->rc_dev));
return dkwedge_add(dkw);
}
case DIOCDWEDGE: {
struct dkwedge_info *dkw = (void *) addr;
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strcpy(dkw->dkw_parent, device_xname(rc->rc_dev));
return dkwedge_del(dkw);
}
case DIOCLWEDGES: {
struct dkwedge_list *dkwl = (void *) addr;
return dkwedge_list(&rc->rc_disk, dkwl, l);
}
case DIOCMWEDGES: {
if ((flag & FWRITE) == 0)
return (EBADF);
dkwedge_discover(&rc->rc_disk);
return 0;
}
default:
err = ENOTTY;
error = ENOTTY;
break;
}
return err;
return error;
}
int

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_netbsdkintf.c,v 1.318 2014/12/31 08:24:50 mlelstv Exp $ */
/* $NetBSD: rf_netbsdkintf.c,v 1.319 2014/12/31 17:06:48 christos Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@ -101,7 +101,7 @@
***********************************************************/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.318 2014/12/31 08:24:50 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.319 2014/12/31 17:06:48 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@ -1062,7 +1062,6 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
#ifdef __HAVE_OLD_DISKLABEL
struct disklabel newlabel;
#endif
struct dkwedge_info *dkw;
if ((rs = raidget(unit)) == NULL)
return ENXIO;
@ -1913,20 +1912,6 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
break;
#endif
case DIOCAWEDGE:
case DIOCDWEDGE:
dkw = (void *)data;
/* If the ioctl happens here, the parent is us. */
(void)strcpy(dkw->dkw_parent, rs->sc_xname);
return cmd == DIOCAWEDGE ? dkwedge_add(dkw) : dkwedge_del(dkw);
case DIOCLWEDGES:
return dkwedge_list(&rs->sc_dkdev,
(struct dkwedge_list *)data, l);
case DIOCMWEDGES:
dkwedge_discover(&rs->sc_dkdev);
return 0;
case DIOCCACHESYNC:
return rf_sync_component_caches(raidPtr);

View File

@ -1,4 +1,4 @@
/* $NetBSD: sd.c,v 1.311 2014/12/31 08:24:50 mlelstv Exp $ */
/* $NetBSD: sd.c,v 1.312 2014/12/31 17:06:48 christos Exp $ */
/*-
* Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.311 2014/12/31 08:24:50 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.312 2014/12/31 17:06:48 christos Exp $");
#include "opt_scsi.h"
@ -1223,48 +1223,6 @@ sdioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
}
return (error);
case DIOCAWEDGE:
{
struct dkwedge_info *dkw = (void *) addr;
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strlcpy(dkw->dkw_parent, device_xname(sd->sc_dev),
sizeof(dkw->dkw_parent));
return (dkwedge_add(dkw));
}
case DIOCDWEDGE:
{
struct dkwedge_info *dkw = (void *) addr;
if ((flag & FWRITE) == 0)
return (EBADF);
/* If the ioctl happens here, the parent is us. */
strlcpy(dkw->dkw_parent, device_xname(sd->sc_dev),
sizeof(dkw->dkw_parent));
return (dkwedge_del(dkw));
}
case DIOCLWEDGES:
{
struct dkwedge_list *dkwl = (void *) addr;
return (dkwedge_list(&sd->sc_dk, dkwl, l));
}
case DIOCMWEDGES:
{
if ((flag & FWRITE) == 0)
return (EBADF);
dkwedge_discover(&sd->sc_dk);
return 0;
}
case DIOCGSTRATEGY:
{
struct disk_strategy *dks = addr;

View File

@ -1,4 +1,4 @@
/* $NetBSD: vnd.c,v 1.236 2014/12/31 08:24:50 mlelstv Exp $ */
/* $NetBSD: vnd.c,v 1.237 2014/12/31 17:06:48 christos Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.236 2014/12/31 08:24:50 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.237 2014/12/31 17:06:48 christos Exp $");
#if defined(_KERNEL_OPT)
#include "opt_vnd.h"
@ -1041,8 +1041,6 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
#ifdef __HAVE_OLD_DISKLABEL
struct disklabel newlabel;
#endif
struct dkwedge_info *dkw;
struct dkwedge_list *dkwl;
#ifdef DEBUG
if (vnddebug & VDB_FOLLOW)
@ -1564,40 +1562,6 @@ unlock_and_exit:
VOP_UNLOCK(vnd->sc_vp);
return error;
case DIOCAWEDGE:
dkw = (void *) data;
if ((flag & FWRITE) == 0)
return EBADF;
/* If the ioctl happens here, the parent is us. */
strlcpy(dkw->dkw_parent, device_xname(vnd->sc_dev),
sizeof(dkw->dkw_parent));
return dkwedge_add(dkw);
case DIOCDWEDGE:
dkw = (void *) data;
if ((flag & FWRITE) == 0)
return EBADF;
/* If the ioctl happens here, the parent is us. */
strlcpy(dkw->dkw_parent, device_xname(vnd->sc_dev),
sizeof(dkw->dkw_parent));
return dkwedge_del(dkw);
case DIOCLWEDGES:
dkwl = (void *) data;
return dkwedge_list(&vnd->sc_dkdev, dkwl, l);
case DIOCMWEDGES:
if ((flag & FWRITE) == 0)
return EBADF;
dkwedge_discover(&vnd->sc_dkdev);
return 0;
default:
return ENOTTY;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_disk.c,v 1.106 2014/12/31 08:24:51 mlelstv Exp $ */
/* $NetBSD: subr_disk.c,v 1.107 2014/12/31 17:06:49 christos Exp $ */
/*-
* Copyright (c) 1996, 1997, 1999, 2000, 2009 The NetBSD Foundation, Inc.
@ -67,12 +67,13 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.106 2014/12/31 08:24:51 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.107 2014/12/31 17:06:49 christos Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/kmem.h>
#include <sys/buf.h>
#include <sys/fcntl.h>
#include <sys/syslog.h>
#include <sys/disklabel.h>
#include <sys/disk.h>
@ -487,38 +488,54 @@ convertdisklabel(struct disklabel *lp, void (*strat)(struct buf *),
* Generic disk ioctl handling.
*/
int
disk_ioctl(struct disk *diskp, u_long cmd, void *data, int flag,
struct lwp *l)
disk_ioctl(struct disk *dk, u_long cmd, void *data, int flag, struct lwp *l)
{
int error = 0;
struct dkwedge_info *dkw;
switch (cmd) {
case DIOCGDISKINFO:
{
struct plistref *pref = (struct plistref *) data;
case DIOCAWEDGE:
if ((flag & FWRITE) == 0)
return EBADF;
if (diskp->dk_info == NULL)
error = ENOTSUP;
else
error = prop_dictionary_copyout_ioctl(pref, cmd,
diskp->dk_info);
break;
}
dkw = data;
strlcpy(dkw->dkw_parent, dk->dk_name, sizeof(dkw->dkw_parent));
return dkwedge_add(dkw);
case DIOCDWEDGE:
if ((flag & FWRITE) == 0)
return EBADF;
dkw = data;
strlcpy(dkw->dkw_parent, dk->dk_name, sizeof(dkw->dkw_parent));
return dkwedge_del(dkw);
case DIOCLWEDGES:
return dkwedge_list(dk, data, l);
case DIOCMWEDGES:
if ((flag & FWRITE) == 0)
return EBADF;
dkwedge_discover(dk);
return 0;
case DIOCGDISKINFO:
if (dk->dk_info == NULL)
return ENOTSUP;
return prop_dictionary_copyout_ioctl(data, cmd, dk->dk_info);
case DIOCGSECTORSIZE:
*(u_int *)data = diskp->dk_geom.dg_secsize;
break;
*(u_int *)data = dk->dk_geom.dg_secsize;
return 0;
case DIOCGMEDIASIZE:
*(off_t *)data = (off_t)diskp->dk_geom.dg_secsize *
diskp->dk_geom.dg_secperunit;
break;
*(off_t *)data = (off_t)dk->dk_geom.dg_secsize *
dk->dk_geom.dg_secperunit;
return 0;
default:
error = EPASSTHROUGH;
return EPASSTHROUGH;
}
return (error);
}
void