aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Makisara <Kai.Makisara@kolumbus.fi>2008-02-24 15:29:12 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-04-07 13:15:40 -0400
commitb174be02f3634460ac215d249617dee5ae446ae1 (patch)
tree6e62d2ff4b3c1cdfe2b36213992bd986ca9a5654
parent40f6b36c6243462fb95d0343237331c423494b03 (diff)
[SCSI] st: show options currently set in sysfs
Show the current binary tape driver and mode options is sysfs. A file (options) is created in each directory in /sys/class/scsi_tape. The files contain masks showing the options. The mask bit definitions are the same as used when setting the options using the MTSETDRVBUFFER function in the MTIOCTOP ioctl (defined in include/linux/mtio.h). For example: > cat /sys/class/scsi_tape/nst0/options 0x00000d07 [jejb: updated doc with correction from Randy Dunlap] Signed-off-by: Kai Makisara <kai.makisara@kolumbus.fi> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r--Documentation/scsi/st.txt7
-rw-r--r--drivers/scsi/st.c43
2 files changed, 49 insertions, 1 deletions
diff --git a/Documentation/scsi/st.txt b/Documentation/scsi/st.txt
index 38f81188def0..40752602c050 100644
--- a/Documentation/scsi/st.txt
+++ b/Documentation/scsi/st.txt
@@ -2,7 +2,7 @@ This file contains brief information about the SCSI tape driver.
2The driver is currently maintained by Kai Mäkisara (email 2The driver is currently maintained by Kai Mäkisara (email
3Kai.Makisara@kolumbus.fi) 3Kai.Makisara@kolumbus.fi)
4 4
5Last modified: Thu Feb 21 21:54:16 2008 by kai.makisara 5Last modified: Sun Feb 24 21:59:07 2008 by kai.makisara
6 6
7 7
8BASICS 8BASICS
@@ -133,6 +133,11 @@ the defaults set by the user. The value -1 means the default is not set. The
133file 'dev' contains the device numbers corresponding to this device. The links 133file 'dev' contains the device numbers corresponding to this device. The links
134'device' and 'driver' point to the SCSI device and driver entries. 134'device' and 'driver' point to the SCSI device and driver entries.
135 135
136Each directory also contains the entry 'options' which shows the currently
137enabled driver and mode options. The value in the file is a bit mask where the
138bit definitions are the same as those used with MTSETDRVBUFFER in setting the
139options.
140
136A link named 'tape' is made from the SCSI device directory to the class 141A link named 'tape' is made from the SCSI device directory to the class
137directory corresponding to the mode 0 auto-rewind device (e.g., st0). 142directory corresponding to the mode 0 auto-rewind device (e.g., st0).
138 143
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index a4361a8c6ac6..d204aad2e683 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4365,6 +4365,46 @@ static ssize_t st_defcompression_show(struct class_device *class_dev, char *buf)
4365 4365
4366CLASS_DEVICE_ATTR(default_compression, S_IRUGO, st_defcompression_show, NULL); 4366CLASS_DEVICE_ATTR(default_compression, S_IRUGO, st_defcompression_show, NULL);
4367 4367
4368static ssize_t st_options_show(struct class_device *class_dev, char *buf)
4369{
4370 struct st_modedef *STm = (struct st_modedef *)class_get_devdata(class_dev);
4371 struct scsi_tape *STp;
4372 int i, j, options;
4373 ssize_t l = 0;
4374
4375 for (i=0; i < st_dev_max; i++) {
4376 for (j=0; j < ST_NBR_MODES; j++)
4377 if (&scsi_tapes[i]->modes[j] == STm)
4378 break;
4379 if (j < ST_NBR_MODES)
4380 break;
4381 }
4382 if (i == st_dev_max)
4383 return 0; /* should never happen */
4384
4385 STp = scsi_tapes[i];
4386
4387 options = STm->do_buffer_writes ? MT_ST_BUFFER_WRITES : 0;
4388 options |= STm->do_async_writes ? MT_ST_ASYNC_WRITES : 0;
4389 options |= STm->do_read_ahead ? MT_ST_READ_AHEAD : 0;
4390 DEB( options |= debugging ? MT_ST_DEBUGGING : 0 );
4391 options |= STp->two_fm ? MT_ST_TWO_FM : 0;
4392 options |= STp->fast_mteom ? MT_ST_FAST_MTEOM : 0;
4393 options |= STm->defaults_for_writes ? MT_ST_DEF_WRITES : 0;
4394 options |= STp->can_bsr ? MT_ST_CAN_BSR : 0;
4395 options |= STp->omit_blklims ? MT_ST_NO_BLKLIMS : 0;
4396 options |= STp->can_partitions ? MT_ST_CAN_PARTITIONS : 0;
4397 options |= STp->scsi2_logical ? MT_ST_SCSI2LOGICAL : 0;
4398 options |= STm->sysv ? MT_ST_SYSV : 0;
4399 options |= STp->immediate ? MT_ST_NOWAIT : 0;
4400 options |= STp->sili ? MT_ST_SILI : 0;
4401
4402 l = snprintf(buf, PAGE_SIZE, "0x%08x\n", options);
4403 return l;
4404}
4405
4406CLASS_DEVICE_ATTR(options, S_IRUGO, st_options_show, NULL);
4407
4368static int do_create_class_files(struct scsi_tape *STp, int dev_num, int mode) 4408static int do_create_class_files(struct scsi_tape *STp, int dev_num, int mode)
4369{ 4409{
4370 int i, rew, error; 4410 int i, rew, error;
@@ -4402,6 +4442,9 @@ static int do_create_class_files(struct scsi_tape *STp, int dev_num, int mode)
4402 error = class_device_create_file(st_class_member, 4442 error = class_device_create_file(st_class_member,
4403 &class_device_attr_default_compression); 4443 &class_device_attr_default_compression);
4404 if (error) goto out; 4444 if (error) goto out;
4445 error = class_device_create_file(st_class_member,
4446 &class_device_attr_options);
4447 if (error) goto out;
4405 4448
4406 if (mode == 0 && rew == 0) { 4449 if (mode == 0 && rew == 0) {
4407 error = sysfs_create_link(&STp->device->sdev_gendev.kobj, 4450 error = sysfs_create_link(&STp->device->sdev_gendev.kobj,