geom_dev.c (e805e8f0e8f9f762bfb5bffd72380a1b101b1a8b) geom_dev.c (b1876192f015b1cf392b52b82b124265fc9683a7)
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

--- 110 unchanged lines hidden (view full) ---

119 EVENTHANDLER_REGISTER(dev_clone, g_dev_clone, 0, 1000);
120 once++;
121 }
122}
123
124SYSINIT(geomdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE,g_dev_register_cloner,NULL);
125
126static struct g_geom *
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

--- 110 unchanged lines hidden (view full) ---

119 EVENTHANDLER_REGISTER(dev_clone, g_dev_clone, 0, 1000);
120 once++;
121 }
122}
123
124SYSINIT(geomdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE,g_dev_register_cloner,NULL);
125
126static struct g_geom *
127g_dev_taste(struct g_class *mp, struct g_provider *pp, struct thread *tp __unused, int insist __unused)
127g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
128{
129 struct g_geom *gp;
130 struct g_consumer *cp;
131 static int unit;
132 u_int secsize;
133 off_t mediasize;
134 int error, j;
135 dev_t dev;

--- 5 unchanged lines hidden (view full) ---

141 return (NULL);
142 gp = g_new_geomf(mp, pp->name);
143 cp = g_new_consumer(gp);
144 g_attach(cp, pp);
145 error = g_access_rel(cp, 1, 0, 0);
146 g_topology_unlock();
147 if (!error) {
148 j = sizeof secsize;
128{
129 struct g_geom *gp;
130 struct g_consumer *cp;
131 static int unit;
132 u_int secsize;
133 off_t mediasize;
134 int error, j;
135 dev_t dev;

--- 5 unchanged lines hidden (view full) ---

141 return (NULL);
142 gp = g_new_geomf(mp, pp->name);
143 cp = g_new_consumer(gp);
144 g_attach(cp, pp);
145 error = g_access_rel(cp, 1, 0, 0);
146 g_topology_unlock();
147 if (!error) {
148 j = sizeof secsize;
149 error = g_io_getattr("GEOM::sectorsize", cp, &j, &secsize, tp);
149 error = g_io_getattr("GEOM::sectorsize", cp, &j, &secsize);
150 if (error) {
151 secsize = 512;
152 printf("g_bsd_taste: error %d Sectors are %d bytes\n",
153 error, secsize);
154 }
155 j = sizeof mediasize;
150 if (error) {
151 secsize = 512;
152 printf("g_bsd_taste: error %d Sectors are %d bytes\n",
153 error, secsize);
154 }
155 j = sizeof mediasize;
156 error = g_io_getattr("GEOM::mediasize", cp, &j, &mediasize, tp);
156 error = g_io_getattr("GEOM::mediasize", cp, &j, &mediasize);
157 if (error) {
158 mediasize = 0;
159 printf("g_error %d Mediasize is %lld bytes\n",
160 error, mediasize);
161 }
162 g_topology_lock();
163 g_access_rel(cp, -1, 0, 0);
164 g_topology_unlock();

--- 81 unchanged lines hidden (view full) ---

246 cp = dev->si_drv2;
247
248 error = 0;
249 DROP_GIANT();
250
251 i = IOCPARM_LEN(cmd);
252 switch (cmd) {
253 case DIOCGSECTORSIZE:
157 if (error) {
158 mediasize = 0;
159 printf("g_error %d Mediasize is %lld bytes\n",
160 error, mediasize);
161 }
162 g_topology_lock();
163 g_access_rel(cp, -1, 0, 0);
164 g_topology_unlock();

--- 81 unchanged lines hidden (view full) ---

246 cp = dev->si_drv2;
247
248 error = 0;
249 DROP_GIANT();
250
251 i = IOCPARM_LEN(cmd);
252 switch (cmd) {
253 case DIOCGSECTORSIZE:
254 error = g_io_getattr("GEOM::sectorsize", cp, &i, data, td);
254 error = g_io_getattr("GEOM::sectorsize", cp, &i, data);
255 break;
256 case DIOCGMEDIASIZE:
255 break;
256 case DIOCGMEDIASIZE:
257 error = g_io_getattr("GEOM::mediasize", cp, &i, data, td);
257 error = g_io_getattr("GEOM::mediasize", cp, &i, data);
258 break;
259 case DIOCGFWSECTORS:
258 break;
259 case DIOCGFWSECTORS:
260 error = g_io_getattr("GEOM::fwsectors", cp, &i, data, td);
260 error = g_io_getattr("GEOM::fwsectors", cp, &i, data);
261 break;
262 case DIOCGFWHEADS:
261 break;
262 case DIOCGFWHEADS:
263 error = g_io_getattr("GEOM::fwheads", cp, &i, data, td);
263 error = g_io_getattr("GEOM::fwheads", cp, &i, data);
264 break;
265 case DIOCGFWCYLINDERS:
264 break;
265 case DIOCGFWCYLINDERS:
266 error = g_io_getattr("GEOM::fwcylinders", cp, &i, data, td);
266 error = g_io_getattr("GEOM::fwcylinders", cp, &i, data);
267 break;
268 default:
269 gio = g_malloc(sizeof *gio, M_WAITOK);
270 gio->cmd = cmd;
271 gio->data = data;
272 gio->fflag = fflag;
273 gio->td = td;
274 i = sizeof *gio;
275 if (cmd & IOC_IN)
267 break;
268 default:
269 gio = g_malloc(sizeof *gio, M_WAITOK);
270 gio->cmd = cmd;
271 gio->data = data;
272 gio->fflag = fflag;
273 gio->td = td;
274 i = sizeof *gio;
275 if (cmd & IOC_IN)
276 error = g_io_setattr("GEOM::ioctl", cp, i, gio, td);
276 error = g_io_setattr("GEOM::ioctl", cp, i, gio);
277 else
277 else
278 error = g_io_getattr("GEOM::ioctl", cp, &i, gio, td);
278 error = g_io_getattr("GEOM::ioctl", cp, &i, gio);
279 g_free(gio);
280 break;
281 }
282
283 if (error != 0 && cmd == DIOCGDVIRGIN) {
284 g_topology_lock();
285 gp = g_create_geomf("BSD-class", cp->provider, NULL);
286 g_topology_unlock();

--- 23 unchanged lines hidden (view full) ---

310{
311 struct g_consumer *cp;
312 int i, error;
313 off_t mediasize;
314
315 cp = dev->si_drv2;
316
317 i = sizeof mediasize;
279 g_free(gio);
280 break;
281 }
282
283 if (error != 0 && cmd == DIOCGDVIRGIN) {
284 g_topology_lock();
285 gp = g_create_geomf("BSD-class", cp->provider, NULL);
286 g_topology_unlock();

--- 23 unchanged lines hidden (view full) ---

310{
311 struct g_consumer *cp;
312 int i, error;
313 off_t mediasize;
314
315 cp = dev->si_drv2;
316
317 i = sizeof mediasize;
318 error = g_io_getattr("GEOM::mediasize", cp, &i, &mediasize, NULL);
318 error = g_io_getattr("GEOM::mediasize", cp, &i, &mediasize);
319 if (error)
320 return (-1);
321 return (mediasize >> DEV_BSHIFT);
322}
323
324static void
325g_dev_done(struct bio *bp2)
326{

--- 35 unchanged lines hidden (view full) ---

362 "g_dev_strategy(%p/%p) offset %lld length %lld data %p cmd %d",
363 bp, bp2, bp->bio_offset, bp2->bio_length, bp2->bio_data,
364 bp2->bio_cmd);
365 g_io_request(bp2, cp);
366}
367
368
369static void
319 if (error)
320 return (-1);
321 return (mediasize >> DEV_BSHIFT);
322}
323
324static void
325g_dev_done(struct bio *bp2)
326{

--- 35 unchanged lines hidden (view full) ---

362 "g_dev_strategy(%p/%p) offset %lld length %lld data %p cmd %d",
363 bp, bp2, bp->bio_offset, bp2->bio_length, bp2->bio_data,
364 bp2->bio_cmd);
365 g_io_request(bp2, cp);
366}
367
368
369static void
370g_dev_orphan(struct g_consumer *cp, struct thread *tp)
370g_dev_orphan(struct g_consumer *cp)
371{
372 struct g_geom *gp;
373 dev_t dev;
374
375 gp = cp->geom;
376 g_trace(G_T_TOPOLOGY, "g_dev_orphan(%p(%s))", cp, gp->name);
377 g_topology_assert();
378 if (cp->biocount > 0)

--- 12 unchanged lines hidden ---
371{
372 struct g_geom *gp;
373 dev_t dev;
374
375 gp = cp->geom;
376 g_trace(G_T_TOPOLOGY, "g_dev_orphan(%p(%s))", cp, gp->name);
377 g_topology_assert();
378 if (cp->biocount > 0)

--- 12 unchanged lines hidden ---