Module Name: src Committed By: riz Date: Thu Jun 24 21:20:23 UTC 2010
Modified Files: src/sys/dev: vnd.c Log Message: Add wedge (dk(4)) support to vnd(4) devices. To generate a diff of this commit: cvs rdiff -u -r1.209 -r1.210 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.209 src/sys/dev/vnd.c:1.210 --- src/sys/dev/vnd.c:1.209 Thu Jun 24 13:03:08 2010 +++ src/sys/dev/vnd.c Thu Jun 24 21:20:23 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.209 2010/06/24 13:03:08 hannken Exp $ */ +/* $NetBSD: vnd.c,v 1.210 2010/06/24 21:20:23 riz Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -130,7 +130,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.209 2010/06/24 13:03:08 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.210 2010/06/24 21:20:23 riz Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -254,6 +254,8 @@ static struct vnd_softc *vnd_spawn(int); int vnd_destroy(device_t); +static struct dkdriver vnddkdriver = { vndstrategy, minphys }; + void vndattach(int num) { @@ -282,7 +284,7 @@ sc->sc_comp_buff = NULL; sc->sc_comp_decombuf = NULL; bufq_alloc(&sc->sc_tab, "disksort", BUFQ_SORT_RAWBLOCK); - disk_init(&sc->sc_dkdev, device_xname(self), NULL); + disk_init(&sc->sc_dkdev, device_xname(self), &vnddkdriver); if (!pmf_device_register(self, NULL, NULL)) aprint_error_dev(self, "couldn't establish power handler\n"); } @@ -1019,6 +1021,8 @@ #ifdef __HAVE_OLD_DISKLABEL struct disklabel newlabel; #endif + struct dkwedge_info *dkw; + struct dkwedge_list *dkwl; #ifdef DEBUG if (vnddebug & VDB_FOLLOW) @@ -1501,6 +1505,33 @@ 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); + default: return ENOTTY; }