Deleted Added
full compact
geom_dev.c (119593) geom_dev.c (119660)
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

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

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
36#include <sys/cdefs.h>
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

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

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
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/sys/geom/geom_dev.c 119593 2003-08-30 18:33:55Z phk $");
37__FBSDID("$FreeBSD: head/sys/geom/geom_dev.c 119660 2003-09-01 20:45:32Z phk $");
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/malloc.h>
42#include <sys/kernel.h>
43#include <sys/conf.h>
44#include <sys/bio.h>
45#include <sys/lock.h>

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

274static int
275g_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
276{
277 struct g_geom *gp;
278 struct g_consumer *cp;
279 struct g_kerneldump kd;
280 int i, error;
281 u_int u;
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/malloc.h>
42#include <sys/kernel.h>
43#include <sys/conf.h>
44#include <sys/bio.h>
45#include <sys/lock.h>

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

274static int
275g_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
276{
277 struct g_geom *gp;
278 struct g_consumer *cp;
279 struct g_kerneldump kd;
280 int i, error;
281 u_int u;
282 struct g_ioctl *gio;
283
284 gp = dev->si_drv1;
285 cp = dev->si_drv2;
282
283 gp = dev->si_drv1;
284 cp = dev->si_drv2;
286 gio = NULL;
287
288 error = 0;
289 KASSERT(cp->acr || cp->acw,
290 ("Consumer with zero access count in g_dev_ioctl"));
291
285
286 error = 0;
287 KASSERT(cp->acr || cp->acw,
288 ("Consumer with zero access count in g_dev_ioctl"));
289
292 gio = NULL;
293 i = IOCPARM_LEN(cmd);
294 switch (cmd) {
295 case DIOCGSECTORSIZE:
296 *(u_int *)data = cp->provider->sectorsize;
297 if (*(u_int *)data == 0)
298 error = ENOENT;
299 break;
300 case DIOCGMEDIASIZE:

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

326 kd.length = OFF_MAX;
327 i = sizeof kd;
328 error = g_io_getattr("GEOM::kerneldump", cp, &i, &kd);
329 if (!error)
330 dev->si_flags |= SI_DUMPDEV;
331 break;
332
333 default:
290 i = IOCPARM_LEN(cmd);
291 switch (cmd) {
292 case DIOCGSECTORSIZE:
293 *(u_int *)data = cp->provider->sectorsize;
294 if (*(u_int *)data == 0)
295 error = ENOENT;
296 break;
297 case DIOCGMEDIASIZE:

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

323 kd.length = OFF_MAX;
324 i = sizeof kd;
325 error = g_io_getattr("GEOM::kerneldump", cp, &i, &kd);
326 if (!error)
327 dev->si_flags |= SI_DUMPDEV;
328 break;
329
330 default:
334 gio = g_malloc(sizeof *gio, M_WAITOK | M_ZERO);
335 gio->cmd = cmd;
336 gio->data = data;
337 gio->fflag = fflag;
338 gio->td = td;
339 i = sizeof *gio;
340 /*
341 * We always issue ioctls as getattr since the direction of data
342 * movement in ioctl is no indication of the ioctl being a "set"
343 * or "get" type ioctl or if such simplistic terms even apply
344 */
345 error = g_io_getattr("GEOM::ioctl", cp, &i, gio);
346 break;
331 if (cp->provider->geom->ioctl != NULL) {
332 error = cp->provider->geom->ioctl(cp->provider, cmd, data, td);
333 if (error != ENOIOCTL)
334 return (error);
335 }
347 }
348
336 }
337
349 if (error == EDIRIOCTL) {
350 KASSERT(gio != NULL, ("NULL gio but EDIRIOCTL"));
351 KASSERT(gio->func != NULL, ("NULL function but EDIRIOCTL"));
352 error = (gio->func)(gio->dev, cmd, data, fflag, td);
353 }
354 g_waitidle();
338 g_waitidle();
355 if (gio != NULL && (error == EOPNOTSUPP || error == ENOIOCTL)) {
356 if (g_debugflags & G_T_TOPOLOGY) {
357 i = IOCGROUP(cmd);
358 printf("IOCTL(0x%lx) \"%s\"", cmd, gp->name);
359 if (i > ' ' && i <= '~')
360 printf(" '%c'", (int)IOCGROUP(cmd));
361 else
362 printf(" 0x%lx", IOCGROUP(cmd));
363 printf("/%ld ", cmd & 0xff);
364 if (cmd & IOC_IN)
365 printf("I");
366 if (cmd & IOC_OUT)
367 printf("O");
368 printf("(%ld) = ENOIOCTL\n", IOCPARM_LEN(cmd));
369 }
370 error = ENOTTY;
371 }
372 if (gio != NULL)
373 g_free(gio);
374 return (error);
375}
376
377static void
378g_dev_done(struct bio *bp2)
379{
380 struct bio *bp;
381

--- 102 unchanged lines hidden ---
339 return (error);
340}
341
342static void
343g_dev_done(struct bio *bp2)
344{
345 struct bio *bp;
346

--- 102 unchanged lines hidden ---