Esempio n. 1
0
static int 
astclose(dev_t dev, int flags, int fmt, struct proc *p)
{
    struct ast_softc *stp = dev->si_drv1;

    /* flush buffers, some drives fail here, they should report ctl = 0 */
    if (stp->cap.ctl && (stp->flags & F_DATA_WRITTEN))
	ast_write_filemark(stp, 0);

    /* write filemark if data written to tape */
    if (!(stp->flags & F_ONSTREAM) &&
	(stp->flags & (F_DATA_WRITTEN | F_FM_WRITTEN)) == F_DATA_WRITTEN)
	ast_write_filemark(stp, WF_WRITE);

    /* if minor is even rewind on close */
    if (!(minor(dev) & 0x01))
	ast_rewind(stp);

    if (stp->cap.lock && count_dev(dev) == 1)
	ast_prevent_allow(stp, 0);

    stp->flags &= F_CTL_WARN;
#ifdef AST_DEBUG
    ata_prtdev(stp->device, "%llu total bytes transferred\n", ast_total);
#endif
    return 0;
}
Esempio n. 2
0
static int 
afd_close(struct dev_close_args *ap)
{
    device_t dev = ap->a_head.a_dev->si_drv1;
    struct afd_softc *fdp = device_get_ivars(dev);

    if (count_dev(fdp->cdev) == 1)
	afd_prevent_allow(dev, 0); 
    return 0;
}
Esempio n. 3
0
static int
astopen(dev_t dev, int flags, int fmt, struct proc *p)
{
    struct ast_softc *stp = dev->si_drv1;

    if (!stp)
	return ENXIO;

    if (count_dev(dev) > 1)
	return EBUSY;

    atapi_test_ready(stp->device);

    if (stp->cap.lock)
	ast_prevent_allow(stp, 1);

    if (ast_sense(stp))
	ata_prtdev(stp->device, "sense media type failed\n");

    stp->device->flags &= ~ATA_D_MEDIA_CHANGED;
    stp->flags &= ~(F_DATA_WRITTEN | F_FM_WRITTEN);
    ast_total = 0;
    return 0;
}