aboutsummaryrefslogtreecommitdiffstats
path: root/udev_sysfs.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2007-06-04 11:20:18 +0200
committerKay Sievers <kay.sievers@vrfy.org>2007-06-04 11:20:18 +0200
commitfd80719273b9d58f88fc5d576cdb67a1fd92e2bb (patch)
tree9d33bd65517105fc216fe184555251794b07f24f /udev_sysfs.c
parent96d3d86145124f1c401d1f1aa74c0e3184fd6ddc (diff)
downloadudev-fd80719273b9d58f88fc5d576cdb67a1fd92e2bb.tar.gz
sysfs: skip unknown sysfs directories
Diffstat (limited to 'udev_sysfs.c')
-rw-r--r--udev_sysfs.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/udev_sysfs.c b/udev_sysfs.c
index 6e6f16c1..34ae9ac1 100644
--- a/udev_sysfs.c
+++ b/udev_sysfs.c
@@ -155,9 +155,21 @@ struct sysfs_device *sysfs_device_get(const char *devpath)
int len;
char *pos;
+ /* we handle only these devpathes */
+ if (devpath != NULL &&
+ strncmp(devpath, "/devices/", 9) != 0 &&
+ strncmp(devpath, "/subsystem/", 11) != 0 &&
+ strncmp(devpath, "/module/", 8) != 0 &&
+ strncmp(devpath, "/bus/", 5) != 0 &&
+ strncmp(devpath, "/class/", 7) != 0 &&
+ strncmp(devpath, "/block/", 7) != 0)
+ return NULL;
+
dbg("open '%s'", devpath);
strlcpy(devpath_real, devpath, sizeof(devpath_real));
remove_trailing_chars(devpath_real, '/');
+ if (devpath[0] == '\0' )
+ return NULL;
/* look for device already in cache (we never put an untranslated path in the cache) */
list_for_each_entry(dev_loop, &dev_list, node) {
@@ -275,14 +287,6 @@ struct sysfs_device *sysfs_device_get_parent(struct sysfs_device *dev)
if (dev->parent != NULL)
return dev->parent;
- /* requesting a parent is only valid for these devpathes */
- if ((strncmp(dev->devpath, "/devices/", 9) != 0) &&
- (strncmp(dev->devpath, "/subsystem/", 11) != 0) &&
- (strncmp(dev->devpath, "/bus/", 5) != 0) &&
- (strncmp(dev->devpath, "/class/", 7) != 0) &&
- (strncmp(dev->devpath, "/block/", 7) != 0))
- return NULL;
-
strlcpy(parent_devpath, dev->devpath, sizeof(parent_devpath));
dbg("'%s'", parent_devpath);