From dc230127daec112c1a3bb700232c22ac04631e88 Mon Sep 17 00:00:00 2001 From: sos Date: Mon, 7 Feb 2000 23:05:40 +0000 Subject: Do refcounting of open devices (more) correctly. count_dev funtion by phk. --- sys/dev/ata/atapi-tape.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'sys/dev/ata/atapi-tape.c') diff --git a/sys/dev/ata/atapi-tape.c b/sys/dev/ata/atapi-tape.c index 93e42e9..81953c2 100644 --- a/sys/dev/ata/atapi-tape.c +++ b/sys/dev/ata/atapi-tape.c @@ -240,7 +240,7 @@ astopen(dev_t dev, int32_t flags, int32_t fmt, struct proc *p) if (!stp) return ENXIO; - if (stp->flags == F_OPEN) + if (count_dev(dev) > 1) return EBUSY; atapi_test_ready(stp->atp); @@ -253,7 +253,6 @@ astopen(dev_t dev, int32_t flags, int32_t fmt, struct proc *p) stp->atp->flags &= ~ATAPI_F_MEDIA_CHANGED; stp->flags &= ~(F_DATA_WRITTEN | F_FM_WRITTEN); - stp->flags |= F_OPEN; ast_total = 0; return 0; } @@ -276,10 +275,10 @@ astclose(dev_t dev, int32_t flags, int32_t fmt, struct proc *p) if (!(minor(dev) & 0x01)) ast_rewind(stp); - if (stp->cap.lock) + if (stp->cap.lock && count_dev(dev) == 1) ast_prevent_allow(stp, 0); - stp->flags &= ~(F_OPEN | F_CTL_WARN); + stp->flags &= F_CTL_WARN; #ifdef AST_DEBUG printf("ast%d: %llu total bytes transferred\n", stp->lun, ast_total); #endif -- cgit v1.1