summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@suse.de>2005-09-18 04:49:23 +0200
committerKay Sievers <kay.sievers@suse.de>2005-09-18 04:49:23 +0200
commit0e5f8a1fcc4b2bb020d865075bb8e543f5b0c230 (patch)
treeda9865a485af3f053443d02926c6a197c6607259
parenta3f129d054395019d4b2385dede233eb12425c78 (diff)
scsi_id: switch temporary node creation to /dev
/tmp is not writable on most systems, so just use /dev to create a temporary node. If called from a udev rule, "-d $tempnode" should be used and udev will create a temporary node and pass the name before calling scsi_id. Also remove gen_scsi_id_udev_rules.sh per Patrick's request, as it's no longer needed with the persistent disk links. Signed-off-by: Kay Sievers <kay.sievers@suse.de>
-rw-r--r--extras/scsi_id/gen_scsi_id_udev_rules.sh80
-rw-r--r--extras/scsi_id/scsi_id.816
-rw-r--r--extras/scsi_id/scsi_id.c4
3 files changed, 14 insertions, 86 deletions
diff --git a/extras/scsi_id/gen_scsi_id_udev_rules.sh b/extras/scsi_id/gen_scsi_id_udev_rules.sh
deleted file mode 100644
index 92fde5df1b..0000000000
--- a/extras/scsi_id/gen_scsi_id_udev_rules.sh
+++ /dev/null
@@ -1,80 +0,0 @@
-#! /bin/sh
-
-# This script generates and sends to stdout a set of udev.rules for use
-# with all scsi block devices on your system. It creates a udev key NAME
-# with prefix defaulting to "disk-", and appends the current kernel name
-# and the udev kernel number (the partition number, empty for the entire
-# disk).
-#
-# Managing these is probably better done via a gui interface.
-#
-# You can edit and append the output to your /etc/udev/udev.rules file.
-# You probably want to to change names to be non-kernel defaults, so as to
-# avoid confusion if a configuration change modifies /sys/block/sd*
-# naming.
-#
-# /etc/scsi_id.config must be properly configured. If you are using this
-# script, you probably want a single line enabling scsi_id for all
-# devices as follows:
-#
-# options=-g
-#
-# The above assumes you will not attach block devices that do not
-# properly support the page codes used by scsi_id, this is especially true
-# of many USB mass storage devices (mainly flash card readers).
-#
-
-prefix=disk-
-scsi_id=/sbin/scsi_id
-
-sysfs_dir=$(mount | awk '$5 == "sysfs" {print $3}')
-if [ "$sysfs_dir" = "" ]
-then
- sysfs_dir="/sys"
- echo "Using sysfs mount point \"$sysfs_dir\"" >&2
-fi
-
-c=$(ls /${sysfs_dir}/block/sd* 2>/dev/null | wc -l)
-if [ $c = 0 ]
-then
- echo $0 no block devices present >&2
- exit 1
-fi
-
-echo "#"
-echo "# Start of autogenerated scsi_id rules. Edit the NAME portions of these"
-echo "# rules to your liking."
-echo "#"
-first_line=yes
-
-#
-cd ${sysfs_dir}/block
-for name in sd*
-do
- id=$($scsi_id -s /block/$name)
- if [ $? != 0 ]
- then
- echo $0 failed for device $name exiting >&2
- exit 1
- fi
- if [ $first_line = "yes" ]
- then
- first_line=no
- echo "BUS=\"scsi\", PROGRAM=\"${scsi_id} -d %N -s %p\", RESULT=\"${id}\", NAME=\"${prefix}${name}%n\""
- echo
- echo "# Further RESULT keys use the result of the last PROGRAM rule."
- echo "# Be careful not to add any rules containing PROGRAM key between here"
- echo "# and the end of this section"
- echo
- else
- # No PROGRAM, so just use the last result of PROGRAM. The
- # following is the same as the above without the PROGRAM
- # key.
- echo "BUS=\"scsi\", RESULT=\"${id}\", NAME=\"${prefix}${name}%n\""
- fi
-
-done
-
-echo "#"
-echo "# End of autogenerated scsi_id rules"
-echo "#"
diff --git a/extras/scsi_id/scsi_id.8 b/extras/scsi_id/scsi_id.8
index 4213468ae4..691d5b8b05 100644
--- a/extras/scsi_id/scsi_id.8
+++ b/extras/scsi_id/scsi_id.8
@@ -111,7 +111,10 @@ The sysfs mount point must not be included. For example, use /block/sd,
not /sys/block/sd.
.TP
.BI \-u
-Reformat the output : replace all whitespaces by underscores
+Reformat the output : replace all whitespaces by underscores.
+.TP
+.BI \-x
+Export all data in KEY=<value> format used to import in other programs.
.TP
.BI \-v
Generate verbose debugging output.
@@ -140,13 +143,18 @@ for example:
.fi
.P
-An example \fBudev\fP rule using \fBscsi_id\fP, that will name a block
+\fBscsi_id\fP is one of the tools used in the "Linux Persistent Device Names"
+scheme that creates persistent device links in /dev/disk. It is called with
+the -x option which will print all values in a defined format to let udev
+import it into its own environment for later event processing.
+.sp
+An example custom \fBudev\fP rule using \fBscsi_id\fP, that will name a block
device and any partitions for the device matching the \fBscsi_id\fP output
of 312345:
.sp
.nf
-BUS="scsi", PROGRAM="/sbin/scsi_id -d %N -s %p", RESULT="312345", NAME="disk%n"
+BUS=="scsi", PROGRAM=="/sbin/scsi_id -d %N -s %p", RESULT=="312345", NAME="disk%n"
.fi
.P
@@ -158,7 +166,7 @@ BUS="scsi", PROGRAM="/sbin/scsi_id -d %N -s %p", RESULT="312345", NAME="disk%n"
.fi
.LP
.SH "SEE ALSO"
-.BR udev (8), hotplug (8)
+.BR udev (8)
.SH AUTHORS
Developed by Patrick Mansfield <patmans@us.ibm.com> based on SCSI ID
source included in earlier linux 2.5 kernels, sg_utils source, and SCSI
diff --git a/extras/scsi_id/scsi_id.c b/extras/scsi_id/scsi_id.c
index e997be9956..39391f6e2e 100644
--- a/extras/scsi_id/scsi_id.c
+++ b/extras/scsi_id/scsi_id.c
@@ -44,8 +44,8 @@
/*
* temporary names for mknod.
*/
-#define TMP_DIR "/tmp"
-#define TMP_PREFIX "scsi"
+#define TMP_DIR "/dev"
+#define TMP_PREFIX "tmp-scsi"
/*
* XXX Note the 'e' (send output to stderr in all cases), and 'c' (callout)