From: Patrick Mansfield <patmans@us.ibm.com>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] update udev scsi_id to scsi_id 0.3
Date: Fri, 16 Jan 2004 19:48:59 +0000 [thread overview]
Message-ID: <20040116114859.A8548@beaverton.ibm.com> (raw)
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
next reply other threads:[~2004-01-16 19:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-16 19:48 Patrick Mansfield [this message]
2004-01-16 20:10 ` [PATCH] update udev scsi_id to scsi_id 0.3 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040116114859.A8548@beaverton.ibm.com \
--to=patmans@us.ibm.com \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).