Commit c1f63ffc authored by Kai Mäkisara's avatar Kai Mäkisara Committed by James Bottomley

[PATCH] SCSI tape: write filemark before rewind etc. when writing

The patch at the end of this message modifies the st write semantics in
the following way: write a filemark before rewind, offline, or seek if the
previous operation was write.

This semantics is specified on the man pages of some Unices and some
software (e.g., cpio) seems to assume this. The change makes sure that the
last file on the tape is properly terminated with a filemark and reading the
file does not fail at the end.
Signed-off-by: default avatarKai Makisara <kai.makisara@kolumbus.fi>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 9b21fa11
......@@ -2,7 +2,7 @@ This file contains brief information about the SCSI tape driver.
The driver is currently maintained by Kai Mäkisara (email
Kai.Makisara@kolumbus.fi)
Last modified: Wed Feb 25 14:09:08 2004 by makisara
Last modified: Sun Feb 20 22:28:27 2005 by kai.makisara
BASICS
......@@ -85,6 +85,9 @@ writing and the last operation has been a write. Two filemarks can be
optionally written. In both cases end of data is signified by
returning zero bytes for two consecutive reads.
If the rewind, offline, or seek is done and previous tape operation was write,
a filemark is written before moving tape.
The compile options are defined in the file linux/drivers/scsi/st_options.h.
4. If the open option O_NONBLOCK is used, open succeeds even if the
......
......@@ -2727,6 +2727,8 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
else if (chg_eof)
STps->eof = ST_NOEOF;
if (cmd_in == MTWEOF)
STps->rw = ST_IDLE;
} else { /* SCSI command was not completely successful. Don't return
from this block without releasing the SCSI command block! */
struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat;
......@@ -3235,6 +3237,17 @@ static int st_ioctl(struct inode *inode, struct file *file,
retval = i;
goto out;
}
if (STps->rw == ST_WRITING &&
(mtc.mt_op == MTREW || mtc.mt_op == MTOFFL ||
mtc.mt_op == MTSEEK)) {
i = st_int_ioctl(STp, MTWEOF, 1);
if (i < 0) {
retval = i;
goto out;
}
STps->rw = ST_IDLE;
}
} else {
/*
* If there was a bus reset, block further access
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment