chiark / gitweb /
Export ID_WWN_VENDOR_EXTENSION and ID_WWN_WITH_EXTENSION
[elogind.git] / extras / scsi_id / scsi_id.h
index eb9498ab71f0fb35a9b5eaac491c605f1d9a38a0..3b8b236368e50c9461681c73e5ed1529e3af3e98 100644 (file)
@@ -1,37 +1,29 @@
-/*
+/*  -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
  * scsi_id.h
  *
  * General defines and such for scsi_id
  *
  * Copyright (C) IBM Corp. 2003
  *
- *  This library is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Lesser General Public License as
- *  published by the Free Software Foundation; either version 2.1 of the
- *  License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- *  USA
+ *     This program is free software; you can redistribute it and/or modify it
+ *     under the terms of the GNU General Public License as published by the
+ *     Free Software Foundation version 2 of the License.
  */
 
-#define dprintf(format, arg...) \
-       log_message(LOG_DEBUG, "%s: " format, __FUNCTION__ , ## arg)
+#define        MAX_PATH_LEN    512
 
-#define        MAX_NAME_LEN    72
-#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.
  */
-#define        MAX_SERIAL_LEN  128
+#define        MAX_SERIAL_LEN  256
 
 /*
  * MAX_BUFFER_LEN: maximum buffer size and line length used while reading
  */
 #define MAX_BUFFER_LEN 256
 
-static inline char *sysfs_get_attr(struct sysfs_class_device *dev,
-                                   const char *attr)
-{
-       return sysfs_get_value_from_attributes(dev->directory->attributes,
-                                              attr);
-}
-
-extern int scsi_get_serial (struct sysfs_class_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)));
-
-#ifdef __KLIBC__
-#define makedev(major, minor)  ((major) << 8) | (minor)
-#endif
-
-#ifndef u8
-typedef unsigned char u8;
-#endif
+struct scsi_id_device {
+       char vendor[9];
+       char model[17];
+       char revision[5];
+       char type[33];
+       char kernel[64];
+       char serial[MAX_SERIAL_LEN];
+       char serial_short[MAX_SERIAL_LEN];
+       int use_sg;
+
+        /* Always from page 0x80 e.g. 'B3G1P8500RWT' - may not be unique */
+        char unit_serial_number[MAX_SERIAL_LEN];
+
+        /* NULs if not set - otherwise hex encoding using lower-case e.g. '50014ee0016eb572' */
+        char wwn[17];
+
+        /* NULs if not set - otherwise hex encoding using lower-case e.g. '0xe00000d80000' */
+        char wwn_vendor_extension[17];
+};
+
+extern int scsi_std_inquiry(struct udev *udev, struct scsi_id_device *dev_scsi, const char *devname);
+extern int scsi_get_serial (struct udev *udev, struct scsi_id_device *dev_scsi, const char *devname,
+                           int page_code, int len);
+
+/*
+ * Page code values.
+ */
+enum page_code {
+               PAGE_83_PRE_SPC3 = -0x83,
+               PAGE_UNSPECIFIED = 0x00,
+               PAGE_80          = 0x80,
+               PAGE_83          = 0x83,
+};
+