[224] in linux-scsi channel archive

home help back first fref pref prev next nref lref last post

Re: st driver open(O_WRONLY) of write-protected tape

daemon@ATHENA.MIT.EDU (Kai Makisara)
Sun Jun 4 03:54:34 1995

Date: Sun, 4 Jun 1995 10:29:56 +0300 (EET DST)
From: Kai Makisara <makisara@abies.metla.fi>
Reply-To: Kai.Makisara@metla.fi
To: "Brandon S. Allbery KF8NH" <bsa@kf8nh.wariat.org>
Cc: linux-scsi@vger.rutgers.edu
In-Reply-To: <199506040150.VAA00253@twit.kf8nh.wariat.org>

On Sat, 3 Jun 1995, Brandon S. Allbery KF8NH wrote:
...
> and got a write error "Permission denied" and an aborted backup instead of a 
> re-prompt for the device as GNU tar normally does.  This led me to look at 
> st.c, where I found that opening a write-protected tape actuallty opens the 
> tape read-only but causes writes to return -EPERM.
> 
> README.st makes no mention of this unexpected behavior.  Is it in fact 
> deliberate, and if so why?  I would much prefer not having to start over in 

The reason for this behavior is probably to prevent problems with the 
programs that open the device for read/write even if they don't always
need to write. I did not think about multivolume tars at that moment.

The quick patch at the end of this message changes the behaviour so that 
the tar problem disappears. Returning EPERM if a write-protected tape is 
opened O_WRONLY is certainly sensible but should we do that also for O_RDWR?

	Kai

*  Kai Makisara                      * email Kai.Makisara@metla.fi *
|  Finnish Forest Research Institute | tel. +358-0-857 05 334      |
|  Unioninkatu 40A                   | fax  +358-0-625 308         |
*  FIN-00170 Helsinki, Finland       *                             *
---------------------------------8<---------------------------------
--- st.c.9      Sun Jun  4 09:51:45 1995
+++ st.c        Sun Jun  4 10:07:35 1995
@@ -640,6 +640,12 @@
       if (debugging)
        printk( "st%d: Write protected\n", dev);
 #endif
+      if ((flags & O_ACCMODE) == O_WRONLY || (flags & O_ACCMODE) == O_RDWR) {
+       (STp->buffer)->in_use = 0;
+       STp->buffer = 0;
+       STp->in_use = 0;
+       return (-EPERM);
+      }
     }
 
     if (scsi_tapes[dev].device->host->hostt->usage_count)


home help back first fref pref prev next nref lref last post