static void g_mbr_ioctl(void *arg) { struct bio *bp; struct g_geom *gp; struct g_slicer *gsp; struct g_mbr_softc *ms; struct g_ioctl *gio; struct g_consumer *cp; u_char *sec0; int error; /* Get hold of the interesting bits from the bio. */ bp = arg; gp = bp->bio_to->geom; gsp = gp->softc; ms = gsp->softc; gio = (struct g_ioctl *)bp->bio_data; /* The disklabel to set is the ioctl argument. */ sec0 = gio->data; error = g_mbr_modify(gp, ms, sec0); if (error) { g_io_deliver(bp, error); return; } cp = LIST_FIRST(&gp->consumer); error = g_write_data(cp, 0, sec0, 512); g_io_deliver(bp, error); }
static int g_mbr_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread *td) { struct g_geom *gp; struct g_mbr_softc *ms; struct g_slicer *gsp; struct g_consumer *cp; int error, opened; gp = pp->geom; gsp = gp->softc; ms = gsp->softc; opened = 0; error = 0; switch(cmd) { case DIOCSMBR: { if (!(fflag & FWRITE)) return (EPERM); DROP_GIANT(); g_topology_lock(); cp = LIST_FIRST(&gp->consumer); if (cp->acw == 0) { error = g_access(cp, 0, 1, 0); if (error == 0) opened = 1; } if (!error) error = g_mbr_modify(gp, ms, data, 512); if (!error) error = g_write_data(cp, 0, data, 512); if (opened) g_access(cp, 0, -1 , 0); g_topology_unlock(); PICKUP_GIANT(); return(error); } default: return (ENOIOCTL); } }