- char path[UTIL_PATH_SIZE];
- DIR *dir;
- struct dirent *dent;
-
- util_strlcpy(path, udev_get_sys_path(udev), sizeof(path));
- util_strlcat(path, devpath, sizeof(path));
-
- dir = opendir(path);
- if (dir != NULL) {
- for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
- struct stat statbuf;
- char filename[UTIL_PATH_SIZE];
- char *attr_value;
- char value[UTIL_NAME_SIZE];
- size_t len;
-
- if (dent->d_name[0] == '.')
- continue;
-
- if (strcmp(dent->d_name, "uevent") == 0)
- continue;
- if (strcmp(dent->d_name, "dev") == 0)
- continue;
-
- util_strlcpy(filename, path, sizeof(filename));
- util_strlcat(filename, "/", sizeof(filename));
- util_strlcat(filename, dent->d_name, sizeof(filename));
- if (lstat(filename, &statbuf) != 0)
- continue;
- if (S_ISLNK(statbuf.st_mode))
- continue;
-
- attr_value = sysfs_attr_get_value(udev, devpath, dent->d_name);
- if (attr_value == NULL)
- continue;
- len = util_strlcpy(value, attr_value, sizeof(value));
- if(len >= sizeof(value))
- len = sizeof(value) - 1;
- dbg(udev, "attr '%s'='%s'(%zi)\n", dent->d_name, value, len);
-
- /* skip nonprintable attributes */
- while (len && isprint(value[len-1]))
- len--;
- if (len) {
- dbg(udev, "attribute value of '%s' non-printable, skip\n", dent->d_name);
- continue;
- }