summaryrefslogtreecommitdiff
path: root/usr/sysfs.h
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2008-05-31 23:47:12 -0500
committerMike Christie <michaelc@cs.wisc.edu>2008-05-31 23:47:12 -0500
commit1c7c496a5195668482f34350ac8ccb2003908a04 (patch)
treeec94f6e0e6b7902ed46dd3775046000f4c67c263 /usr/sysfs.h
parent63c247d15a164fd326120887b2a706a8eb132f7d (diff)
downloadopen-iscsi-1c7c496a5195668482f34350ac8ccb2003908a04.tar.gz
Fix sysfs handling of block:sdX and scsi bus changes
This has us use the udev_sysfs code instead of hacking our own. There are two items that need future proofing: 1. handling of iscsi_session class device symlinks 2. scanning opens /sys/class/iscsi_* dir instead of doing a proper search like udev_sysfs.
Diffstat (limited to 'usr/sysfs.h')
-rw-r--r--usr/sysfs.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/usr/sysfs.h b/usr/sysfs.h
new file mode 100644
index 0000000..af25ccc
--- /dev/null
+++ b/usr/sysfs.h
@@ -0,0 +1,53 @@
+/*
+ * This is from udev-121 udev.h
+ *
+ * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (C) 2003-2006 Kay Sievers <kay.sievers@vrfy.org>
+ *
+ * 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.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef _SYSFS_
+#define _SYSFS_
+
+#include "list.h"
+#include "string.h"
+
+#define PATH_SIZE 512
+#define NAME_SIZE 256
+
+struct sysfs_device {
+ struct list_head node; /* for device cache */
+ struct sysfs_device *parent; /* already cached parent*/
+ char devpath[PATH_SIZE];
+ char subsystem[NAME_SIZE]; /* $class, $bus, drivers, module */
+ char kernel[NAME_SIZE]; /* device instance name */
+ char kernel_number[NAME_SIZE];
+ char driver[NAME_SIZE]; /* device driver name */
+};
+
+extern char sysfs_path[PATH_SIZE];
+extern int sysfs_init(void);
+extern void sysfs_cleanup(void);
+extern void sysfs_device_set_values(struct sysfs_device *dev, const char *devpath,
+ const char *subsystem, const char *driver);
+extern struct sysfs_device *sysfs_device_get(const char *devpath);
+extern struct sysfs_device *sysfs_device_get_parent(struct sysfs_device *dev);
+extern struct sysfs_device *sysfs_device_get_parent_with_subsystem(struct sysfs_device *dev, const char *subsystem);
+extern char *sysfs_attr_get_value(const char *devpath, const char *attr_name);
+extern int sysfs_resolve_link(char *path, size_t size);
+extern int sysfs_lookup_devpath_by_subsys_id(char *devpath, size_t len, const char *subsystem, const char *id);
+
+#endif