* [PATCH] update udev scsi_id to scsi_id 0.3
@ 2004-01-16 19:48 Patrick Mansfield
2004-01-16 20:10 ` Patrick Mansfield
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Patrick Mansfield @ 2004-01-16 19:48 UTC (permalink / raw)
To: linux-hotplug
Greg -
Can you apply this patch to update udev's scsi_id to version 0.3?
Thanks!
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/ChangeLog udev-bk/extras/scsi_id/ChangeLog
--- udev-bk/extras/orig-scsi_id/ChangeLog Sun Dec 7 12:29:08 2003
+++ udev-bk/extras/scsi_id/ChangeLog Thu Jan 15 14:48:36 2004
@@ -1,3 +1,36 @@
+2004-jan-15:
+ * Makefile: Version 0.3
+
+2004-jan-13:
+ * scsi_id.c, Makefile: Fix prefix usage with scsi_id.config.
+
+2004-jan-13:
+ * scsi_id.config: Clean up some comment entries.
+
+2004-jan-13:
+ * Makefile: Install the sample scsi_id.config file.
+
+2004-jan-13:
+ * Makefile: Use DESTDIR in all install/uninstall rules, per
+ problem reported by Svetoslav Slavtchev.
+
+2004-jan-12:
+ * scsi_id.h, scsi_id.c, scsi_serial.c: Fix to work with current
+ sysfs 0.4, based on patch from Dan Stekloff, but uses
+ sysfs_read_attribute_value instead of
+ sysfs_get_value_from_attributes.
+
+2004-jan-08:
+ * scsi_id.c: SYSFS_BUS_DIR was replaced with SYSFS_BUS_NAME.
+
+2004-jan-08:
+ * scsi_id.c: Must now use sysfs_open_class_device_path instead of the
+ previous sysfs_open_class_device.
+
+2003-dec-07:
+ * Makefile: patch from Olaf Hering <olh@suse.de> remove DEBUG and
+ add --fno-builtin
+
2003-dec-05:
* Makefile, scsi_id.8: Add a man page.
@@ -53,12 +86,12 @@
is no support for that in klibc.
2003-nov-17:
- * scsi_id.c: Patch from Brian King: check result of setting model,
- not vendor in per_dev_options.
+ * scsi_id.c: Patch from Brian King <brking@us.ibm.com>: check
+ result of setting model, not vendor in per_dev_options.
2003-nov-03:
* scsi_id.c, scsi_serial.c: Use new and correct path to libsysfs.h.
2003-nov-03:
- * scsi_id.h: Fix scsi_id.h so var args in marcros works ok with
+ * scsi_id.h: Fix scsi_id.h so var args in macros works ok with
older gcc.
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/Makefile udev-bk/extras/scsi_id/Makefile
--- udev-bk/extras/orig-scsi_id/Makefile Tue Jan 13 07:38:49 2004
+++ udev-bk/extras/scsi_id/Makefile Thu Jan 15 15:05:00 2004
@@ -14,9 +14,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-SCSI_ID_VERSION=0.2
+SCSI_ID_VERSION=0.3
prefix +etcdir = ${prefix}/etc
sbindir = ${prefix}/sbin
mandir = ${prefix}/usr/share/man
@@ -27,7 +28,7 @@ INSTALL_DATA = ${INSTALL} -m 644
# Note some of the variables used here are set when built under udev, and
# otherwise might not be set.
-override CFLAGS+=-DSCSI_ID_VERSION=\"$(SCSI_ID_VERSION)\" -Wall
+override CFLAGS+=-Wall -fno-builtin
PROG=scsi_id
SYSFS=-lsysfs
@@ -39,25 +40,35 @@ SYSFS=-lsysfs
# LDFLAGS=$(STRIP)
LD=$(CC)
-OBJS= scsi_id.o \
- scsi_serial.o \
+OBJS= scsi_id.o scsi_serial.o
all: $(PROG)
# XXX use a compressed man page?
install: all
- $(INSTALL_PROGRAM) -D $(PROG) $(sbindir)/$(PROG)
+ $(INSTALL_PROGRAM) -D $(PROG) $(DESTDIR)$(sbindir)/$(PROG)
$(INSTALL_DATA) -D scsi_id.8 $(DESTDIR)$(mandir)/man8/scsi_id.8
+ @if [ ! -r $(DESTDIR)$(etcdir)/scsi_id.config ]; then \
+ echo $(INSTALL_DATA) -D ./scsi_id.config $(DESTDIR)$(etcdir); \
+ $(INSTALL_DATA) -D ./scsi_id.config $(DESTDIR)$(etcdir)/scsi_id.config; \
+ fi
uninstall:
- -rm $(sbindir)/$(PROG)
- -rm $(mandir)/man8/scsi_id.8
-
-$(OBJS): scsi_id.h scsi.h
+ -rm $(DESTDIR)$(sbindir)/$(PROG)
+ -rm $(DESTDIR)$(mandir)/man8/scsi_id.8
+ -rm $(DESTDIR)$(etcdir)/scsi_id.config
+
+GEN_HEADER=scsi_id_version.h
+
+scsi_id_version.h:
+ @echo "/* This file is auto-generated by the Makefile */" > $@
+ @echo \#define SCSI_ID_VERSION \"$(SCSI_ID_VERSION)\" >> $@
+ @echo \#define SCSI_ID_CONFIG_FILE \"$(etcdir)/scsi_id.config\" >> $@
+$(OBJS): scsi_id.h scsi.h scsi_id_version.h
clean:
- rm -f $(PROG) $(OBJS)
+ rm -f $(PROG) $(OBJS) $(GEN_HEADER)
$(PROG): $(OBJS)
$(LD) $(LDFLAGS) -o $(PROG) $(CRT0) $(OBJS) $(SYSFS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/README udev-bk/extras/scsi_id/README
--- udev-bk/extras/orig-scsi_id/README Sun Dec 7 12:29:08 2003
+++ udev-bk/extras/scsi_id/README Thu Jan 15 14:51:58 2004
@@ -7,12 +7,7 @@ Requires:
- Linux kernel 2.6
- - libsysfs
-
-No man page yet.
-
-libsysfs 0_2_0 was not installing libsysfs.h or dlist.h, manually copy
-those files to /usr/include/sys before compiling.
+ - sysfsutils 0.4
Build via make and make install.
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/TODO udev-bk/extras/scsi_id/TODO
--- udev-bk/extras/orig-scsi_id/TODO Sun Dec 7 12:29:08 2003
+++ udev-bk/extras/scsi_id/TODO Tue Jan 13 16:26:09 2004
@@ -1,4 +1,4 @@
-- add information abou the config file to the man page
+- add information about the config file to the man page
- change so non-KLIBC builds under udev don't use /usr/include/sysfs,
but instead use the sysfs included with udev (needs udev change and/or
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/release-notes udev-bk/extras/scsi_id/release-notes
--- udev-bk/extras/orig-scsi_id/release-notes Wed Dec 31 16:00:00 1969
+++ udev-bk/extras/scsi_id/release-notes Thu Jan 15 14:48:04 2004
@@ -0,0 +1,39 @@
+Version 0.3 of scsi_id is available at:
+
+http://www-124.ibm.com/storageio/scsi_id/scsi_id-0.3.tar.gz
+
+scsi_id is a program to generate a SCSI unique identifier for a given SCSI
+device.
+
+It is primarily for use with udev callout config entries. It can also be
+used for automatic multi-path configuration or device mapper configuration.
+
+Version 0.3 requires:
+
+- Linux kernel 2.6
+- libsysfs 0.4.0
+
+Major changes since the last release:
+
+ - Changes to work with libsysfs 0.4.0
+
+All changes:
+
+ - fix "prefix" usage for path to scsi_id.config
+
+ - install the sample scsi_id.config file.
+
+ - Use DESTDIR in all install/uninstall rules, per problem reported
+ by Svetoslav Slavtchev.
+
+ - Fix to work with current sysfs 0.4, based on patch from Dan
+ Stekloff, but uses sysfs_read_attribute_value instead of
+ sysfs_get_value_from_attributes.
+
+ - SYSFS_BUS_DIR was replaced with SYSFS_BUS_NAME.
+
+ - Must now use sysfs_open_class_device_path instead of the
+ previous sysfs_open_class_device.
+
+ - patch from Olaf Hering <olh@suse.de> remove DEBUG and
+ add --fno-builtin
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/scsi_id.c udev-bk/extras/scsi_id/scsi_id.c
--- udev-bk/extras/orig-scsi_id/scsi_id.c Fri Jan 9 11:34:35 2004
+++ udev-bk/extras/scsi_id/scsi_id.c Tue Jan 13 16:25:46 2004
@@ -40,6 +40,7 @@
#else
#include <sysfs/libsysfs.h>
#endif
+#include "scsi_id_version.h"
#include "scsi_id.h"
#ifndef SCSI_ID_VERSION
@@ -53,8 +54,6 @@
#define TMP_DIR "/tmp"
#define TMP_PREFIX "scsi"
-#define CONFIG_FILE "/etc/scsi_id.config"
-
static const char short_options[] = "bc:d:ef:gip:s:vV";
/*
* Just duplicate per dev options.
@@ -67,7 +66,7 @@ static int all_good;
static char *default_callout;
static int dev_specified;
static int sys_specified;
-static char config_file[MAX_NAME_LEN] = CONFIG_FILE;
+static char config_file[MAX_NAME_LEN] = SCSI_ID_CONFIG_FILE;
static int display_bus_id;
static int default_page_code;
static int use_stderr;
@@ -102,6 +101,18 @@ void log_message (int level, const char
return;
}
+int sysfs_get_attr(const char *devpath, const char *attr, char *value,
+ size_t bufsize)
+{
+ char attr_path[SYSFS_PATH_MAX];
+
+ strncpy(attr_path, devpath, SYSFS_PATH_MAX);
+ strncat(attr_path, "/", SYSFS_PATH_MAX);
+ strncat(attr_path, attr, SYSFS_PATH_MAX);
+ dprintf("%s\n", attr_path);
+ return sysfs_read_attribute_value(attr_path, value, SYSFS_NAME_LEN);
+}
+
static int sysfs_get_actual_dev(const char *sysfs_path, char *dev, int len)
{
dprintf("%s\n", sysfs_path);
@@ -153,34 +164,22 @@ static int sysfs_is_bus(const char *sysf
static int get_major_minor(const char *devpath, int *major, int *minor)
{
- struct sysfs_class_device *class_dev;
- char dev_value[SYSFS_NAME_LEN];
- char *dev;
-
- dprintf("%s\n", devpath);
- class_dev = sysfs_open_class_device_path(devpath);
- if (!class_dev) {
- log_message(LOG_WARNING, "open class %s failed: %s\n", devpath,
- strerror(errno));
- return -1;
- }
+ char dev_value[MAX_ATTR_LEN];
- dev = sysfs_get_attr(class_dev, "dev");
- if (dev)
- strncpy(dev_value, dev, SYSFS_NAME_LEN);
- sysfs_close_class_device(class_dev);
- if (!dev) {
+ if (sysfs_get_attr(devpath, "dev", dev_value, MAX_ATTR_LEN)) {
/*
* XXX This happens a lot, since sg has no dev attr.
- * Someday change this back to a LOG_WARNING.
+ * And now sysfsutils does not set a meaningful errno
+ * value. Someday change this back to a LOG_WARNING.
+ * And if sysfsutils changes, check for ENOENT and handle
+ * it separately.
*/
log_message(LOG_DEBUG, "%s could not get dev attribute: %s\n",
devpath, strerror(errno));
return -1;
}
- dev = NULL;
- dprintf("dev %s", dev_value); /* dev_value has a trailing \n */
+ dprintf("dev value %s", dev_value); /* dev_value has a trailing \n */
if (sscanf(dev_value, "%u:%u", major, minor) != 2) {
log_message(LOG_WARNING, "%s: invalid dev major/minor\n",
devpath);
@@ -547,8 +546,8 @@ static int per_dev_options(struct sysfs_
int retval;
int newargc;
char **newargv = NULL;
- char *vendor;
- char *model;
+ char vendor[MAX_ATTR_LEN];
+ char model[MAX_ATTR_LEN];
int option;
*good_bad = all_good;
@@ -558,16 +557,14 @@ static int per_dev_options(struct sysfs_
else
callout[0] = '\0';
- vendor = sysfs_get_attr(scsi_dev, "vendor");
- if (!vendor) {
- log_message(LOG_WARNING, "%s: no vendor attribute\n",
+ if (sysfs_get_attr(scsi_dev->path, "vendor", vendor, MAX_ATTR_LEN)) {
+ log_message(LOG_WARNING, "%s: cannot get vendor attribute\n",
scsi_dev->name);
return -1;
}
- model = sysfs_get_attr(scsi_dev, "model");
- if (!model) {
- log_message(LOG_WARNING, "%s: no model attribute\n",
+ if (sysfs_get_attr(scsi_dev->path, "model", model, MAX_ATTR_LEN)) {
+ log_message(LOG_WARNING, "%s: cannot get model attribute\n",
scsi_dev->name);
return -1;
}
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/scsi_id.config udev-bk/extras/scsi_id/scsi_id.config
--- udev-bk/extras/orig-scsi_id/scsi_id.config Tue Dec 2 10:58:40 2003
+++ udev-bk/extras/scsi_id/scsi_id.config Tue Jan 13 10:59:43 2004
@@ -21,7 +21,9 @@
# vendor=string[,model=string],options=<per-device scsi_id options>
#
-# If you normally don't need id's, black list everyone:
+# If you normally don't need scsi id's, or might be attaching devices of
+# an unknown functionality, black list everyone. This is the default
+# behaviour (if no -b or -g is specified).
#
options=-b
@@ -30,7 +32,8 @@ options=-b
#
vendor=someone, model=nicedrive, options=-g
-# If you have all good devices on your system use, mark all as good:
+# If you all the scsi devices are your system support valid id's, remove
+# the -b line above, and mark all devices as good:
## options=-g
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/scsi_id.h udev-bk/extras/scsi_id/scsi_id.h
--- udev-bk/extras/orig-scsi_id/scsi_id.h Fri Jan 9 11:34:35 2004
+++ udev-bk/extras/scsi_id/scsi_id.h Mon Jan 12 10:23:59 2004
@@ -28,6 +28,12 @@
#define OFFSET (2 * sizeof(unsigned int))
/*
+ * MAX_ATTR_LEN: maximum length of the result of reading a sysfs
+ * attribute.
+ */
+#define MAX_ATTR_LEN 256
+
+/*
* MAX_SERIAL_LEN: the maximum length of the serial number, including
* added prefixes such as vendor and product (model) strings.
*/
@@ -39,19 +45,8 @@
*/
#define MAX_BUFFER_LEN 256
-static inline char *sysfs_get_attr(struct sysfs_class_device *dev,
- const char *attr)
-{
- struct dlist *attributes = NULL;
-
- attributes = sysfs_get_classdev_attributes(dev);
-
- if (attributes = NULL)
- return NULL;
-
- return sysfs_get_value_from_attributes(attributes, attr);
-}
-
+extern int sysfs_get_attr(const char *devpath, const char *attr, char *value,
+ size_t bufsize);
extern int scsi_get_serial (struct sysfs_class_device *scsi_dev,
const char *devname, int page_code, char *serial,
int len);
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/scsi_serial.c udev-bk/extras/scsi_id/scsi_serial.c
--- udev-bk/extras/orig-scsi_id/scsi_serial.c Sun Dec 7 12:29:08 2003
+++ udev-bk/extras/scsi_id/scsi_serial.c Mon Jan 12 10:23:59 2004
@@ -385,7 +385,7 @@ static int do_scsi_page0_inquiry(struct
char *buffer, int len)
{
int retval;
- char *vendor;
+ char vendor[MAX_ATTR_LEN];
memset(buffer, 0, len);
retval = scsi_inquiry(scsi_dev, fd, 1, 0x0, buffer, len);
@@ -415,9 +415,10 @@ static int do_scsi_page0_inquiry(struct
* If the vendor id appears in the page assume the page is
* invalid.
*/
- vendor = sysfs_get_attr(scsi_dev, "vendor");
- if (!vendor) {
- log_message(LOG_WARNING, "%s: no vendor attribute\n",
+ if (sysfs_get_attr(scsi_dev->path, "vendor", vendor,
+ MAX_ATTR_LEN)) {
+ log_message(LOG_WARNING,
+ "%s: cannot get model attribute\n",
scsi_dev->name);
return 1;
}
@@ -437,12 +438,11 @@ static int do_scsi_page0_inquiry(struct
static int prepend_vendor_model(struct sysfs_class_device *scsi_dev,
char *serial)
{
- char *attr;
+ char attr[MAX_ATTR_LEN];
int ind;
- attr = sysfs_get_attr(scsi_dev, "vendor");
- if (!attr) {
- log_message(LOG_WARNING, "%s: no vendor attribute\n",
+ if (sysfs_get_attr(scsi_dev->path, "vendor", attr, MAX_ATTR_LEN)) {
+ log_message(LOG_WARNING, "%s: cannot get vendor attribute\n",
scsi_dev->name);
return 1;
}
@@ -454,9 +454,8 @@ static int prepend_vendor_model(struct s
if (serial[ind] = '\n')
serial[ind] = '\0';
- attr = sysfs_get_attr(scsi_dev, "model");
- if (!attr) {
- log_message(LOG_WARNING, "%s: no model attribute\n",
+ if (sysfs_get_attr(scsi_dev->path, "model", attr, MAX_ATTR_LEN)) {
+ log_message(LOG_WARNING, "%s: cannot get model attribute\n",
scsi_dev->name);
return 1;
}
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] update udev scsi_id to scsi_id 0.3
2004-01-16 19:48 [PATCH] update udev scsi_id to scsi_id 0.3 Patrick Mansfield
@ 2004-01-16 20:10 ` Patrick Mansfield
2004-01-16 22:04 ` Greg KH
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Patrick Mansfield @ 2004-01-16 20:10 UTC (permalink / raw)
To: linux-hotplug
Oops! That last one was diff-ed against the wrong scsi_id/Makefile, this
one should work with no rejects.
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/ChangeLog udev-bk/extras/scsi_id/ChangeLog
--- udev-bk/extras/orig-scsi_id/ChangeLog Fri Jan 16 11:51:24 2004
+++ udev-bk/extras/scsi_id/ChangeLog Thu Jan 15 14:48:36 2004
@@ -1,3 +1,36 @@
+2004-jan-15:
+ * Makefile: Version 0.3
+
+2004-jan-13:
+ * scsi_id.c, Makefile: Fix prefix usage with scsi_id.config.
+
+2004-jan-13:
+ * scsi_id.config: Clean up some comment entries.
+
+2004-jan-13:
+ * Makefile: Install the sample scsi_id.config file.
+
+2004-jan-13:
+ * Makefile: Use DESTDIR in all install/uninstall rules, per
+ problem reported by Svetoslav Slavtchev.
+
+2004-jan-12:
+ * scsi_id.h, scsi_id.c, scsi_serial.c: Fix to work with current
+ sysfs 0.4, based on patch from Dan Stekloff, but uses
+ sysfs_read_attribute_value instead of
+ sysfs_get_value_from_attributes.
+
+2004-jan-08:
+ * scsi_id.c: SYSFS_BUS_DIR was replaced with SYSFS_BUS_NAME.
+
+2004-jan-08:
+ * scsi_id.c: Must now use sysfs_open_class_device_path instead of the
+ previous sysfs_open_class_device.
+
+2003-dec-07:
+ * Makefile: patch from Olaf Hering <olh@suse.de> remove DEBUG and
+ add --fno-builtin
+
2003-dec-05:
* Makefile, scsi_id.8: Add a man page.
@@ -53,12 +86,12 @@
is no support for that in klibc.
2003-nov-17:
- * scsi_id.c: Patch from Brian King: check result of setting model,
- not vendor in per_dev_options.
+ * scsi_id.c: Patch from Brian King <brking@us.ibm.com>: check
+ result of setting model, not vendor in per_dev_options.
2003-nov-03:
* scsi_id.c, scsi_serial.c: Use new and correct path to libsysfs.h.
2003-nov-03:
- * scsi_id.h: Fix scsi_id.h so var args in marcros works ok with
+ * scsi_id.h: Fix scsi_id.h so var args in macros works ok with
older gcc.
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/Makefile udev-bk/extras/scsi_id/Makefile
--- udev-bk/extras/orig-scsi_id/Makefile Fri Jan 16 11:51:24 2004
+++ udev-bk/extras/scsi_id/Makefile Thu Jan 15 15:05:00 2004
@@ -14,9 +14,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-SCSI_ID_VERSION=0.2
+SCSI_ID_VERSION=0.3
prefix +etcdir = ${prefix}/etc
sbindir = ${prefix}/sbin
mandir = ${prefix}/usr/share/man
@@ -27,7 +28,7 @@ INSTALL_DATA = ${INSTALL} -m 644
# Note some of the variables used here are set when built under udev, and
# otherwise might not be set.
-override CFLAGS+=-DSCSI_ID_VERSION=\"$(SCSI_ID_VERSION)\" $(DEBUG) -Wall
+override CFLAGS+=-Wall -fno-builtin
PROG=scsi_id
SYSFS=-lsysfs
@@ -39,25 +40,35 @@ SYSFS=-lsysfs
# LDFLAGS=$(STRIP)
LD=$(CC)
-OBJS= scsi_id.o \
- scsi_serial.o \
+OBJS= scsi_id.o scsi_serial.o
all: $(PROG)
# XXX use a compressed man page?
install: all
- $(INSTALL_PROGRAM) -D $(PROG) $(sbindir)/$(PROG)
+ $(INSTALL_PROGRAM) -D $(PROG) $(DESTDIR)$(sbindir)/$(PROG)
$(INSTALL_DATA) -D scsi_id.8 $(DESTDIR)$(mandir)/man8/scsi_id.8
+ @if [ ! -r $(DESTDIR)$(etcdir)/scsi_id.config ]; then \
+ echo $(INSTALL_DATA) -D ./scsi_id.config $(DESTDIR)$(etcdir); \
+ $(INSTALL_DATA) -D ./scsi_id.config $(DESTDIR)$(etcdir)/scsi_id.config; \
+ fi
uninstall:
- -rm $(sbindir)/$(PROG)
- -rm $(mandir)/man8/scsi_id.8
-
-$(OBJS): scsi_id.h scsi.h
+ -rm $(DESTDIR)$(sbindir)/$(PROG)
+ -rm $(DESTDIR)$(mandir)/man8/scsi_id.8
+ -rm $(DESTDIR)$(etcdir)/scsi_id.config
+
+GEN_HEADER=scsi_id_version.h
+
+scsi_id_version.h:
+ @echo "/* This file is auto-generated by the Makefile */" > $@
+ @echo \#define SCSI_ID_VERSION \"$(SCSI_ID_VERSION)\" >> $@
+ @echo \#define SCSI_ID_CONFIG_FILE \"$(etcdir)/scsi_id.config\" >> $@
+$(OBJS): scsi_id.h scsi.h scsi_id_version.h
clean:
- rm -f $(PROG) $(OBJS)
+ rm -f $(PROG) $(OBJS) $(GEN_HEADER)
$(PROG): $(OBJS)
$(LD) $(LDFLAGS) -o $(PROG) $(CRT0) $(OBJS) $(SYSFS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/README udev-bk/extras/scsi_id/README
--- udev-bk/extras/orig-scsi_id/README Fri Jan 16 11:51:24 2004
+++ udev-bk/extras/scsi_id/README Thu Jan 15 14:51:58 2004
@@ -7,12 +7,7 @@ Requires:
- Linux kernel 2.6
- - libsysfs
-
-No man page yet.
-
-libsysfs 0_2_0 was not installing libsysfs.h or dlist.h, manually copy
-those files to /usr/include/sys before compiling.
+ - sysfsutils 0.4
Build via make and make install.
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/TODO udev-bk/extras/scsi_id/TODO
--- udev-bk/extras/orig-scsi_id/TODO Fri Jan 16 11:51:24 2004
+++ udev-bk/extras/scsi_id/TODO Tue Jan 13 16:26:09 2004
@@ -1,4 +1,4 @@
-- add information abou the config file to the man page
+- add information about the config file to the man page
- change so non-KLIBC builds under udev don't use /usr/include/sysfs,
but instead use the sysfs included with udev (needs udev change and/or
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/release-notes udev-bk/extras/scsi_id/release-notes
--- udev-bk/extras/orig-scsi_id/release-notes Wed Dec 31 16:00:00 1969
+++ udev-bk/extras/scsi_id/release-notes Thu Jan 15 14:48:04 2004
@@ -0,0 +1,39 @@
+Version 0.3 of scsi_id is available at:
+
+http://www-124.ibm.com/storageio/scsi_id/scsi_id-0.3.tar.gz
+
+scsi_id is a program to generate a SCSI unique identifier for a given SCSI
+device.
+
+It is primarily for use with udev callout config entries. It can also be
+used for automatic multi-path configuration or device mapper configuration.
+
+Version 0.3 requires:
+
+- Linux kernel 2.6
+- libsysfs 0.4.0
+
+Major changes since the last release:
+
+ - Changes to work with libsysfs 0.4.0
+
+All changes:
+
+ - fix "prefix" usage for path to scsi_id.config
+
+ - install the sample scsi_id.config file.
+
+ - Use DESTDIR in all install/uninstall rules, per problem reported
+ by Svetoslav Slavtchev.
+
+ - Fix to work with current sysfs 0.4, based on patch from Dan
+ Stekloff, but uses sysfs_read_attribute_value instead of
+ sysfs_get_value_from_attributes.
+
+ - SYSFS_BUS_DIR was replaced with SYSFS_BUS_NAME.
+
+ - Must now use sysfs_open_class_device_path instead of the
+ previous sysfs_open_class_device.
+
+ - patch from Olaf Hering <olh@suse.de> remove DEBUG and
+ add --fno-builtin
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/scsi_id.c udev-bk/extras/scsi_id/scsi_id.c
--- udev-bk/extras/orig-scsi_id/scsi_id.c Fri Jan 16 11:51:24 2004
+++ udev-bk/extras/scsi_id/scsi_id.c Tue Jan 13 16:25:46 2004
@@ -40,6 +40,7 @@
#else
#include <sysfs/libsysfs.h>
#endif
+#include "scsi_id_version.h"
#include "scsi_id.h"
#ifndef SCSI_ID_VERSION
@@ -53,8 +54,6 @@
#define TMP_DIR "/tmp"
#define TMP_PREFIX "scsi"
-#define CONFIG_FILE "/etc/scsi_id.config"
-
static const char short_options[] = "bc:d:ef:gip:s:vV";
/*
* Just duplicate per dev options.
@@ -67,7 +66,7 @@ static int all_good;
static char *default_callout;
static int dev_specified;
static int sys_specified;
-static char config_file[MAX_NAME_LEN] = CONFIG_FILE;
+static char config_file[MAX_NAME_LEN] = SCSI_ID_CONFIG_FILE;
static int display_bus_id;
static int default_page_code;
static int use_stderr;
@@ -102,6 +101,18 @@ void log_message (int level, const char
return;
}
+int sysfs_get_attr(const char *devpath, const char *attr, char *value,
+ size_t bufsize)
+{
+ char attr_path[SYSFS_PATH_MAX];
+
+ strncpy(attr_path, devpath, SYSFS_PATH_MAX);
+ strncat(attr_path, "/", SYSFS_PATH_MAX);
+ strncat(attr_path, attr, SYSFS_PATH_MAX);
+ dprintf("%s\n", attr_path);
+ return sysfs_read_attribute_value(attr_path, value, SYSFS_NAME_LEN);
+}
+
static int sysfs_get_actual_dev(const char *sysfs_path, char *dev, int len)
{
dprintf("%s\n", sysfs_path);
@@ -153,34 +164,22 @@ static int sysfs_is_bus(const char *sysf
static int get_major_minor(const char *devpath, int *major, int *minor)
{
- struct sysfs_class_device *class_dev;
- char dev_value[SYSFS_NAME_LEN];
- char *dev;
-
- dprintf("%s\n", devpath);
- class_dev = sysfs_open_class_device_path(devpath);
- if (!class_dev) {
- log_message(LOG_WARNING, "open class %s failed: %s\n", devpath,
- strerror(errno));
- return -1;
- }
+ char dev_value[MAX_ATTR_LEN];
- dev = sysfs_get_attr(class_dev, "dev");
- if (dev)
- strncpy(dev_value, dev, SYSFS_NAME_LEN);
- sysfs_close_class_device(class_dev);
- if (!dev) {
+ if (sysfs_get_attr(devpath, "dev", dev_value, MAX_ATTR_LEN)) {
/*
* XXX This happens a lot, since sg has no dev attr.
- * Someday change this back to a LOG_WARNING.
+ * And now sysfsutils does not set a meaningful errno
+ * value. Someday change this back to a LOG_WARNING.
+ * And if sysfsutils changes, check for ENOENT and handle
+ * it separately.
*/
log_message(LOG_DEBUG, "%s could not get dev attribute: %s\n",
devpath, strerror(errno));
return -1;
}
- dev = NULL;
- dprintf("dev %s", dev_value); /* dev_value has a trailing \n */
+ dprintf("dev value %s", dev_value); /* dev_value has a trailing \n */
if (sscanf(dev_value, "%u:%u", major, minor) != 2) {
log_message(LOG_WARNING, "%s: invalid dev major/minor\n",
devpath);
@@ -547,8 +546,8 @@ static int per_dev_options(struct sysfs_
int retval;
int newargc;
char **newargv = NULL;
- char *vendor;
- char *model;
+ char vendor[MAX_ATTR_LEN];
+ char model[MAX_ATTR_LEN];
int option;
*good_bad = all_good;
@@ -558,16 +557,14 @@ static int per_dev_options(struct sysfs_
else
callout[0] = '\0';
- vendor = sysfs_get_attr(scsi_dev, "vendor");
- if (!vendor) {
- log_message(LOG_WARNING, "%s: no vendor attribute\n",
+ if (sysfs_get_attr(scsi_dev->path, "vendor", vendor, MAX_ATTR_LEN)) {
+ log_message(LOG_WARNING, "%s: cannot get vendor attribute\n",
scsi_dev->name);
return -1;
}
- model = sysfs_get_attr(scsi_dev, "model");
- if (!model) {
- log_message(LOG_WARNING, "%s: no model attribute\n",
+ if (sysfs_get_attr(scsi_dev->path, "model", model, MAX_ATTR_LEN)) {
+ log_message(LOG_WARNING, "%s: cannot get model attribute\n",
scsi_dev->name);
return -1;
}
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/scsi_id.config udev-bk/extras/scsi_id/scsi_id.config
--- udev-bk/extras/orig-scsi_id/scsi_id.config Fri Jan 16 11:51:24 2004
+++ udev-bk/extras/scsi_id/scsi_id.config Tue Jan 13 10:59:43 2004
@@ -21,7 +21,9 @@
# vendor=string[,model=string],options=<per-device scsi_id options>
#
-# If you normally don't need id's, black list everyone:
+# If you normally don't need scsi id's, or might be attaching devices of
+# an unknown functionality, black list everyone. This is the default
+# behaviour (if no -b or -g is specified).
#
options=-b
@@ -30,7 +32,8 @@ options=-b
#
vendor=someone, model=nicedrive, options=-g
-# If you have all good devices on your system use, mark all as good:
+# If you all the scsi devices are your system support valid id's, remove
+# the -b line above, and mark all devices as good:
## options=-g
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/scsi_id.h udev-bk/extras/scsi_id/scsi_id.h
--- udev-bk/extras/orig-scsi_id/scsi_id.h Fri Jan 16 11:51:24 2004
+++ udev-bk/extras/scsi_id/scsi_id.h Mon Jan 12 10:23:59 2004
@@ -28,6 +28,12 @@
#define OFFSET (2 * sizeof(unsigned int))
/*
+ * MAX_ATTR_LEN: maximum length of the result of reading a sysfs
+ * attribute.
+ */
+#define MAX_ATTR_LEN 256
+
+/*
* MAX_SERIAL_LEN: the maximum length of the serial number, including
* added prefixes such as vendor and product (model) strings.
*/
@@ -39,19 +45,8 @@
*/
#define MAX_BUFFER_LEN 256
-static inline char *sysfs_get_attr(struct sysfs_class_device *dev,
- const char *attr)
-{
- struct dlist *attributes = NULL;
-
- attributes = sysfs_get_classdev_attributes(dev);
-
- if (attributes = NULL)
- return NULL;
-
- return sysfs_get_value_from_attributes(attributes, attr);
-}
-
+extern int sysfs_get_attr(const char *devpath, const char *attr, char *value,
+ size_t bufsize);
extern int scsi_get_serial (struct sysfs_class_device *scsi_dev,
const char *devname, int page_code, char *serial,
int len);
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/scsi_serial.c udev-bk/extras/scsi_id/scsi_serial.c
--- udev-bk/extras/orig-scsi_id/scsi_serial.c Fri Jan 16 11:51:24 2004
+++ udev-bk/extras/scsi_id/scsi_serial.c Mon Jan 12 10:23:59 2004
@@ -385,7 +385,7 @@ static int do_scsi_page0_inquiry(struct
char *buffer, int len)
{
int retval;
- char *vendor;
+ char vendor[MAX_ATTR_LEN];
memset(buffer, 0, len);
retval = scsi_inquiry(scsi_dev, fd, 1, 0x0, buffer, len);
@@ -415,9 +415,10 @@ static int do_scsi_page0_inquiry(struct
* If the vendor id appears in the page assume the page is
* invalid.
*/
- vendor = sysfs_get_attr(scsi_dev, "vendor");
- if (!vendor) {
- log_message(LOG_WARNING, "%s: no vendor attribute\n",
+ if (sysfs_get_attr(scsi_dev->path, "vendor", vendor,
+ MAX_ATTR_LEN)) {
+ log_message(LOG_WARNING,
+ "%s: cannot get model attribute\n",
scsi_dev->name);
return 1;
}
@@ -437,12 +438,11 @@ static int do_scsi_page0_inquiry(struct
static int prepend_vendor_model(struct sysfs_class_device *scsi_dev,
char *serial)
{
- char *attr;
+ char attr[MAX_ATTR_LEN];
int ind;
- attr = sysfs_get_attr(scsi_dev, "vendor");
- if (!attr) {
- log_message(LOG_WARNING, "%s: no vendor attribute\n",
+ if (sysfs_get_attr(scsi_dev->path, "vendor", attr, MAX_ATTR_LEN)) {
+ log_message(LOG_WARNING, "%s: cannot get vendor attribute\n",
scsi_dev->name);
return 1;
}
@@ -454,9 +454,8 @@ static int prepend_vendor_model(struct s
if (serial[ind] = '\n')
serial[ind] = '\0';
- attr = sysfs_get_attr(scsi_dev, "model");
- if (!attr) {
- log_message(LOG_WARNING, "%s: no model attribute\n",
+ if (sysfs_get_attr(scsi_dev->path, "model", attr, MAX_ATTR_LEN)) {
+ log_message(LOG_WARNING, "%s: cannot get model attribute\n",
scsi_dev->name);
return 1;
}
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] update udev scsi_id to scsi_id 0.3
2004-01-16 19:48 [PATCH] update udev scsi_id to scsi_id 0.3 Patrick Mansfield
2004-01-16 20:10 ` Patrick Mansfield
@ 2004-01-16 22:04 ` Greg KH
2004-02-25 22:46 ` [PATCH] update udev scsi_id to scsi_id 0.4 Patrick Mansfield
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2004-01-16 22:04 UTC (permalink / raw)
To: linux-hotplug
On Fri, Jan 16, 2004 at 12:10:56PM -0800, Patrick Mansfield wrote:
> Oops! That last one was diff-ed against the wrong scsi_id/Makefile, this
> one should work with no rejects.
Applied, thanks.
greg k-h
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] update udev scsi_id to scsi_id 0.4
2004-01-16 19:48 [PATCH] update udev scsi_id to scsi_id 0.3 Patrick Mansfield
2004-01-16 20:10 ` Patrick Mansfield
2004-01-16 22:04 ` Greg KH
@ 2004-02-25 22:46 ` Patrick Mansfield
2004-02-28 1:01 ` Greg KH
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Patrick Mansfield @ 2004-02-25 22:46 UTC (permalink / raw)
To: linux-hotplug
Hi -
Greg, can you please apply this to your udev tree?
This patch syncs the scsi_id in the udev tree to version 0.4.
See the announce email for details.
Thanks.
diff -uprN -X /home/patman/dontdiff udev-bk/extras/scsi_id/ChangeLog udev-scsi_id-0.4/extras/scsi_id/ChangeLog
--- udev-bk/extras/scsi_id/ChangeLog Tue Feb 17 16:33:28 2004
+++ udev-scsi_id-0.4/extras/scsi_id/ChangeLog Wed Feb 25 13:08:48 2004
@@ -1,3 +1,46 @@
+2004-feb-25:
+ * scsi_id.8: Add verbage about usage with udev, and running via
+ hotplug.
+
+2004-feb-25:
+ * scsi_id.c, scsi_id.8: Disable support for -e (all output to
+ stderr) as it cannot be used in any useful way, and the -c
+ (device specific callout) as the code is incomplete and has no
+ users.
+
+2004-feb-25:
+ * scsi_id.c: Don't print errno for NULL return from
+ sysfs_get_classdev_device.
+
+2004-feb-23:
+ * scsi_id.c: Get rid of dead/leftover code that checked
+ if we are on a scsi bus.
+
+2004-feb-23:
+ * scsi_serial.c, scsi_id.c: Use ":" consistently in output messages.
+
+2004-feb-23:
+ * scsi_serial.c: Add missing new lines for some error messages.
+
+2004-feb-23:
+ * scsi_serial.c: open O_NONBLOCK so we handle tape drives without
+ tapes loaded.
+
+2004-feb-20:
+ * scsi_id.h, scsi_id.c: Remove hacks based on KLIBC define to get
+ around problems when building with udev (udev libsysfs files
+ were rearranged).
+
+2004-feb-19:
+ * scsi_id.h, scsi_id.c, scsi_serial.c: As done in udev code, support
+ partitions via looking for a parent of the target path. Uses
+ libsysfs functions to do most of the work, and includes changing
+ a lot of variables to be struct sysfs_device instead of
+ sysfs_class_device.
+
+2004-feb-19:
+ * Makefile: Version 0.4
+
2004-jan-15:
* Makefile: Version 0.3
diff -uprN -X /home/patman/dontdiff udev-bk/extras/scsi_id/Makefile udev-scsi_id-0.4/extras/scsi_id/Makefile
--- udev-bk/extras/scsi_id/Makefile Tue Feb 17 16:33:28 2004
+++ udev-scsi_id-0.4/extras/scsi_id/Makefile Thu Feb 19 16:27:00 2004
@@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-SCSI_ID_VERSION=0.3
+SCSI_ID_VERSION=0.4
prefix etcdir = ${prefix}/etc
diff -uprN -X /home/patman/dontdiff udev-bk/extras/scsi_id/TODO udev-scsi_id-0.4/extras/scsi_id/TODO
--- udev-bk/extras/scsi_id/TODO Tue Feb 17 16:33:28 2004
+++ udev-scsi_id-0.4/extras/scsi_id/TODO Wed Feb 25 13:06:24 2004
@@ -1,11 +1,8 @@
-- add information about the config file to the man page
+- Document that config file options override command line options, or fix
+ the code. This means a '-b' in the config file disables any -g on the
+ command line.
-- change so non-KLIBC builds under udev don't use /usr/include/sysfs,
- but instead use the sysfs included with udev (needs udev change and/or
- sysfsutils changes).
+- Add code to check that SCSI commands get back enough data for their
+ intended usage, mainly callers of scsi_inquiry().
-- do something with callout code - remove or change to a tag?
-
- This needs an implementation of a device specific callout or device
- specific code (called via some special "tag" or such) before it can be
- completed. Someone with such hardware to send in a patch.
+- Document the config file in the man page
diff -uprN -X /home/patman/dontdiff udev-bk/extras/scsi_id/gen_scsi_id_udev_rules.sh udev-scsi_id-0.4/extras/scsi_id/gen_scsi_id_udev_rules.sh
--- udev-bk/extras/scsi_id/gen_scsi_id_udev_rules.sh Wed Dec 31 16:00:00 1969
+++ udev-scsi_id-0.4/extras/scsi_id/gen_scsi_id_udev_rules.sh Wed Feb 25 13:03:08 2004
@@ -0,0 +1,85 @@
+#! /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
+
+dump_ids()
+{
+ cd ${sysfs_dir}/block
+ for b in sd*
+ do
+ echo -n "$b "
+ $scsi_id -s /block/$b
+ if [ $? != 0 ]
+ then
+ echo $0 failed for device $b >&2
+ exit 1
+ fi
+ done
+}
+
+sysfs_dir=$(mount | awk '$5 = "sysfs" {print $3}')
+
+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
+dump_ids | while read in
+do
+ set $in
+ name=$1
+ shift
+ id="$*"
+ if [ $first_line = "yes" ]
+ then
+ first_line=no
+ echo "BUS=\"scsi\", PROGRAM=\"${scsi_id}\", 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 -uprN -X /home/patman/dontdiff udev-bk/extras/scsi_id/release-notes udev-scsi_id-0.4/extras/scsi_id/release-notes
--- udev-bk/extras/scsi_id/release-notes Tue Feb 17 16:33:28 2004
+++ udev-scsi_id-0.4/extras/scsi_id/release-notes Wed Feb 25 13:20:13 2004
@@ -1,39 +1,49 @@
-Version 0.3 of scsi_id is available at:
+Version 0.4 of scsi_id is available at:
-http://www-124.ibm.com/storageio/scsi_id/scsi_id-0.3.tar.gz
+http://www-124.ibm.com/storageio/scsi_id/scsi_id-0.4.tar.gz
-scsi_id is a program to generate a SCSI unique identifier for a given SCSI
+scsi_id is a program to generate a unique identifier for a given SCSI
device.
-It is primarily for use with udev callout config entries. It can also be
-used for automatic multi-path configuration or device mapper configuration.
+It is primarily for use with the udev callout key. It could also be used
+for automatic multi-path configuration or device mapper configuration.
-Version 0.3 requires:
+Version 0.4 requires:
- Linux kernel 2.6
- libsysfs 0.4.0
Major changes since the last release:
- - Changes to work with libsysfs 0.4.0
+ - Support block device partitions
-All changes:
+ - Added a script to auto-generate udev rules. The script is not
+ installed but is part of the tarball.
- - fix "prefix" usage for path to scsi_id.config
+Detailed changes:
- - install the sample scsi_id.config file.
+ - Add man page verbage about usage with udev, and running via
+ hotplug
- - Use DESTDIR in all install/uninstall rules, per problem reported
- by Svetoslav Slavtchev.
+ - Disable support for -e (all output to stderr) as it cannot be
+ used in any useful way, and the -c (device specific callout) as
+ the code is incomplete and has no users.
- - Fix to work with current sysfs 0.4, based on patch from Dan
- Stekloff, but uses sysfs_read_attribute_value instead of
- sysfs_get_value_from_attributes.
+ - Don't print errno for NULL return from sysfs_get_classdev_device.
- - SYSFS_BUS_DIR was replaced with SYSFS_BUS_NAME.
+ - Get rid of dead/leftover code that checked if we are on a scsi
+ bus.
- - Must now use sysfs_open_class_device_path instead of the
- previous sysfs_open_class_device.
+ - ":" consistently in output messages.
- - patch from Olaf Hering <olh@suse.de> remove DEBUG and
- add --fno-builtin
+ - Add missing new lines for some error messages.
+
+ - open O_NONBLOCK so we handle tape drives without tapes loaded.
+
+ - Remove hacks based on KLIBC define to get around problems when
+ building with udev (udev libsysfs files were rearranged).
+
+ - As done in udev code, support partitions via looking for a
+ parent of the target path. Uses libsysfs functions to do most of
+ the work, and includes changing a lot of variables to be struct
+ sysfs_device instead of sysfs_class_device.
Binary files udev-bk/extras/scsi_id/scsi_id and udev-scsi_id-0.4/extras/scsi_id/scsi_id differ
diff -uprN -X /home/patman/dontdiff udev-bk/extras/scsi_id/scsi_id.8 udev-scsi_id-0.4/extras/scsi_id/scsi_id.8
--- udev-bk/extras/scsi_id/scsi_id.8 Tue Feb 17 16:33:28 2004
+++ udev-scsi_id-0.4/extras/scsi_id/scsi_id.8 Wed Feb 25 13:08:48 2004
@@ -50,9 +50,13 @@ identifier starts with the NAA value of
.fi
.P
-
.SH OPTIONS
.TP
+.BI subsystem
+When called with only a single argument without a leading \-, runs in a hotplug
+mode, and expects the environment variable DEVPATH to specify the
+corresponding sysfs device. See section below on usage with \fBudev\fP.
+.TP
.BI \-b
The default behaviour - treat the device as black listed, and do nothing
unless a white listed device is found in the scsi_id config-file.
@@ -63,11 +67,6 @@ of determining and creating a device nod
entry as done for the \fB-s\fP, send SG_IO commands to
\fBdevice\fP, such as \fB/dev/sdc\fP.
.TP
-.BI \-e
-Send all output to standard error even if
-.B scsi_id
-is running in hotplug mode.
-.TP
.BI \-f "\| config-file"
Read configuration and black/white list entries from
.B config-file
@@ -90,7 +89,7 @@ Use SCSI INQUIRY VPD page code 0x80 or 0
query the available VPD pages, and use page 0x83 if found, else page 0x80
if found, else nothing.
.TP
-.BI \-s "\|sysfs-device"
+.BI \-s "\| sysfs-device"
Generate an id for the
.B sysfs-device.
The sysfs mount point must not be included. For example, use /block/sd,
@@ -102,6 +101,37 @@ Generate verbose debugging output.
.BI \-V
Display version number and exit.
.RE
+
+.SH USAGE WITH UDEV
+If \fBscsi_id\fP is invoked with one argument without a leading \-, it
+assumes it is called for a hotplug event, and looks for the sysfs device
+in the DEVPATH environment variable.
+
+This mode is used when run via the \fBudev\fP PROGRAM key. Passing any
+arguments or options as part of the PROGRAM rule breaks this assumption,
+and the results will likely not be as expected.
+
+When in this mode, all errors and warnings are sent via syslog.
+
+To determine the specific value needed in a RESULT key, use the -s option,
+for example:
+
+.sp
+.nf
+/sbin/scsi_id -s /block/sda
+.fi
+.P
+
+An example \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", RESULT="312345", NAME="disk%n"
+.fi
+.P
+
.SH "FILES"
.nf
.ft B
@@ -110,8 +140,7 @@ Display version number and exit.
.fi
.LP
.SH "SEE ALSO"
-.BR udev (8)
-, especially the CALLOUT method.
+.BR udev (8), hotplug (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 -uprN -X /home/patman/dontdiff udev-bk/extras/scsi_id/scsi_id.c udev-scsi_id-0.4/extras/scsi_id/scsi_id.c
--- udev-bk/extras/scsi_id/scsi_id.c Tue Feb 17 16:33:28 2004
+++ udev-scsi_id-0.4/extras/scsi_id/scsi_id.c Wed Feb 25 09:55:01 2004
@@ -33,7 +33,6 @@
#include <ctype.h>
#include <sys/stat.h>
#include <sysfs/libsysfs.h>
-
#include "scsi_id_version.h"
#include "scsi_id.h"
@@ -48,11 +47,16 @@
#define TMP_DIR "/tmp"
#define TMP_PREFIX "scsi"
-static const char short_options[] = "bc:d:ef:gip:s:vV";
+/*
+ * XXX Note the 'e' (send output to stderr in all cases), and 'c' (callout)
+ * options are not supported, but other code is still left in place for
+ * now.
+ */
+static const char short_options[] = "bd:f:gip:s:vV";
/*
* Just duplicate per dev options.
*/
-static const char dev_short_options[] = "bc:gp:";
+static const char dev_short_options[] = "bgp:";
char sysfs_mnt_path[SYSFS_PATH_MAX];
@@ -107,55 +111,6 @@ int sysfs_get_attr(const char *devpath,
return sysfs_read_attribute_value(attr_path, value, SYSFS_NAME_LEN);
}
-static int sysfs_get_actual_dev(const char *sysfs_path, char *dev, int len)
-{
- dprintf("%s\n", sysfs_path);
- strncpy(dev, sysfs_path, len);
- strncat(dev, "/device", len);
- if (sysfs_get_link(dev, dev, len)) {
- if (!hotplug_mode)
- log_message(LOG_WARNING, "%s: %s\n", dev,
- strerror(errno));
- return -1;
- }
- return 0;
-}
-
-/*
- * sysfs_is_bus: Given the sysfs_path to a device, return 1 if sysfs_path
- * is on bus, 0 if not on bus, and < 0 on error
- */
-static int sysfs_is_bus(const char *sysfs_path, const char *bus)
-{
- char bus_dev_name[SYSFS_PATH_MAX];
- char bus_id[SYSFS_NAME_LEN];
- struct stat stat_buf;
- ino_t dev_inode;
-
- dprintf("%s\n", sysfs_path);
-
- if (sysfs_get_name_from_path(sysfs_path, bus_id, SYSFS_NAME_LEN))
- return -1;
-
- snprintf(bus_dev_name, MAX_NAME_LEN, "%s/%s/%s/%s/%s", sysfs_mnt_path,
- SYSFS_BUS_NAME, bus, SYSFS_DEVICES_NAME, bus_id);
-
- if (stat(sysfs_path, &stat_buf))
- return -1;
- dev_inode = stat_buf.st_ino;
-
- if (stat(bus_dev_name, &stat_buf)) {
- if (errno = ENOENT)
- return 0;
- else
- return -1;
- }
- if (dev_inode = stat_buf.st_ino)
- return 1;
- else
- return 0;
-}
-
static int get_major_minor(const char *devpath, int *major, int *minor)
{
char dev_value[MAX_ATTR_LEN];
@@ -168,7 +123,7 @@ static int get_major_minor(const char *d
* And if sysfsutils changes, check for ENOENT and handle
* it separately.
*/
- log_message(LOG_DEBUG, "%s could not get dev attribute: %s\n",
+ log_message(LOG_DEBUG, "%s: could not get dev attribute: %s\n",
devpath, strerror(errno));
return -1;
}
@@ -534,7 +489,7 @@ static int set_options(int argc, char **
return 0;
}
-static int per_dev_options(struct sysfs_class_device *scsi_dev, int *good_bad,
+static int per_dev_options(struct sysfs_device *scsi_dev, int *good_bad,
int *page_code, char *callout)
{
int retval;
@@ -628,9 +583,10 @@ static int scsi_id(const char *target_pa
{
int retval;
int dev_type = 0;
- char full_dev_path[MAX_NAME_LEN];
char serial[MAX_SERIAL_LEN];
- struct sysfs_class_device *scsi_dev; /* of scsi_device full_dev_path */
+ struct sysfs_class_device *class_dev; /* of target_path */
+ struct sysfs_class_device *class_dev_parent; /* for partitions */
+ struct sysfs_device *scsi_dev; /* the scsi_device */
int good_dev;
int page_code;
char callout[MAX_NAME_LEN];
@@ -661,20 +617,48 @@ static int scsi_id(const char *target_pa
}
}
- if (sysfs_get_actual_dev(target_path, full_dev_path, MAX_NAME_LEN))
+ class_dev = sysfs_open_class_device_path(target_path);
+ if (!class_dev) {
+ log_message(LOG_WARNING, "open class %s failed: %s\n",
+ target_path, strerror(errno));
+ return 1;
+ }
+ class_dev_parent = sysfs_get_classdev_parent(class_dev);
+ dprintf("class_dev 0x%p; class_dev_parent 0x%p\n", class_dev,
+ class_dev_parent);
+ if (class_dev_parent) {
+ scsi_dev = sysfs_get_classdev_device(class_dev_parent);
+ } else {
+ scsi_dev = sysfs_get_classdev_device(class_dev);
+ }
+
+ /*
+ * The close of scsi_dev will close class_dev or class_dev_parent.
+ */
+
+ /*
+ * We assume we are called after the device is completely ready,
+ * so we don't have to loop here like udev. (And we are usually
+ * called via udev.)
+ */
+ if (!scsi_dev) {
+ /*
+ * errno is not set if we can't find the device link, so
+ * don't print it out here.
+ */
+ log_message(LOG_WARNING, "Cannot find sysfs device associated with %s\n",
+ target_path);
return 1;
+ }
- dprintf("full_dev_path %s\n", full_dev_path);
/*
- * Allow only scsi devices (those that have a matching device
- * under /bus/scsi/devices).
+ * Allow only scsi devices.
*
* Other block devices can support SG IO, but only ide-cd does, so
* for now, don't bother with anything else.
*/
- retval = sysfs_is_bus(full_dev_path, "scsi");
- if (retval = 0) {
+ if (strcmp(scsi_dev->bus, "scsi") != 0) {
if (hotplug_mode)
/*
* Expected in some cases.
@@ -684,14 +668,12 @@ static int scsi_id(const char *target_pa
log_message(LOG_WARNING, "%s is not a scsi device\n",
target_path);
return 1;
- } else if (retval < 0) {
- log_message(LOG_WARNING, "sysfs_is_bus failed: %s\n",
- strerror(errno));
- return 1;
}
/*
* mknod a temp dev to communicate with the device.
+ *
+ * XXX pass down class_dev or class_dev_parent.
*/
if (!dev_specified && create_tmp_dev(target_path, maj_min_dev,
dev_type)) {
@@ -699,13 +681,6 @@ static int scsi_id(const char *target_pa
return 1;
}
- scsi_dev = sysfs_open_class_device_path(full_dev_path);
- if (!scsi_dev) {
- log_message(LOG_WARNING, "open class %s failed: %s\n",
- full_dev_path, strerror(errno));
- return 1;
- }
-
/*
* Get any per device (vendor + model) options from the config
* file.
@@ -718,14 +693,7 @@ static int scsi_id(const char *target_pa
retval = 1;
} else if (callout[0] != '\0') {
/*
- * exec vendor callout, pass it only the "name" to be used
- * for error messages, and the dev to open.
- *
- * This won't work if we need to pass on the original
- * command line (when not hotplug mode) since the option
- * parsing and per dev parsing modify the argv's.
- *
- * XXX Not implemented yet. And not fully tested ;-)
+ * XXX Disabled for now ('c' is not in any options[]).
*/
retval = 1;
} else if (scsi_get_serial(scsi_dev, maj_min_dev, page_code,
@@ -736,14 +704,14 @@ static int scsi_id(const char *target_pa
}
if (!retval) {
if (display_bus_id)
- printf("%s ", scsi_dev->name);
+ printf("%s: ", scsi_dev->name);
printf("%s", serial);
if (!hotplug_mode)
printf("\n");
dprintf("%s\n", serial);
retval = 0;
}
- sysfs_close_class_device(scsi_dev);
+ sysfs_close_device(scsi_dev);
if (!dev_specified)
unlink(maj_min_dev);
diff -uprN -X /home/patman/dontdiff udev-bk/extras/scsi_id/scsi_id.h udev-scsi_id-0.4/extras/scsi_id/scsi_id.h
--- udev-bk/extras/scsi_id/scsi_id.h Tue Feb 17 16:33:28 2004
+++ udev-scsi_id-0.4/extras/scsi_id/scsi_id.h Thu Feb 19 17:05:33 2004
@@ -47,9 +47,9 @@
extern int sysfs_get_attr(const char *devpath, const char *attr, char *value,
size_t bufsize);
-extern int scsi_get_serial (struct sysfs_class_device *scsi_dev,
- const char *devname, int page_code, char *serial,
- int len);
+extern int scsi_get_serial (struct sysfs_device *scsi_dev, const char
+ *devname, int page_code, char *serial, int
+ len);
extern void log_message (int level, const char *format, ...)
__attribute__ ((format (printf, 2, 3)));
diff -uprN -X /home/patman/dontdiff udev-bk/extras/scsi_id/scsi_id_version.h udev-scsi_id-0.4/extras/scsi_id/scsi_id_version.h
--- udev-bk/extras/scsi_id/scsi_id_version.h Tue Feb 24 09:25:17 2004
+++ udev-scsi_id-0.4/extras/scsi_id/scsi_id_version.h Wed Feb 25 14:06:25 2004
@@ -1,3 +1,3 @@
/* This file is auto-generated by the Makefile */
-#define SCSI_ID_VERSION "0.3"
+#define SCSI_ID_VERSION "0.4"
#define SCSI_ID_CONFIG_FILE "/etc/scsi_id.config"
diff -uprN -X /home/patman/dontdiff udev-bk/extras/scsi_id/scsi_serial.c udev-scsi_id-0.4/extras/scsi_id/scsi_serial.c
--- udev-bk/extras/scsi_id/scsi_serial.c Tue Feb 17 16:33:28 2004
+++ udev-scsi_id-0.4/extras/scsi_id/scsi_serial.c Mon Feb 23 16:25:40 2004
@@ -32,7 +32,6 @@
#include <syslog.h>
#include <scsi/sg.h>
#include <sysfs/libsysfs.h>
-
#include "scsi_id.h"
#include "scsi.h"
@@ -71,12 +70,6 @@ static const struct scsi_id_search_value
static const char hex_str[]="0123456789abcdef";
/*
- * XXX maybe move all these to an sg_io.c file.
- *
- * From here ...
- */
-
-/*
* Values returned in the result/status, only the ones used by the code
* are used here.
*/
@@ -160,8 +153,7 @@ static int sg_err_category3(struct sg_io
hp->sbp, hp->sb_len_wr);
}
-static int scsi_dump_sense(struct sysfs_class_device *scsi_dev,
- struct sg_io_hdr *io)
+static int scsi_dump_sense(struct sysfs_device *scsi_dev, struct sg_io_hdr *io)
{
unsigned char *sense_buffer;
int s;
@@ -257,7 +249,7 @@ static int scsi_dump_sense(struct sysfs_
scsi_dev->name, sense_buffer[0],
sense_buffer[2]);
log_message(LOG_WARNING,
- "%s: non-extended sense class %d code 0x%0x ",
+ "%s: non-extended sense class %d code 0x%0x\n",
scsi_dev->name, sense_class, code);
}
@@ -277,7 +269,7 @@ static int scsi_dump_sense(struct sysfs_
return -1;
}
-static int scsi_dump(struct sysfs_class_device *scsi_dev, struct sg_io_hdr *io)
+static int scsi_dump(struct sysfs_device *scsi_dev, struct sg_io_hdr *io)
{
if (!io->status && !io->host_status && !io->msg_status &&
!io->driver_status) {
@@ -298,9 +290,9 @@ static int scsi_dump(struct sysfs_class_
return -1;
}
-static int scsi_inquiry(struct sysfs_class_device *scsi_dev, int fd,
- unsigned char evpd, unsigned char page, unsigned
- char *buf, unsigned int buflen)
+static int scsi_inquiry(struct sysfs_device *scsi_dev, int fd, unsigned
+ char evpd, unsigned char page, unsigned char *buf,
+ unsigned int buflen)
{
unsigned char inq_cmd[INQUIRY_CMDLEN] { INQUIRY_CMD, evpd, page, 0, buflen, 0 };
@@ -332,7 +324,7 @@ resend:
io_hdr.timeout = DEF_TIMEOUT;
if (ioctl(fd, SG_IO, &io_hdr) < 0) {
- log_message(LOG_WARNING, "%s ioctl failed: %s\n",
+ log_message(LOG_WARNING, "%s: ioctl failed: %s\n",
scsi_dev->name, strerror(errno));
return -1;
}
@@ -349,11 +341,6 @@ resend:
retval = scsi_dump(scsi_dev, &io_hdr);
}
- /*
- * XXX where is the length checked? That is, was our request
- * buffer long enough?
- */
-
if (!retval) {
retval = buflen;
memcpy(buf, buffer, retval);
@@ -369,13 +356,7 @@ resend:
return retval;
}
-/*
- * XXX maybe move all these to an sg_io.c file.
- *
- * Ending here.
- */
-
-static int do_scsi_page0_inquiry(struct sysfs_class_device *scsi_dev, int fd,
+static int do_scsi_page0_inquiry(struct sysfs_device *scsi_dev, int fd,
char *buffer, int len)
{
int retval;
@@ -392,7 +373,7 @@ static int do_scsi_page0_inquiry(struct
return 1;
}
if (buffer[3] > len) {
- log_message(LOG_WARNING, "%s: page 0 buffer too long %d",
+ log_message(LOG_WARNING, "%s: page 0 buffer too long %d\n",
scsi_dev->name, buffer[3]);
return 1;
}
@@ -417,7 +398,7 @@ static int do_scsi_page0_inquiry(struct
return 1;
}
if (!strncmp(&buffer[VENDOR_LENGTH], vendor, VENDOR_LENGTH)) {
- log_message(LOG_WARNING, "%s invalid page0 data\n",
+ log_message(LOG_WARNING, "%s: invalid page0 data\n",
scsi_dev->name);
return 1;
}
@@ -429,8 +410,7 @@ static int do_scsi_page0_inquiry(struct
* The caller checks that serial is long enough to include the vendor +
* model.
*/
-static int prepend_vendor_model(struct sysfs_class_device *scsi_dev,
- char *serial)
+static int prepend_vendor_model(struct sysfs_device *scsi_dev, char *serial)
{
char attr[MAX_ATTR_LEN];
int ind;
@@ -477,10 +457,9 @@ static int prepend_vendor_model(struct s
* check_fill_0x83_id - check the page 0x83 id, if OK allocate and fill
* serial number.
**/
-static int check_fill_0x83_id(struct sysfs_class_device *scsi_dev,
- char *page_83,
- const struct scsi_id_search_values *id_search,
- char *serial, int max_len)
+static int check_fill_0x83_id(struct sysfs_device *scsi_dev, char
+ *page_83, const struct scsi_id_search_values
+ *id_search, char *serial, int max_len)
{
int i, j, len;
@@ -565,7 +544,7 @@ static int check_fill_0x83_id(struct sys
return 0;
}
-static int do_scsi_page83_inquiry(struct sysfs_class_device *scsi_dev, int fd,
+static int do_scsi_page83_inquiry(struct sysfs_device *scsi_dev, int fd,
char *serial, int len)
{
int retval;
@@ -622,7 +601,7 @@ static int do_scsi_page83_inquiry(struct
return 1;
}
-static int do_scsi_page80_inquiry(struct sysfs_class_device *scsi_dev, int fd,
+static int do_scsi_page80_inquiry(struct sysfs_device *scsi_dev, int fd,
char *serial, int max_len)
{
int retval;
@@ -662,7 +641,7 @@ static int do_scsi_page80_inquiry(struct
return 0;
}
-int scsi_get_serial (struct sysfs_class_device *scsi_dev, const char *devname,
+int scsi_get_serial (struct sysfs_device *scsi_dev, const char *devname,
int page_code, char *serial, int len)
{
unsigned char page0[256];
@@ -674,9 +653,9 @@ int scsi_get_serial (struct sysfs_class_
}
memset(serial, 0, len);
dprintf("opening %s\n", devname);
- fd = open(devname, O_RDONLY);
+ fd = open(devname, O_RDONLY | O_NONBLOCK);
if (fd < 0) {
- log_message(LOG_WARNING, "%s cannot open %s: %s\n",
+ log_message(LOG_WARNING, "%s: cannot open %s: %s\n",
scsi_dev->name, devname, strerror(errno));
return 1;
}
@@ -698,7 +677,7 @@ int scsi_get_serial (struct sysfs_class_
goto completed;
}
} else if (page_code != 0x00) {
- log_message(LOG_WARNING, "%s unsupported page code 0x%d\n",
+ log_message(LOG_WARNING, "%s: unsupported page code 0x%d\n",
scsi_dev->name, page_code);
return 1;
}
@@ -743,6 +722,7 @@ int scsi_get_serial (struct sysfs_class_
retval = 1;
completed:
if (close(fd) < 0)
- log_message(LOG_WARNING, "close failed: %s", strerror(errno));
+ log_message(LOG_WARNING, "%s: close failed: %s\n",
+ scsi_dev->name, strerror(errno));
return retval;
}
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id\x1356&alloc_id438&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] update udev scsi_id to scsi_id 0.4
2004-01-16 19:48 [PATCH] update udev scsi_id to scsi_id 0.3 Patrick Mansfield
` (2 preceding siblings ...)
2004-02-25 22:46 ` [PATCH] update udev scsi_id to scsi_id 0.4 Patrick Mansfield
@ 2004-02-28 1:01 ` Greg KH
2004-03-01 16:30 ` Patrick Mansfield
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2004-02-28 1:01 UTC (permalink / raw)
To: linux-hotplug
On Wed, Feb 25, 2004 at 02:46:52PM -0800, Patrick Mansfield wrote:
> Hi -
>
> Greg, can you please apply this to your udev tree?
I applied it, but had to cut out the change to your _version.h file as
that shouldn't have been there, right?
thanks,
greg k-h
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id\x1356&alloc_id438&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] update udev scsi_id to scsi_id 0.4
2004-01-16 19:48 [PATCH] update udev scsi_id to scsi_id 0.3 Patrick Mansfield
` (3 preceding siblings ...)
2004-02-28 1:01 ` Greg KH
@ 2004-03-01 16:30 ` Patrick Mansfield
2004-06-23 20:31 ` [PATCH] update udev scsi_id to scsi_id 0.5 Patrick Mansfield
2004-06-26 0:30 ` Greg KH
6 siblings, 0 replies; 8+ messages in thread
From: Patrick Mansfield @ 2004-03-01 16:30 UTC (permalink / raw)
To: linux-hotplug
On Fri, Feb 27, 2004 at 05:01:01PM -0800, Greg KH wrote:
> On Wed, Feb 25, 2004 at 02:46:52PM -0800, Patrick Mansfield wrote:
> > Hi -
> >
> > Greg, can you please apply this to your udev tree?
>
> I applied it, but had to cut out the change to your _version.h file as
> that shouldn't have been there, right?
Yes, thanks for catching that.
-- Patrick Mansfield
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id\x1356&alloc_id438&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] update udev scsi_id to scsi_id 0.5
2004-01-16 19:48 [PATCH] update udev scsi_id to scsi_id 0.3 Patrick Mansfield
` (4 preceding siblings ...)
2004-03-01 16:30 ` Patrick Mansfield
@ 2004-06-23 20:31 ` Patrick Mansfield
2004-06-26 0:30 ` Greg KH
6 siblings, 0 replies; 8+ messages in thread
From: Patrick Mansfield @ 2004-06-23 20:31 UTC (permalink / raw)
To: linux-hotplug
Hi -
Greg can you please apply? Patch against current udev bk.
This patch syncs the scsi_id in the udev tree to version 0.5.
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/ChangeLog udev-bk/extras/scsi_id/ChangeLog
--- udev-bk/extras/orig-scsi_id/ChangeLog Wed Jun 16 14:39:17 2004
+++ udev-bk/extras/scsi_id/ChangeLog Wed Jun 23 11:58:56 2004
@@ -1,3 +1,42 @@
+2004-jun-23:
+ * scsi_id.h: increase MAX_SERIAL_LEN from 128 to 256, as some
+ devices (maybe broken ones) are giving really long id's.
+
+2004-jun-17:
+ * Makefile: Olaf Hering add spotless target (already in udev).
+
+2004-jun-17:
+ * scsi_serial.c: Include linux/compiler.h so we can build with
+ klibc using kernel headers.
+
+2004-may-24:
+ * scsi_id.c: Rename major and minor to maj min to avoid compiler
+ warnings when compiled with -D_GNU_SOURCE.
+
+2004-mar-30:
+ * scsi_id.config: Minor wording changes
+
+2004-mar-30:
+ * scsi_id.h: Don't supply a makedev() when built under klibc.
+
+2004-mar-30:
+ * scsi_id.c: Ken Brush <ken@cgi101.com> Have the command line
+ options override generic options.
+
+2004-mar-05:
+ * scsi_serial.c: Log INQUIRY failure, including the
+ failing page code and vpd values. And add a dprintf() to
+ the scsi_inquiry function.
+
+2004-mar-02:
+ * gen_scsi_id_udev_rules.sh: Per bug report from Atul Sabharwal
+ <atul.sabharwal@intel.com> change to not require that sysfs be
+ in the mount tab (and default to "/sys"), and fix so scsi_id
+ results containing spaces work correctly.
+
+2004-mar-02:
+ * scsi_id.8: Escape '-' with '\-'.
+
2004-feb-25:
* scsi_id.8: Add verbage about usage with udev, and running via
hotplug.
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/Makefile udev-bk/extras/scsi_id/Makefile
--- udev-bk/extras/orig-scsi_id/Makefile Wed Jun 16 14:39:17 2004
+++ udev-bk/extras/scsi_id/Makefile Thu Jun 17 14:46:46 2004
@@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-SCSI_ID_VERSION=0.4
+SCSI_ID_VERSION=0.5
prefix etcdir = ${prefix}/etc
@@ -71,5 +71,6 @@ clean:
rm -f $(PROG) $(OBJS) $(GEN_HEADER)
spotless: clean
+
$(PROG): $(OBJS)
$(LD) $(LDFLAGS) -o $(PROG) $(CRT0) $(OBJS) $(SYSFS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/TODO udev-bk/extras/scsi_id/TODO
--- udev-bk/extras/orig-scsi_id/TODO Wed Jun 16 14:39:17 2004
+++ udev-bk/extras/scsi_id/TODO Mon May 24 14:55:39 2004
@@ -1,6 +1,9 @@
-- Document that config file options override command line options, or fix
- the code. This means a '-b' in the config file disables any -g on the
- command line.
+- Add an option to replace blanks with spaces, so the generated id can be
+ more easily used as a /dev name.
+
+- Add a bus white/black list option. So for example, all scsi devices
+ under USB could easily be blacklisted. This should allow multiple busses
+ to be listed.
- Add code to check that SCSI commands get back enough data for their
intended usage, mainly callers of scsi_inquiry().
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/gen_scsi_id_udev_rules.sh udev-bk/extras/scsi_id/gen_scsi_id_udev_rules.sh
--- udev-bk/extras/orig-scsi_id/gen_scsi_id_udev_rules.sh Wed Jun 16 14:39:17 2004
+++ udev-bk/extras/scsi_id/gen_scsi_id_udev_rules.sh Tue Mar 2 16:35:19 2004
@@ -27,22 +27,12 @@
prefix=disk-
scsi_id=/sbin/scsi_id
-dump_ids()
-{
- cd ${sysfs_dir}/block
- for b in sd*
- do
- echo -n "$b "
- $scsi_id -s /block/$b
- if [ $? != 0 ]
- then
- echo $0 failed for device $b >&2
- exit 1
- fi
- done
-}
-
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 ]
@@ -56,12 +46,17 @@ echo "# Start of autogenerated scsi_id r
echo "# rules to your liking."
echo "#"
first_line=yes
-dump_ids | while read in
+
+#
+cd ${sysfs_dir}/block
+for name in sd*
do
- set $in
- name=$1
- shift
- id="$*"
+ 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
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/release-notes udev-bk/extras/scsi_id/release-notes
--- udev-bk/extras/orig-scsi_id/release-notes Wed Jun 16 14:39:17 2004
+++ udev-bk/extras/scsi_id/release-notes Wed Jun 23 12:14:25 2004
@@ -1,49 +1,42 @@
-Version 0.4 of scsi_id is available at:
+Version 0.5 of scsi_id is available at:
-http://www-124.ibm.com/storageio/scsi_id/scsi_id-0.4.tar.gz
+http://www-124.ibm.com/storageio/scsi_id/scsi_id-0.5.tar.gz
scsi_id is a program to generate a unique identifier for a given SCSI
device.
-It is primarily for use with the udev callout key. It could also be used
-for automatic multi-path configuration or device mapper configuration.
+It is primarily for use with the udev program key, or hotplug scripts that
+want persistent naming of scsi devices. It could also be used for
+automatic multi-path configuration or device mapper configuration.
-Version 0.4 requires:
+Version 0.5 requires:
- Linux kernel 2.6
- libsysfs 0.4.0
Major changes since the last release:
- - Support block device partitions
+ - Ken Brush <ken@cgi101.com> have the command line options
+ override generic options.
- - Added a script to auto-generate udev rules. The script is not
- installed but is part of the tarball.
+ - Fix the gen_scsi_id_udev_rules.sh to handle spaces in the id.
-Detailed changes:
+ - Don't supply a makedev() when built with klibc. Also, the
+ scsi_id supplied makedev() was using the old major/minor method.
- - Add man page verbage about usage with udev, and running via
- hotplug
+ - Include compiler.h so we can build against klibc, as recent sg.h
+ changes need a define for __user.
- - Disable support for -e (all output to stderr) as it cannot be
- used in any useful way, and the -c (device specific callout) as
- the code is incomplete and has no users.
+Other changes:
- - Don't print errno for NULL return from sysfs_get_classdev_device.
+ - Increase the MAX_SERIAL_LEN from 128 to 256, as some (possibly
+ broken devics) are returning very long id's
- - Get rid of dead/leftover code that checked if we are on a scsi
- bus.
+ - Add spotless target (via Olaf Hering's udev patch)
- - ":" consistently in output messages.
+ - minor wording changes in scsi_id.config
- - Add missing new lines for some error messages.
+ - Log INQUIRY failure, including the failing page code and vpd
+ values
- - open O_NONBLOCK so we handle tape drives without tapes loaded.
-
- - Remove hacks based on KLIBC define to get around problems when
- building with udev (udev libsysfs files were rearranged).
-
- - As done in udev code, support partitions via looking for a
- parent of the target path. Uses libsysfs functions to do most of
- the work, and includes changing a lot of variables to be struct
- sysfs_device instead of sysfs_class_device.
+ - Escape '-' with '\-' in the man page.
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/scsi_id.8 udev-bk/extras/scsi_id/scsi_id.8
--- udev-bk/extras/orig-scsi_id/scsi_id.8 Wed Jun 16 14:39:17 2004
+++ udev-bk/extras/scsi_id/scsi_id.8 Tue Mar 2 16:32:42 2004
@@ -12,12 +12,12 @@ all SCSI devices that properly support p
If a result is generated it is sent to standard output, and the program
exits with a zero value. If no identifier is output, the program exits
-with a non-zero value.
+with a non\-zero value.
\fBscsi_id\fP is primarily for use by other utilities such as \fBudev\fP
that require a unique SCSI identifier.
-By default all devices are assume black listed, the \fB-g\fP option must
+By default all devices are assume black listed, the \fB\-g\fP option must
be specified on the command line or in the config file for any useful
behaviour.
@@ -58,18 +58,18 @@ mode, and expects the environment variab
corresponding sysfs device. See section below on usage with \fBudev\fP.
.TP
.BI \-b
-The default behaviour - treat the device as black listed, and do nothing
-unless a white listed device is found in the scsi_id config-file.
+The default behaviour \- treat the device as black listed, and do nothing
+unless a white listed device is found in the scsi_id config\-file.
.TP
.BI \-d "\| device\^"
Instead
of determining and creating a device node based on a sysfs dev
-entry as done for the \fB-s\fP, send SG_IO commands to
+entry as done for the \fB\-s\fP, send SG_IO commands to
\fBdevice\fP, such as \fB/dev/sdc\fP.
.TP
-.BI \-f "\| config-file"
+.BI \-f "\| config\-file"
Read configuration and black/white list entries from
-.B config-file
+.B config\-file
rather than the default
.B /etc/scsi_id.config
file.
@@ -89,9 +89,9 @@ Use SCSI INQUIRY VPD page code 0x80 or 0
query the available VPD pages, and use page 0x83 if found, else page 0x80
if found, else nothing.
.TP
-.BI \-s "\| sysfs-device"
+.BI \-s "\| sysfs\-device"
Generate an id for the
-.B sysfs-device.
+.B sysfs\-device.
The sysfs mount point must not be included. For example, use /block/sd,
not /sys/block/sd.
.TP
@@ -113,7 +113,7 @@ and the results will likely not be as ex
When in this mode, all errors and warnings are sent via syslog.
-To determine the specific value needed in a RESULT key, use the -s option,
+To determine the specific value needed in a RESULT key, use the \-s option,
for example:
.sp
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/scsi_id.c udev-bk/extras/scsi_id/scsi_id.c
--- udev-bk/extras/orig-scsi_id/scsi_id.c Wed Jun 16 14:39:17 2004
+++ udev-bk/extras/scsi_id/scsi_id.c Mon May 24 15:14:32 2004
@@ -111,7 +111,7 @@ int sysfs_get_attr(const char *devpath,
return sysfs_read_attribute_value(attr_path, value, SYSFS_NAME_LEN);
}
-static int get_major_minor(const char *devpath, int *major, int *minor)
+static int get_major_minor(const char *devpath, int *maj, int *min)
{
char dev_value[MAX_ATTR_LEN];
@@ -129,7 +129,7 @@ static int get_major_minor(const char *d
}
dprintf("dev value %s", dev_value); /* dev_value has a trailing \n */
- if (sscanf(dev_value, "%u:%u", major, minor) != 2) {
+ if (sscanf(dev_value, "%u:%u", maj, min) != 2) {
log_message(LOG_WARNING, "%s: invalid dev major/minor\n",
devpath);
return -1;
@@ -140,18 +140,18 @@ static int get_major_minor(const char *d
static int create_tmp_dev(const char *devpath, char *tmpdev, int dev_type)
{
- int major, minor;
+ int maj, min;
dprintf("(%s)\n", devpath);
- if (get_major_minor(devpath, &major, &minor))
+ if (get_major_minor(devpath, &maj, &min))
return -1;
snprintf(tmpdev, MAX_NAME_LEN, "%s/%s-maj%d-min%d-%u",
- TMP_DIR, TMP_PREFIX, major, minor, getpid());
+ TMP_DIR, TMP_PREFIX, maj, min, getpid());
dprintf("tmpdev '%s'\n", tmpdev);
- if (mknod(tmpdev, 0600 | dev_type, makedev(major, minor))) {
+ if (mknod(tmpdev, 0600 | dev_type, makedev(maj, min))) {
log_message(LOG_WARNING, "mknod failed: %s\n", strerror(errno));
return -1;
}
@@ -759,10 +759,6 @@ int main(int argc, char **argv)
strncpy(target_path, sysfs_mnt_path, MAX_NAME_LEN);
strncat(target_path, devpath, MAX_NAME_LEN);
- } else {
- if (set_options(argc, argv, short_options, target_path,
- maj_min_dev) < 0)
- exit(1);
}
/*
@@ -778,6 +774,11 @@ int main(int argc, char **argv)
maj_min_dev) < 0)
exit(1);
free(newargv);
+ }
+ if (!hotplug_mode) {
+ if (set_options(argc, argv, short_options, target_path,
+ maj_min_dev) < 0)
+ exit(1);
}
if (!sys_specified) {
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/scsi_id.config udev-bk/extras/scsi_id/scsi_id.config
--- udev-bk/extras/orig-scsi_id/scsi_id.config Wed Jun 16 14:39:17 2004
+++ udev-bk/extras/scsi_id/scsi_id.config Tue Mar 30 08:22:38 2004
@@ -9,12 +9,12 @@
# INQUIRY product identification field. Per the SCSI INQUIRY, the vendor
# is limited to 8 bytes, model to 16 bytes.
#
-# The first maching line found is used. Short matches match longer ones,
+# The first matching line found is used. Short matches match longer ones,
# if you do not want such a match space fill the extra bytes. If no model
# is specified, only the vendor string need match.
#
-# The "option" line is searched when scsi_id first starts up (for use with
-# hotplug during boot).
+# The "options" line is searched for when scsi_id starts up, and is
+# primarily for use with hotplug.
#
# options=<any scsi_id command line options>
#
@@ -32,12 +32,12 @@ options=-b
#
vendor=someone, model=nicedrive, options=-g
-# If you all the scsi devices are your system support valid id's, remove
-# the -b line above, and mark all devices as good:
+# If you know all the scsi devices on your system support valid id's,
+# remove the options=-b line, and mark all devices as good:
## options=-g
# Then black list any offenders. Missing entries here could be dangerous
-# if you rely on the id for naming or multi-path configuration!
+# if you rely on the id for persistent naming or multi-path configuration.
## vendor=ELBONIA, model=borken, options=-b
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/scsi_id.h udev-bk/extras/scsi_id/scsi_id.h
--- udev-bk/extras/orig-scsi_id/scsi_id.h Wed Jun 16 14:39:17 2004
+++ udev-bk/extras/scsi_id/scsi_id.h Wed Jun 23 11:58:56 2004
@@ -37,7 +37,7 @@
* MAX_SERIAL_LEN: the maximum length of the serial number, including
* added prefixes such as vendor and product (model) strings.
*/
-#define MAX_SERIAL_LEN 128
+#define MAX_SERIAL_LEN 256
/*
* MAX_BUFFER_LEN: maximum buffer size and line length used while reading
@@ -52,10 +52,6 @@ extern int scsi_get_serial (struct sysfs
len);
extern void log_message (int level, const char *format, ...)
__attribute__ ((format (printf, 2, 3)));
-
-#ifdef __KLIBC__
-#define makedev(major, minor) ((major) << 8) | (minor)
-#endif
#ifndef u8
typedef unsigned char u8;
diff -uprN -X /home/patman/dontdiff udev-bk/extras/orig-scsi_id/scsi_serial.c udev-bk/extras/scsi_id/scsi_serial.c
--- udev-bk/extras/orig-scsi_id/scsi_serial.c Wed Jun 16 14:39:17 2004
+++ udev-bk/extras/scsi_id/scsi_serial.c Thu Jun 17 11:29:24 2004
@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
+#include <linux/compiler.h> /* need __user when built via klibc */
#include <scsi/sg.h>
#include <sysfs/libsysfs.h>
#include "scsi_id.h"
@@ -312,6 +313,8 @@ static int scsi_inquiry(struct sysfs_dev
buffer = inq + OFFSET;
resend:
+ dprintf("%s evpd %d, page 0x%x\n", scsi_dev->name, evpd, page);
+
memset(&io_hdr, 0, sizeof(struct sg_io_hdr));
io_hdr.interface_id = 'S';
io_hdr.cmd_len = sizeof(inq_cmd);
@@ -351,6 +354,11 @@ resend:
}
retval = -1;
}
+
+ if (retval < 0)
+ log_message(LOG_WARNING,
+ "%s: Unable to get INQUIRY vpd %d page 0x%x.\n",
+ scsi_dev->name, evpd, page);
free(inq);
return retval;
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] update udev scsi_id to scsi_id 0.5
2004-01-16 19:48 [PATCH] update udev scsi_id to scsi_id 0.3 Patrick Mansfield
` (5 preceding siblings ...)
2004-06-23 20:31 ` [PATCH] update udev scsi_id to scsi_id 0.5 Patrick Mansfield
@ 2004-06-26 0:30 ` Greg KH
6 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2004-06-26 0:30 UTC (permalink / raw)
To: linux-hotplug
On Wed, Jun 23, 2004 at 01:31:39PM -0700, Patrick Mansfield wrote:
> Hi -
>
> Greg can you please apply? Patch against current udev bk.
>
> This patch syncs the scsi_id in the udev tree to version 0.5.
Applied, thanks.
greg k-h
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-06-26 0:30 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-16 19:48 [PATCH] update udev scsi_id to scsi_id 0.3 Patrick Mansfield
2004-01-16 20:10 ` Patrick Mansfield
2004-01-16 22:04 ` Greg KH
2004-02-25 22:46 ` [PATCH] update udev scsi_id to scsi_id 0.4 Patrick Mansfield
2004-02-28 1:01 ` Greg KH
2004-03-01 16:30 ` Patrick Mansfield
2004-06-23 20:31 ` [PATCH] update udev scsi_id to scsi_id 0.5 Patrick Mansfield
2004-06-26 0:30 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.