home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!unixhub!fnnews.fnal.gov!dcdmwm.fnal.gov!mengel
- From: mengel@dcdmwm.fnal.gov (Marc Mengel)
- Newsgroups: comp.unix.aix
- Subject: Re: Checking for write protect on 8mm tapes.
- Date: 17 Dec 1992 15:50:42 GMT
- Organization: Fermi National Accelerator Laboratory, Batavia IL
- Lines: 62
- Distribution: world
- Message-ID: <1gq7kiINNdc7@fnnews.fnal.gov>
- References: <707@dwp.la.ca.us>
- NNTP-Posting-Host: dcdmwm.fnal.gov
-
- In article <707@dwp.la.ca.us>, carlson@dwp.la.ca.us (CarlsonPeters 7898) writes:
- |>
- |> Is there anyway to check to see if the write protect tab is set on an
- |> 8mm tape via software without actually trying to write to the tape? I
- |> am writing a front-end for tar/tctl and it would be really nice to
- |> disable the backup menu if the write-protect tab is on. Checking by
- |> writing to tape is not an option.
-
- The only good way is to use the scsi pass-through ioctl() calls, and you
- have to be root and open the device in diagnostics mode(!!).
- The code looks like this:
-
- do_status(char *pcTape)
- {
- int i;
- int nTapeDiag;
- static char buf[SIZE];
- static struct sc_iocmd scInquiry = {
- 0x38, buf, 5, 0, 0, 0, 0, 0, 0, 0, B_READ, 0, 0, 0,
- 6, { 0x12, 0, 0, 0, 0x38, 0 }
- };
- static struct sc_iocmd scMode = {
- 80, buf, 5, 0, 0, 0, 0, 0, 0, 0, B_READ, 0, 0, 0,
- 6, { 0x1a, 0, 0, 0, 80, }
- };
-
-
- if (debug)
- fprintf(stderr,"do_status\n");
-
- if (0 > (nTapeDiag = openx(pcTape,O_RDONLY,0,SC_DIAGNOSTIC))) {
- perror("openx\n");
- return 1;
- }
- printf("Drive %s", pcTape);
- if (0 > ioctl(nTapeDiag,STIOCMD,&scMode) &&
- 0 > ioctl(nTapeDiag,STIOCMD,&scMode)) {
- perror("ioctl IOCMD {1a, 0, 0, 0, 0xff, 0}");
- return 1;
- }
- if (buf[1] == 0) {
- printf(" is off line");
- } else {
- printf(" is on line");
-
- if (buf[2]&0x80)
- printf(", write-protected");
- else
- printf(", read/write");
- printf("\n");
- }
- close(nTapeDiag);
- printf("\n");
- return 0;
- }
-
- There's lots of other good status bits in there you can check; look in
- the EXABYTE manual for details on the hex 1A Mode Sense command.
-
- -------
- Marc Mengel
- mengel@fnal.fnal.gov
-