geom_disk.c (92108) | geom_disk.c (92403) |
---|---|
1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 18 unchanged lines hidden (view full) --- 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * | 1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 18 unchanged lines hidden (view full) --- 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * |
35 * $FreeBSD: head/sys/geom/geom_disk.c 92108 2002-03-11 21:42:35Z phk $ | 35 * $FreeBSD: head/sys/geom/geom_disk.c 92403 2002-03-16 09:24:19Z phk $ |
36 */ 37 38#include "opt_geom.h" 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/kernel.h> 43#include <sys/sysctl.h> --- 66 unchanged lines hidden (view full) --- 110} 111 112static void 113g_disk_start(struct bio *bp) 114{ 115 struct bio *bp2; 116 dev_t dev; 117 struct disk *dp; | 36 */ 37 38#include "opt_geom.h" 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/kernel.h> 43#include <sys/sysctl.h> --- 66 unchanged lines hidden (view full) --- 110} 111 112static void 113g_disk_start(struct bio *bp) 114{ 115 struct bio *bp2; 116 dev_t dev; 117 struct disk *dp; |
118 struct g_ioctl *gio; 119 int error; |
|
118 119 dp = bp->bio_to->geom->softc; 120 dev = dp->d_dev; | 120 121 dp = bp->bio_to->geom->softc; 122 dev = dp->d_dev; |
123 error = 0; |
|
121 switch(bp->bio_cmd) { 122 case BIO_READ: 123 case BIO_WRITE: 124 bp2 = g_clone_bio(bp); 125 bp2->bio_done = g_disk_done; 126 bp2->bio_blkno = bp2->bio_offset >> DEV_BSHIFT; 127 bp2->bio_pblkno = bp2->bio_blkno; 128 bp2->bio_bcount = bp2->bio_length; 129 bp2->bio_dev = dev; 130 mtx_lock(&Giant); 131 devsw(dev)->d_strategy(bp2); 132 mtx_unlock(&Giant); 133 break; 134 case BIO_GETATTR: 135 if (g_haveattr_int(bp, "GEOM::sectorsize", 136 dp->d_label.d_secsize)) | 124 switch(bp->bio_cmd) { 125 case BIO_READ: 126 case BIO_WRITE: 127 bp2 = g_clone_bio(bp); 128 bp2->bio_done = g_disk_done; 129 bp2->bio_blkno = bp2->bio_offset >> DEV_BSHIFT; 130 bp2->bio_pblkno = bp2->bio_blkno; 131 bp2->bio_bcount = bp2->bio_length; 132 bp2->bio_dev = dev; 133 mtx_lock(&Giant); 134 devsw(dev)->d_strategy(bp2); 135 mtx_unlock(&Giant); 136 break; 137 case BIO_GETATTR: 138 if (g_haveattr_int(bp, "GEOM::sectorsize", 139 dp->d_label.d_secsize)) |
137 return; 138 if (g_haveattr_int(bp, "GEOM::fwsectors", | 140 break; 141 else if (g_haveattr_int(bp, "GEOM::fwsectors", |
139 dp->d_label.d_nsectors)) | 142 dp->d_label.d_nsectors)) |
140 return; 141 if (g_haveattr_int(bp, "GEOM::fwheads", | 143 break; 144 else if (g_haveattr_int(bp, "GEOM::fwheads", |
142 dp->d_label.d_ntracks)) | 145 dp->d_label.d_ntracks)) |
143 return; 144 if (g_haveattr_int(bp, "GEOM::fwcylinders", | 146 break; 147 else if (g_haveattr_int(bp, "GEOM::fwcylinders", |
145 dp->d_label.d_ncylinders)) | 148 dp->d_label.d_ncylinders)) |
146 return; 147 if (g_haveattr_off_t(bp, "GEOM::mediasize", | 149 break; 150 else if (g_haveattr_off_t(bp, "GEOM::mediasize", |
148 dp->d_label.d_secsize * (off_t)dp->d_label.d_secperunit)) | 151 dp->d_label.d_secsize * (off_t)dp->d_label.d_secperunit)) |
149 return; 150 bp->bio_error = ENOIOCTL; 151 g_io_deliver(bp); 152 return; | 152 break; 153 else if (!strcmp(bp->bio_attribute, "GEOM::ioctl") && 154 bp->bio_length == sizeof *gio) { 155 gio = (struct g_ioctl *)bp->bio_data; 156 mtx_lock(&Giant); 157 error = devsw(dev)->d_ioctl(dev, gio->cmd, 158 gio->data, gio->fflag, gio->td); 159 mtx_unlock(&Giant); 160 } else 161 error = ENOIOCTL; 162 break; |
153 default: | 163 default: |
154 bp->bio_error = EOPNOTSUPP; | 164 error = EOPNOTSUPP; 165 break; 166 } 167 if (error) { 168 bp->bio_error = error; |
155 g_io_deliver(bp); | 169 g_io_deliver(bp); |
156 return; | |
157 } | 170 } |
171 return; |
|
158} 159 160dev_t 161disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw, struct cdevsw *proto) 162{ 163 static int once; 164 struct g_geom *gp; 165 struct g_provider *pp; --- 67 unchanged lines hidden --- | 172} 173 174dev_t 175disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw, struct cdevsw *proto) 176{ 177 static int once; 178 struct g_geom *gp; 179 struct g_provider *pp; --- 67 unchanged lines hidden --- |