diff options
author | kay.sievers@vrfy.org <kay.sievers@vrfy.org> | 2005-02-25 07:40:14 +0100 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 23:39:48 -0700 |
commit | 9fe1a96d88b304af5f3315197800f6b3d16675e1 (patch) | |
tree | 75c7549c463a73342938035599686fb5d2d320b9 /udev_db.c | |
parent | f8a178a35b8dee2ee46a3de298345aa4faa8f41e (diff) |
[PATCH] udevinfo: print devpath -> node relationship for all devices
Diffstat (limited to 'udev_db.c')
-rw-r--r-- | udev_db.c | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -239,3 +239,38 @@ found: return 0; } + +int udev_db_call_foreach(int (*handler_function)(struct udevice *udev)) +{ + struct dirent *ent; + DIR *dir; + char filename[NAME_SIZE]; + struct udevice db_udev; + + dir = opendir(udev_db_path); + if (dir == NULL) { + dbg("unable to udev db '%s'", udev_db_path); + return -1; + } + + while (1) { + ent = readdir(dir); + if (ent == NULL || ent->d_name[0] == '\0') + break; + + if (ent->d_name[0] == '.') + continue; + + snprintf(filename, NAME_SIZE, "%s/%s", udev_db_path, ent->d_name); + filename[NAME_SIZE-1] = '\0'; + + memset(&db_udev, 0x00, sizeof(struct udevice)); + if (parse_db_file(&db_udev, filename) == 0) { + if (handler_function(&db_udev) != 0) + break; + } + } + + closedir(dir); + return 0; +} |