SunOS 4.0.3 SCSI tape close error: EPERM

Tom Poage poage at sunny.ucdavis.edu
Thu Aug 3 04:21:56 AEST 1989


Has anyone running SunOS 4.0.3 observed that closing a 1/4"
SCSI tape after read/write returns EPERM?  This happens on
a 3/150 with /dev/rst[08].  It may have happened under
4.0.1 too, but I don't specifically remember.

If you're root or you own the device, no problem.  If you
don't write or read the tape, no error.

Is this a known problem?  Any fixes/work-arounds?

Repeat with the following program and a scratch tape.

Tom.
==============================================================

/*
 * Write and read a dummy block on /dev/rst8 (SCSI tape).
 *
 * If you do not own the tape device (or not root)
 * you will get an EPERM error on calling close().
 * You won't get the error unless you call read()
 * or write().  Sun 3/150, SunOS 4.0.3.
 *
 * Tom Poage (poage at sunny.ucdavis.edu)
 */
#include <fcntl.h>
#include <errno.h>
main()
{
	int fd;
	char buf[512];	/* Tape read/write has to be modulo-512. */
	if ((fd = open("/dev/rst8", O_WRONLY)) < 0) {
		perror("tape open #1"); return(1);
	}
	if (write(fd, buf, sizeof buf) < 0) {
		perror("write to tape"); return(1);
	}
	if (close(fd) < 0) {	/* Fails here. */
		perror("tape close #1");
	}
	/* rst8 rewinds on close. */
	if ((fd = open("/dev/rst8", O_RDONLY)) < 0) {
		perror("tape open #2"); return(1);
	}
	if (read(fd, buf, sizeof buf) != sizeof buf) {
		perror("read from tape");
	}
	if (close(fd) < 0) {	/* Fails here, too. */
		perror("tape close #2");
	}
	return(0);
}
-- 
Tom Poage, Clinical Engineering
Universiy of California, Davis, Medical Center, Sacramento, CA
poage at sunny.ucdavis.edu  {...,ucbvax,uunet}!ucdavis!sunny!poage



More information about the Comp.unix.questions mailing list