}
static int
-path_discover (vector pathvec, struct config * conf, char * devname, int flag)
+path_discover (vector pathvec, struct config * conf,
+ struct udev_device *udevice, int flag)
{
- char path[FILE_NAME_SIZE];
struct path * pp;
+ const char * devname;
+ devname = udev_device_get_sysname(udevice);
if (!devname)
return 0;
if (filter_devnode(conf->blist_devnode, conf->elist_devnode,
- devname) > 0)
+ (char *)devname) > 0)
return 0;
- if(safe_sprintf(path, "%s/block/%s/device", sysfs_path,
- devname)) {
- condlog(0, "path too small");
- return 1;
- }
-
- if (strncmp(devname,"cciss",5) && !filepresent(path)) {
- condlog(4, "path %s not present", path);
- return 0;
- }
-
- pp = find_path_by_dev(pathvec, devname);
-
+ pp = find_path_by_dev(pathvec, (char *)devname);
if (!pp) {
pp = store_pathinfo(pathvec, conf->hwtable,
- devname, flag);
+ (char *)devname, flag);
return (pp ? 0 : 1);
}
return pathinfo(pp, conf->hwtable, flag);
{
struct udev_enumerate *udev_iter;
struct udev_list_entry *entry;
- char *devpath;
- char *devptr;
+ struct udev_device *udevice;
+ const char *devpath;
int r = 0;
udev_iter = udev_enumerate_new(conf->udev);
udev_enumerate_get_list_entry(udev_iter)) {
devpath = udev_list_entry_get_name(entry);
condlog(4, "Discover device %s", devpath);
- devptr = strrchr(devpath, '/');
- if (devptr)
- devptr++;
- else
- devptr = devpath;
-
- r += path_discover(pathvec, conf, devptr, flag);
+ udevice = udev_device_new_from_syspath(conf->udev, devpath);
+ if (!udevice) {
+ condlog(4, "%s: no udev information", devpath);
+ r++;
+ continue;
+ }
+ if(!strncmp(udev_device_get_devtype(udevice), "disk", 4))
+ r += path_discover(pathvec, conf, udevice, flag);
+ udev_device_unref(udevice);
}
udev_enumerate_unref(udev_iter);
condlog(4, "Discovery status %d", r);