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 105551 2002-10-20 20:28:24Z phk $
36 */
37
38#include "opt_geom.h"
39#ifndef NO_GEOM
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/kernel.h>
--- 40 unchanged lines hidden (view full) ---
84 dp = pp->geom->softc;
85 dev = dp->d_dev;
86 if ((pp->acr + pp->acw + pp->ace) == 0 && (r + w + e) > 0) {
87 mtx_lock(&Giant);
88 error = devsw(dev)->d_open(dev, 3, 0, NULL);
89 if (error != 0)
90 printf("Opened disk %s -> %d\n", pp->name, error);
91 mtx_unlock(&Giant);
92 pp->mediasize = dp->d_mediasize;
93 pp->sectorsize = dp->d_sectorsize;
94 } else if ((pp->acr + pp->acw + pp->ace) > 0 && (r + w + e) == 0) {
95 mtx_lock(&Giant);
96 error = devsw(dev)->d_close(dev, 3, 0, NULL);
97 if (error != 0)
98 printf("Closed disk %s -> %d\n", pp->name, error);
99 mtx_unlock(&Giant);
100 } else {
101 error = 0;
102 }
103 return (error);
104}
105
106static void
107g_disk_kerneldump(struct bio *bp, struct disk *dp)
108{
109 int error;
110 struct g_kerneldump *gkd;
--- 50 unchanged lines hidden (view full) ---
161 bp2->bio_pblkno = bp2->bio_offset / dp->d_sectorsize;
162 bp2->bio_bcount = bp2->bio_length;
163 bp2->bio_dev = dev;
164 mtx_lock(&Giant);
165 devsw(dev)->d_strategy(bp2);
166 mtx_unlock(&Giant);
167 break;
168 case BIO_GETATTR:
169 if (g_handleattr_int(bp, "GEOM::fwsectors", dp->d_fwsectors))
170 break;
171 else if (g_handleattr_int(bp, "GEOM::fwheads", dp->d_fwheads))
172 break;
173 else if (g_handleattr_off_t(bp, "GEOM::frontstuff", 0))
174 break;
175 else if (!strcmp(bp->bio_attribute, "GEOM::kerneldump"))
176 g_disk_kerneldump(bp, dp);
177 else if (!strcmp(bp->bio_attribute, "GEOM::ioctl") &&
178 bp->bio_length == sizeof *gio) {
179 gio = (struct g_ioctl *)bp->bio_data;
180 gio->func = devsw(dp->d_dev)->d_ioctl;
--- 46 unchanged lines hidden (view full) ---
227 dev = arg;
228 gp = g_new_geomf(&g_disk_class, dev->si_name);
229 gp->start = g_disk_start;
230 gp->access = g_disk_access;
231 gp->softc = dev->si_disk;
232 gp->dumpconf = g_disk_dumpconf;
233 dev->si_disk->d_softc = gp;
234 pp = g_new_providerf(gp, "%s", gp->name);
235 pp->mediasize = dev->si_disk->d_mediasize;
236 pp->sectorsize = dev->si_disk->d_sectorsize;
237 g_error_provider(pp, 0);
238}
239
240
241
242dev_t
243disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw, struct cdevsw *proto)
244{
--- 79 unchanged lines hidden ---
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 105551 2002-10-20 20:28:24Z phk $
36 */
37
38#include "opt_geom.h"
39#ifndef NO_GEOM
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/kernel.h>
--- 40 unchanged lines hidden (view full) ---
84 dp = pp->geom->softc;
85 dev = dp->d_dev;
86 if ((pp->acr + pp->acw + pp->ace) == 0 && (r + w + e) > 0) {
87 mtx_lock(&Giant);
88 error = devsw(dev)->d_open(dev, 3, 0, NULL);
89 if (error != 0)
90 printf("Opened disk %s -> %d\n", pp->name, error);
91 mtx_unlock(&Giant);
92 pp->mediasize = dp->d_mediasize;
93 pp->sectorsize = dp->d_sectorsize;
94 } else if ((pp->acr + pp->acw + pp->ace) > 0 && (r + w + e) == 0) {
95 mtx_lock(&Giant);
96 error = devsw(dev)->d_close(dev, 3, 0, NULL);
97 if (error != 0)
98 printf("Closed disk %s -> %d\n", pp->name, error);
99 mtx_unlock(&Giant);
100 } else {
101 error = 0;
102 }
103 return (error);
104}
105
106static void
107g_disk_kerneldump(struct bio *bp, struct disk *dp)
108{
109 int error;
110 struct g_kerneldump *gkd;
--- 50 unchanged lines hidden (view full) ---
161 bp2->bio_pblkno = bp2->bio_offset / dp->d_sectorsize;
162 bp2->bio_bcount = bp2->bio_length;
163 bp2->bio_dev = dev;
164 mtx_lock(&Giant);
165 devsw(dev)->d_strategy(bp2);
166 mtx_unlock(&Giant);
167 break;
168 case BIO_GETATTR:
169 if (g_handleattr_int(bp, "GEOM::fwsectors", dp->d_fwsectors))
170 break;
171 else if (g_handleattr_int(bp, "GEOM::fwheads", dp->d_fwheads))
172 break;
173 else if (g_handleattr_off_t(bp, "GEOM::frontstuff", 0))
174 break;
175 else if (!strcmp(bp->bio_attribute, "GEOM::kerneldump"))
176 g_disk_kerneldump(bp, dp);
177 else if (!strcmp(bp->bio_attribute, "GEOM::ioctl") &&
178 bp->bio_length == sizeof *gio) {
179 gio = (struct g_ioctl *)bp->bio_data;
180 gio->func = devsw(dp->d_dev)->d_ioctl;
--- 46 unchanged lines hidden (view full) ---
227 dev = arg;
228 gp = g_new_geomf(&g_disk_class, dev->si_name);
229 gp->start = g_disk_start;
230 gp->access = g_disk_access;
231 gp->softc = dev->si_disk;
232 gp->dumpconf = g_disk_dumpconf;
233 dev->si_disk->d_softc = gp;
234 pp = g_new_providerf(gp, "%s", gp->name);
235 pp->mediasize = dev->si_disk->d_mediasize;
236 pp->sectorsize = dev->si_disk->d_sectorsize;
237 g_error_provider(pp, 0);
238}
239
240
241
242dev_t
243disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw, struct cdevsw *proto)
244{
--- 79 unchanged lines hidden ---