>From 6d0f1d306660c645d72f8e1543ce0bebc719f10b Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Sun, 2 Feb 2014 12:03:09 +0100 Subject: [PATCH] st: Implement MT_ST_NOREWIND option This patch implements the MT_ST_NOREWIND option to inhibit the rewind on close setting even on normal 'st' devices. With this patch programs like sg_inq can retrieve the device identification without interrupting the current operation. Signed-off-by: Hannes Reinecke diff --git a/Documentation/scsi/st.txt b/Documentation/scsi/st.txt index f346abb..93906d0 100644 --- a/Documentation/scsi/st.txt +++ b/Documentation/scsi/st.txt @@ -399,6 +399,8 @@ MTSETDRVBUFFER correctly returns transfer residuals MT_ST_DEBUGGING debugging (global; debugging must be compiled into the driver) + MT_ST_NOREWIND disable rewind-on-close even on autorewind + tape devices MT_ST_SETBOOLEANS MT_ST_CLEARBOOLEANS Sets or clears the option bits. diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index a1d6986..f550d0d 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -2228,6 +2228,8 @@ static int st_set_options(struct scsi_tape *STp, long options) STp->immediate_filemark = (options & MT_ST_NOWAIT_EOF) != 0; STm->sysv = (options & MT_ST_SYSV) != 0; STp->sili = (options & MT_ST_SILI) != 0; + if (options & MT_ST_NOREWIND) + STp->rew_at_close = 0; DEB( debugging = (options & MT_ST_DEBUGGING) != 0; st_log_options(STp, STm, name); ) } else if (code == MT_ST_SETBOOLEANS || code == MT_ST_CLEARBOOLEANS) { @@ -2263,6 +2265,8 @@ static int st_set_options(struct scsi_tape *STp, long options) STm->sysv = value; if ((options & MT_ST_SILI) != 0) STp->sili = value; + if (value && (options & MT_ST_NOREWIND) != 0) + Stp->rew_at_close = 0; DEB( if ((options & MT_ST_DEBUGGING) != 0) debugging = value; diff --git a/include/uapi/linux/mtio.h b/include/uapi/linux/mtio.h index 18543e2..e8b0417 100644 --- a/include/uapi/linux/mtio.h +++ b/include/uapi/linux/mtio.h @@ -195,6 +195,7 @@ struct mtpos { #define MT_ST_NOWAIT 0x2000 #define MT_ST_SILI 0x4000 #define MT_ST_NOWAIT_EOF 0x8000 +#define MT_ST_NOREWIND 0x10000 /* The mode parameters to be controlled. Parameter chosen with bits 20-28 */ #define MT_ST_CLEAR_DEFAULT 0xfffff