您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ DISKUNIT函数代码示例

51自学网 2021-06-01 20:22:02
  C++
这篇教程C++ DISKUNIT函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中DISKUNIT函数的典型用法代码示例。如果您正苦于以下问题:C++ DISKUNIT函数的具体用法?C++ DISKUNIT怎么用?C++ DISKUNIT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了DISKUNIT函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ldsize

intldsize(dev_t dev){	struct ld_softc *sc;	int part, unit, omask, size;	unit = DISKUNIT(dev);	if ((sc = device_lookup(&ld_cd, unit)) == NULL)		return (ENODEV);	if ((sc->sc_flags & LDF_ENABLED) == 0)		return (ENODEV);	part = DISKPART(dev);	omask = sc->sc_dk.dk_openmask & (1 << part);	if (omask == 0 && ldopen(dev, 0, S_IFBLK, NULL) != 0)		return (-1);	else if (sc->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP)		size = -1;	else		size = sc->sc_dk.dk_label->d_partitions[part].p_size *		    (sc->sc_dk.dk_label->d_secsize / DEV_BSIZE);	if (omask == 0 && ldclose(dev, 0, S_IFBLK, NULL) != 0)		return (-1);	return (size);}
开发者ID:MarginC,项目名称:kame,代码行数:27,


示例2: vndclose

intvndclose(dev_t dev, int flags, int mode, struct proc *p){	int unit = DISKUNIT(dev);	struct vnd_softc *sc;	int part;	DNPRINTF(VDB_FOLLOW, "vndclose(%x, %x, %x, %p)/n", dev, flags, mode, p);	if (unit >= numvnd)		return (ENXIO);	sc = &vnd_softc[unit];	disk_lock_nointr(&sc->sc_dk);	part = DISKPART(dev);	disk_closepart(&sc->sc_dk, part, mode);#if 0	if (sc->sc_dk.dk_openmask == 0)		sc->sc_flags &= ~VNF_HAVELABEL;#endif	disk_unlock(&sc->sc_dk);	return (0);}
开发者ID:orumin,项目名称:openbsd-efivars,代码行数:27,


示例3: fd2biosinfo

static struct biosdisk_info *fd2biosinfo(struct proc *p, struct file *fp){	struct vnode *vp;	const char *blkname;	char diskname[16];	int i;	struct nativedisk_info *nip;	struct disklist *dl = x86_alldisks;	if (fp->f_type != DTYPE_VNODE)		return NULL;	vp = (struct vnode *)fp->f_data;	if (vp->v_type != VBLK)		return NULL;	blkname = devsw_blk2name(major(vp->v_rdev));	snprintf(diskname, sizeof diskname, "%s%llu", blkname,	    (unsigned long long)DISKUNIT(vp->v_rdev));	for (i = 0; i < dl->dl_nnativedisks; i++) {		nip = &dl->dl_nativedisks[i];		if (strcmp(diskname, nip->ni_devname))			continue;		if (nip->ni_nmatches != 0)			return &dl->dl_biosdisks[nip->ni_biosmatches[0]];	}	return NULL;}
开发者ID:goroutines,项目名称:rumprun,代码行数:31,


示例4: rdopen

intrdopen(dev_t dev, int flag, int fmt, struct proc *p){	struct rd_softc *sc;	u_int unit, part;	int error;	unit = DISKUNIT(dev);	part = DISKPART(dev);	sc = rdlookup(unit);	if (sc == NULL)		return (ENXIO);	if ((error = disk_lock(&sc->sc_dk)) != 0)		goto unref;	if (sc->sc_dk.dk_openmask == 0) {		/* Load the partition info if not already loaded. */		if ((error = rdgetdisklabel(dev, sc, sc->sc_dk.dk_label, 0))		    != 0)			goto unlock;	}	error = disk_openpart(&sc->sc_dk, part, fmt, 1); unlock:	disk_unlock(&sc->sc_dk); unref:	device_unref(&sc->sc_dev);	return (error);}
开发者ID:sofuture,项目名称:bitrig,代码行数:32,


示例5: cdminphys

voidcdminphys(struct buf *bp){	struct cd_softc *cd;	long max;	cd = cdlookup(DISKUNIT(bp->b_dev));	if (cd == NULL)		return;	/*	 * If the device is ancient, we want to make sure that	 * the transfer fits into a 6-byte cdb.	 *	 * XXX Note that the SCSI-I spec says that 256-block transfers	 * are allowed in a 6-byte read/write, and are specified	 * by setting the "length" to 0.  However, we're conservative	 * here, allowing only 255-block transfers in case an	 * ancient device gets confused by length == 0.  A length of 0	 * in a 10-byte read/write actually means 0 blocks.	 */	if (cd->flags & CDF_ANCIENT) {		max = cd->sc_dk.dk_label->d_secsize * 0xff;		if (bp->b_bcount > max)			bp->b_bcount = max;	}	(*cd->sc_link->adapter->scsi_minphys)(bp);	device_unref(&cd->sc_dev);}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:32,


示例6: wdsize

daddr_twdsize(dev_t dev){	struct wd_softc *wd;	struct disklabel *lp;	int part, omask;	daddr_t size;	WDCDEBUG_PRINT(("wdsize/n"), DEBUG_FUNCS);	wd = wdlookup(DISKUNIT(dev));	if (wd == NULL)		return (-1);	part = DISKPART(dev);	omask = wd->sc_dk.dk_openmask & (1 << part);	if (omask == 0 && wdopen(dev, 0, S_IFBLK, NULL) != 0) {		size = -1;		goto exit;	}	lp = wd->sc_dk.dk_label;	size = DL_SECTOBLK(lp, DL_GETPSIZE(&lp->d_partitions[part]));	if (omask == 0 && wdclose(dev, 0, S_IFBLK, NULL) != 0)		size = -1; exit:	device_unref(&wd->sc_dev);	return (size);}
开发者ID:DavidAlphaFox,项目名称:openbsd-kernel,代码行数:31,


示例7: prestoopen

intprestoopen(dev_t dev, int flag, int fmt, struct proc *proc){	int unit, part;	struct presto_softc *sc;	unit = DISKUNIT(dev);	sc = (struct presto_softc *)device_lookup(&presto_cd, unit);	if (sc == NULL)		return (ENXIO);	/* only allow valid partitions */	part = DISKPART(dev);	if (part != RAW_PART &&	    (part >= sc->sc_dk.dk_label->d_npartitions ||	    sc->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED))		return (ENXIO);	/* update open masks */	switch (fmt) {	case S_IFCHR:		sc->sc_dk.dk_copenmask |= (1 << part);		break;	case S_IFBLK:		sc->sc_dk.dk_bopenmask |= (1 << part);		break;	}	sc->sc_dk.dk_openmask = sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask;	return (0);}
开发者ID:avsm,项目名称:openbsd-xen-sys,代码行数:31,


示例8: get_hibernate_io_function

/* * Returns the hibernate write I/O function to use on this machine */hibio_fnget_hibernate_io_function(void){	char *blkname = findblkname(major(swdevt[0].sw_dev));	if (blkname == NULL)		return NULL;#if NWD > 0	if (strcmp(blkname, "wd") == 0) {		extern int wd_hibernate_io(dev_t dev, daddr_t blkno,		    vaddr_t addr, size_t size, int op, void *page);		return wd_hibernate_io;	}#endif#if NAHCI > 0 && NSD > 0	if (strcmp(blkname, "sd") == 0) {		extern struct cfdriver sd_cd;		extern int ahci_hibernate_io(dev_t dev, daddr_t blkno,		    vaddr_t addr, size_t size, int op, void *page);		struct device *dv;		dv = disk_lookup(&sd_cd, DISKUNIT(swdevt[0].sw_dev));		if (dv && dv->dv_parent && dv->dv_parent->dv_parent &&		    strcmp(dv->dv_parent->dv_parent->dv_cfdata->cf_driver->cd_name,		    "ahci") == 0)			return ahci_hibernate_io;	}#endif	return NULL;}
开发者ID:toddfries,项目名称:OpenBSD-sys-patches,代码行数:33,


示例9: wdclose

intwdclose(dev_t dev, int flag, int fmt, struct proc *p){	struct wd_softc *wd;	int part = DISKPART(dev);	wd = wdlookup(DISKUNIT(dev));	if (wd == NULL)		return ENXIO;	WDCDEBUG_PRINT(("wdclose/n"), DEBUG_FUNCS);	disk_lock_nointr(&wd->sc_dk);	disk_closepart(&wd->sc_dk, part, fmt);	if (wd->sc_dk.dk_openmask == 0) {		wd_flushcache(wd, 0);		/* XXXX Must wait for I/O to complete! */	}	disk_unlock(&wd->sc_dk);	device_unref(&wd->sc_dev);	return (0);}
开发者ID:DavidAlphaFox,项目名称:openbsd-kernel,代码行数:26,


示例10: ofdisk_size

intofdisk_size(dev_t dev){	struct ofdisk_softc *of;	struct disklabel *lp;	int size, part, omask;	of = device_lookup_private(&ofdisk_cd, DISKUNIT(dev));	if (of == NULL)		return ENXIO;	part = DISKPART(dev);	omask = of->sc_dk.dk_openmask & (1 << part);	lp = of->sc_dk.dk_label;	if (omask == 0 && ofdisk_open(dev, 0, S_IFBLK, curlwp) != 0)		return -1;	if (lp->d_partitions[part].p_fstype != FS_SWAP)		size = -1;	else		size = lp->d_partitions[part].p_size *		    (lp->d_secsize / DEV_BSIZE);	if (omask == 0 && ofdisk_close(dev, 0, S_IFBLK, curlwp) != 0)		return -1;	return size;}
开发者ID:ryoon,项目名称:netbsd-xhci,代码行数:29,


示例11: ldclose

/* ARGSUSED */intldclose(dev_t dev, int flags, int fmt, struct proc *p){	struct ld_softc *sc;	int part, unit;	unit = DISKUNIT(dev);	part = DISKPART(dev);	sc = device_lookup(&ld_cd, unit);	ldlock(sc);	switch (fmt) {	case S_IFCHR:		sc->sc_dk.dk_copenmask &= ~(1 << part);		break;	case S_IFBLK:		sc->sc_dk.dk_bopenmask &= ~(1 << part);		break;	}	sc->sc_dk.dk_openmask =	    sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask;	if (sc->sc_dk.dk_openmask == 0 && sc->sc_flush != NULL)		if ((*sc->sc_flush)(sc) != 0)			printf("%s: unable to flush cache/n",			    sc->sc_dv.dv_xname);	ldunlock(sc);	return (0);}
开发者ID:MarginC,项目名称:kame,代码行数:31,


示例12: ofdisk_close

intofdisk_close(dev_t dev, int flags, int fmt, struct lwp *l){	struct ofdisk_softc *of =		device_lookup_private(&ofdisk_cd, DISKUNIT(dev));	mutex_enter(&of->sc_dk.dk_openlock);	switch (fmt) {	case S_IFCHR:		of->sc_dk.dk_copenmask &= ~(1 << DISKPART(dev));		break;	case S_IFBLK:		of->sc_dk.dk_bopenmask &= ~(1 << DISKPART(dev));		break;	}	of->sc_dk.dk_openmask = of->sc_dk.dk_copenmask | of->sc_dk.dk_bopenmask;#ifdef	FIRMWORKSBUGS	/*	 * This is a hack to get the firmware to flush its buffers.	 */	OF_seek(of->sc_ihandle, 0);#endif	if (!of->sc_dk.dk_openmask) {		OF_close(of->sc_ihandle);		of->sc_ihandle = 0;	}	mutex_exit(&of->sc_dk.dk_openlock);	return 0;}
开发者ID:ryoon,项目名称:netbsd-xhci,代码行数:32,


示例13: rdioctl

intrdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p){	struct rd_softc *sc;	struct disklabel *lp;	int error = 0;	sc = rdlookup(DISKUNIT(dev));	if (sc == NULL)		return (ENXIO);	switch (cmd) {	case DIOCRLDINFO:		lp = malloc(sizeof(*lp), M_TEMP, M_WAITOK);		rdgetdisklabel(dev, sc, lp, 0);		bcopy(lp, sc->sc_dk.dk_label, sizeof(*lp));		free(lp, M_TEMP);		goto done;	case DIOCGPDINFO:		rdgetdisklabel(dev, sc, (struct disklabel *)data, 1);		goto done;	case DIOCGDINFO:		*(struct disklabel *)data = *(sc->sc_dk.dk_label);		goto done;	case DIOCGPART:		((struct partinfo *)data)->disklab = sc->sc_dk.dk_label;		((struct partinfo *)data)->part =		    &sc->sc_dk.dk_label->d_partitions[DISKPART(dev)];		goto done;	case DIOCWDINFO:	case DIOCSDINFO:		if ((fflag & FWRITE) == 0) {			error = EBADF;			goto done;		}		if ((error = disk_lock(&sc->sc_dk)) != 0)			goto done;		error = setdisklabel(sc->sc_dk.dk_label,		    (struct disklabel *)data, sc->sc_dk.dk_openmask);		if (error == 0) {			if (cmd == DIOCWDINFO)				error = writedisklabel(DISKLABELDEV(dev),				    rdstrategy, sc->sc_dk.dk_label);		}		disk_unlock(&sc->sc_dk);		goto done;	} done:	device_unref(&sc->sc_dev);	return (error);}
开发者ID:sofuture,项目名称:bitrig,代码行数:59,


示例14: readdisklabel

/* * Attempt to read a disk label from a device * using the indicated strategy routine. * The label must be partly set up before this: * secpercyl, secsize and anything required for a block i/o read * operation in the driver's strategy/start routines * must be filled in before calling us. * * If dos partition table requested, attempt to load it and * find disklabel inside a DOS partition. * * We would like to check if each MBR has a valid DOSMBR_SIGNATURE, but * we cannot because it doesn't always exist. So.. we assume the * MBR is valid. */intreaddisklabel(dev_t dev, void (*strat)(struct buf *),    struct disklabel *lp, int spoofonly){	bios_diskinfo_t *pdi;	struct buf *bp = NULL;	dev_t devno;	int error;	if ((error = initdisklabel(lp)))		goto done;	/* Look for any BIOS geometry information we should honour. */	devno = chrtoblk(dev);	if (devno == NODEV)		devno = dev;	pdi = bios_getdiskinfo(MAKEBOOTDEV(major(devno), 0, 0, DISKUNIT(devno),	    RAW_PART));	if (pdi != NULL && pdi->bios_heads > 0 && pdi->bios_sectors > 0) {#ifdef DEBUG		printf("Disk GEOM %u/%u/%u -> BIOS GEOM %u/%u/%u/n",		    lp->d_ntracks, lp->d_nsectors, lp->d_ncylinders,		    pdi->bios_heads, pdi->bios_sectors,		    DL_GETDSIZE(lp) / (pdi->bios_heads * pdi->bios_sectors));#endif		lp->d_ntracks = pdi->bios_heads;		lp->d_nsectors = pdi->bios_sectors;		lp->d_secpercyl = pdi->bios_sectors * pdi->bios_heads;		lp->d_ncylinders = DL_GETDSIZE(lp) / lp->d_secpercyl;	}	/* get a buffer and initialize it */	bp = geteblk((int)lp->d_secsize);	bp->b_dev = dev;	error = readdoslabel(bp, strat, lp, NULL, spoofonly);	if (error == 0)		goto done;#if defined(CD9660)	error = iso_disklabelspoof(dev, strat, lp);	if (error == 0)		goto done;#endif#if defined(UDF)	error = udf_disklabelspoof(dev, strat, lp);	if (error == 0)		goto done;#endifdone:	if (bp) {		bp->b_flags |= B_INVAL;		brelse(bp);	}	disk_change = 1;	return (error);}
开发者ID:bradla,项目名称:OpenBSD-Hammer2,代码行数:73,


示例15: rlopen

intrlopen(dev_t dev, int flag, int fmt, struct lwp *l){	struct rl_softc * const rc = device_lookup_private(&rl_cd, DISKUNIT(dev));	struct rlc_softc *sc;	int error, part, mask;	struct disklabel *dl;	const char *msg;	/*	 * Make sure this is a reasonable open request.	 */	if (rc == NULL)		return ENXIO;	sc = rc->rc_rlc;	part = DISKPART(dev);	mutex_enter(&rc->rc_disk.dk_openlock);	/*	 * If there are wedges, and this is not RAW_PART, then we	 * need to fail.	 */	if (rc->rc_disk.dk_nwedges != 0 && part != RAW_PART) {		error = EBUSY;		goto bad1;	}	/* Check that the disk actually is useable */	msg = rlstate(sc, rc->rc_hwid);	if (msg == NULL || msg == rlstates[RLMP_UNLOAD] ||	    msg == rlstates[RLMP_SPUNDOWN]) {		error = ENXIO;		goto bad1;	}	/*	 * If this is the first open; read in where on the disk we are.	 */	dl = rc->rc_disk.dk_label;	if (rc->rc_state == DK_CLOSED) {		u_int16_t mp;		int maj;		RL_WREG(RL_CS, RLCS_RHDR|(rc->rc_hwid << RLCS_USHFT));		waitcrdy(sc);		mp = RL_RREG(RL_MP);		rc->rc_head = ((mp & RLMP_HS) == RLMP_HS);		rc->rc_cyl = (mp >> 7) & 0777;		rc->rc_state = DK_OPEN;		/* Get disk label */		maj = cdevsw_lookup_major(&rl_cdevsw);		if ((msg = readdisklabel(MAKEDISKDEV(maj,		    device_unit(rc->rc_dev), RAW_PART), rlstrategy, dl, NULL)))			aprint_normal_dev(rc->rc_dev, "%s", msg);		aprint_normal_dev(rc->rc_dev, "size %d sectors/n",		    dl->d_secperunit);	}
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:57,


示例16: ofminphys

static voidofminphys(struct buf *bp){	struct ofdisk_softc *of =		device_lookup_private(&ofdisk_cd, DISKUNIT(bp->b_dev));	if (bp->b_bcount > of->max_transfer)		bp->b_bcount = of->max_transfer;}
开发者ID:ryoon,项目名称:netbsd-xhci,代码行数:9,


示例17: lddump

/* * Take a dump. */intlddump(dev_t dev, daddr_t blkno, caddr_t va, size_t size){	struct ld_softc *sc;	struct disklabel *lp;	int unit, part, nsects, sectoff, towrt, nblk, maxblkcnt, rv;	static int dumping;	unit = DISKUNIT(dev);	if ((sc = device_lookup(&ld_cd, unit)) == NULL)		return (ENXIO);	if ((sc->sc_flags & LDF_ENABLED) == 0)		return (ENODEV);	if (sc->sc_dump == NULL)		return (ENXIO);	/* Check if recursive dump; if so, punt. */	if (dumping)		return (EFAULT);	dumping = 1;	/* Convert to disk sectors.  Request must be a multiple of size. */	part = DISKPART(dev);	lp = sc->sc_dk.dk_label;	if ((size % lp->d_secsize) != 0)		return (EFAULT);	towrt = size / lp->d_secsize;	blkno = dbtob(blkno) / lp->d_secsize;	/* blkno in DEV_BSIZE units */	nsects = lp->d_partitions[part].p_size;	sectoff = lp->d_partitions[part].p_offset;	/* Check transfer bounds against partition size. */	if ((blkno < 0) || ((blkno + towrt) > nsects))		return (EINVAL);	/* Offset block number to start of partition. */	blkno += sectoff;	/* Start dumping and return when done. */	maxblkcnt = sc->sc_maxxfer / sc->sc_secsize - 1;	while (towrt > 0) {		nblk = min(maxblkcnt, towrt);		if ((rv = (*sc->sc_dump)(sc, va, blkno, nblk)) != 0)			return (rv);		towrt -= nblk;		blkno += nblk;		va += nblk * sc->sc_secsize;	}	dumping = 0;	return (0);}
开发者ID:MarginC,项目名称:kame,代码行数:58,


示例18: ldminphys

/* * Adjust the size of a transfer. */static voidldminphys(struct buf *bp){	struct ld_softc *sc;	sc = device_lookup(&ld_cd, DISKUNIT(bp->b_dev));	if (bp->b_bcount > sc->sc_maxxfer)		bp->b_bcount = sc->sc_maxxfer;	minphys(bp);}
开发者ID:MarginC,项目名称:kame,代码行数:14,


示例19: ldenddetach

voidldenddetach(struct ld_softc *sc){	struct buf *bp;	int s, bmaj, cmaj, mn;	if ((sc->sc_flags & LDF_ENABLED) == 0)		return;	/* Wait for commands queued with the hardware to complete. */	if (sc->sc_queuecnt != 0)		if (tsleep(&sc->sc_queuecnt, PRIBIO, "lddtch", 30 * hz))			printf("%s: not drained/n", sc->sc_dv.dv_xname);	/* Locate the major numbers. */	for (bmaj = 0; bmaj <= nblkdev; bmaj++)		if (bdevsw[bmaj].d_open == ldopen)			break;	for (cmaj = 0; cmaj <= nchrdev; cmaj++)		if (cdevsw[cmaj].d_open == ldopen)			break;	/* Kill off any queued buffers. */	s = splbio();	while ((bp = BUFQ_FIRST(&sc->sc_bufq)) != NULL) {		BUFQ_REMOVE(&sc->sc_bufq, bp);		bp->b_error = EIO;		bp->b_flags |= B_ERROR;		bp->b_resid = bp->b_bcount;		biodone(bp);	}	splx(s);	/* Nuke the vnodes for any open instances. */	mn = DISKUNIT(sc->sc_dv.dv_unit);	vdevgone(bmaj, mn, mn + (MAXPARTITIONS - 1), VBLK);	vdevgone(cmaj, mn, mn + (MAXPARTITIONS - 1), VCHR);		/* Detach from the disk list. */	disk_detach(&sc->sc_dk);#if NRND > 0	/* Unhook the entropy source. */	rnd_detach_source(&sc->sc_rnd_source);#endif	/* Flush the device's cache. */	if (sc->sc_flush != NULL)		if ((*sc->sc_flush)(sc) != 0)			printf("%s: unable to flush cache/n",			    sc->sc_dv.dv_xname);}
开发者ID:MarginC,项目名称:kame,代码行数:52,


示例20: sdclose

/* * Close the device. Only called if we are the last occurrence of an open * device.  Convenient now but usually a pain. */intsdclose(dev_t dev, int flag, int fmt, struct proc *p){    struct sd_softc *sc;    int part = DISKPART(dev);    int error;    sc = sdlookup(DISKUNIT(dev));    if (sc == NULL)        return (ENXIO);    if (sc->flags & SDF_DYING) {        device_unref(&sc->sc_dev);        return (ENXIO);    }    if ((error = sdlock(sc)) != 0) {        device_unref(&sc->sc_dev);        return (error);    }    switch (fmt) {    case S_IFCHR:        sc->sc_dk.dk_copenmask &= ~(1 << part);        break;    case S_IFBLK:        sc->sc_dk.dk_bopenmask &= ~(1 << part);        break;    }    sc->sc_dk.dk_openmask = sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask;    if (sc->sc_dk.dk_openmask == 0) {        if ((sc->flags & SDF_DIRTY) != 0)            sd_flush(sc, 0);        if ((sc->sc_link->flags & SDEV_REMOVABLE) != 0)            scsi_prevent(sc->sc_link, PR_ALLOW,                         SCSI_IGNORE_ILLEGAL_REQUEST |                         SCSI_IGNORE_NOT_READY | SCSI_SILENT);        sc->sc_link->flags &= ~(SDEV_OPEN | SDEV_MEDIA_LOADED);        if (sc->sc_link->flags & SDEV_EJECTING) {            scsi_start(sc->sc_link, SSS_STOP|SSS_LOEJ, 0);            sc->sc_link->flags &= ~SDEV_EJECTING;        }        timeout_del(&sc->sc_timeout);    }    sdunlock(sc);    device_unref(&sc->sc_dev);    return 0;}
开发者ID:7shi,项目名称:openbsd-loongson-vc,代码行数:56,


示例21: ofdisk_strategy

voidofdisk_strategy(struct buf *bp){	struct ofdisk_softc *of =		device_lookup_private(&ofdisk_cd, DISKUNIT(bp->b_dev));	struct partition *p;	u_quad_t off;	int read;	int (*OF_io)(int, void *, int);	daddr_t blkno = bp->b_blkno;	bp->b_resid = 0;	if (bp->b_bcount == 0)		goto done;	OF_io = bp->b_flags & B_READ ? OF_read : 		(int(*)(int, void*, int))OF_write;	if (DISKPART(bp->b_dev) != RAW_PART) {		if (bounds_check_with_label(&of->sc_dk, bp, 0) <= 0) {			bp->b_resid = bp->b_bcount;			goto done;		}		p = &of->sc_dk.dk_label->d_partitions[DISKPART(bp->b_dev)];		blkno = bp->b_blkno + p->p_offset;	}	disk_busy(&of->sc_dk);	off = (u_quad_t)blkno * DEV_BSIZE;	read = -1;	do {		if (OF_seek(of->sc_ihandle, off) < 0)			break;		read = OF_io(of->sc_ihandle, bp->b_data, bp->b_bcount);	} while (read == -2);	if (read < 0) {		bp->b_error = EIO;		bp->b_resid = bp->b_bcount;	} else		bp->b_resid = bp->b_bcount - read;	disk_unbusy(&of->sc_dk, bp->b_bcount - bp->b_resid,	    (bp->b_flags & B_READ));done:	biodone(bp);}
开发者ID:ryoon,项目名称:netbsd-xhci,代码行数:49,


示例22: wdstrategy

/* * Read/write routine for a buffer.  Validates the arguments and schedules the * transfer.  Does not wait for the transfer to complete. */voidwdstrategy(struct buf *bp){	struct wd_softc *wd;	int s;	wd = wdlookup(DISKUNIT(bp->b_dev));	if (wd == NULL) {		bp->b_error = ENXIO;		goto bad;	}	WDCDEBUG_PRINT(("wdstrategy (%s)/n", wd->sc_dev.dv_xname),	    DEBUG_XFERS);	/* If device invalidated (e.g. media change, door open), error. */	if ((wd->sc_flags & WDF_LOADED) == 0) {		bp->b_error = EIO;		goto bad;	}	/* Validate the request. */	if (bounds_check_with_label(bp, wd->sc_dk.dk_label) == -1)		goto done;	/* Check that the number of sectors can fit in a byte. */	if ((bp->b_bcount / wd->sc_dk.dk_label->d_secsize) >= (1 << NBBY)) {		bp->b_error = EINVAL;		goto bad;	}	/* Queue transfer on drive, activate drive and controller if idle. */	bufq_queue(&wd->sc_bufq, bp);	s = splbio();	wdstart(wd);	splx(s);	device_unref(&wd->sc_dev);	return; bad:	bp->b_flags |= B_ERROR;	bp->b_resid = bp->b_bcount; done:	s = splbio();	biodone(bp);	splx(s);	if (wd != NULL)		device_unref(&wd->sc_dev);}
开发者ID:DavidAlphaFox,项目名称:openbsd-kernel,代码行数:53,


示例23: rdstrategy

voidrdstrategy(struct buf *bp){	struct rd_softc *sc;	struct partition *p;	size_t off, xfer;	caddr_t addr;	int s;	sc = rdlookup(DISKUNIT(bp->b_dev));	if (sc == NULL) {		bp->b_error = ENXIO;		goto bad;	}	/* Validate the request. */	if (bounds_check_with_label(bp, sc->sc_dk.dk_label) == -1)		goto done;	/* Do the transfer. */	/* XXX: Worry about overflow when computing off? */	p = &sc->sc_dk.dk_label->d_partitions[DISKPART(bp->b_dev)];	off = DL_GETPOFFSET(p) * sc->sc_dk.dk_label->d_secsize +	    (u_int64_t)bp->b_blkno * DEV_BSIZE;	if (off > rd_root_size)		off = rd_root_size;	xfer = bp->b_bcount;	if (xfer > rd_root_size - off)		xfer = rd_root_size - off;	addr = rd_root_image + off;	if (bp->b_flags & B_READ)		memcpy(bp->b_data, addr, xfer);	else		memcpy(addr, bp->b_data, xfer);	bp->b_resid = bp->b_bcount - xfer;	goto done; bad:	bp->b_flags |= B_ERROR;	bp->b_resid = bp->b_bcount; done:	s = splbio();	biodone(bp);	splx(s);	if (sc != NULL)		device_unref(&sc->sc_dev);}
开发者ID:sofuture,项目名称:bitrig,代码行数:48,


示例24: cdclose

/* * Close the device. Only called if we are the last occurrence of an open * device. */intcdclose(dev_t dev, int flag, int fmt, struct proc *p){	struct cd_softc *cd;	int part = DISKPART(dev);	int error;	cd = cdlookup(DISKUNIT(dev));	if (cd == NULL)		return ENXIO;	if ((error = cdlock(cd)) != 0) {		device_unref(&cd->sc_dev);		return error;	}	switch (fmt) {	case S_IFCHR:		cd->sc_dk.dk_copenmask &= ~(1 << part);		break;	case S_IFBLK:		cd->sc_dk.dk_bopenmask &= ~(1 << part);		break;	}	cd->sc_dk.dk_openmask = cd->sc_dk.dk_copenmask | cd->sc_dk.dk_bopenmask;	if (cd->sc_dk.dk_openmask == 0) {		/* XXXX Must wait for I/O to complete! */		scsi_prevent(cd->sc_link, PR_ALLOW,		    SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY |		    SCSI_SILENT);		cd->sc_link->flags &= ~(SDEV_OPEN | SDEV_MEDIA_LOADED);		if (cd->sc_link->flags & SDEV_EJECTING) {			scsi_start(cd->sc_link, SSS_STOP|SSS_LOEJ, 0);			cd->sc_link->flags &= ~SDEV_EJECTING;		}		timeout_del(&cd->sc_timeout);	}	cdunlock(cd);	device_unref(&cd->sc_dev);	return 0;}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:52,


示例25: prestostrategy

voidprestostrategy(struct buf *bp){	int unit, part;	struct presto_softc *sc;	size_t offset, count;	int s;	unit = DISKUNIT(bp->b_dev);	sc = (struct presto_softc *)device_lookup(&presto_cd, unit);	/* Sort rogue requests out */	if (sc == NULL || bp->b_blkno < 0 ||	    (bp->b_bcount % sc->sc_dk.dk_label->d_secsize) != 0) {		bp->b_error = EINVAL;		goto bad;	}	/* Do not write on "no trespassing" areas... */	part = DISKPART(bp->b_dev);	if (part != RAW_PART &&	    bounds_check_with_label(bp, sc->sc_dk.dk_label,	    sc->sc_dk.dk_cpulabel, 1) <= 0)		goto bad;	/* Bound the request size, then move data between buf and nvram */	bp->b_resid = bp->b_bcount;	offset = (bp->b_blkno << DEV_BSHIFT) + PSERVE_OFFSET;	count = bp->b_bcount;	if (count > (sc->sc_memsize - offset))		count = (sc->sc_memsize - offset);	if (ISSET(bp->b_flags, B_READ))		bcopy(sc->sc_mem + offset, bp->b_data, count);	else		bcopy(bp->b_data, sc->sc_mem + offset, count);	bp->b_resid -= count;	goto done;bad:	bp->b_flags |= B_ERROR;	bp->b_resid = bp->b_bcount;done:	s = splbio();	biodone(bp);	splx(s);}
开发者ID:avsm,项目名称:openbsd-xen-sys,代码行数:47,



注:本文中的DISKUNIT函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ DISPATCHEX函数代码示例
C++ DISKPART函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。