- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
/* skip directories */
if (S_ISDIR(statbuf.st_mode))
goto out;
/* skip non-readable files */
if ((statbuf.st_mode & S_IRUSR) == 0)
goto out;
/* read attribute value */
fd = open(path, O_RDONLY);
if (fd < 0) {
dbg(udev_device->udev, "attribute '%s' can not be opened\n", path);
goto out;
}
size = read(fd, value, sizeof(value));
close(fd);
if (size < 0)
goto out;
if (size == sizeof(value))
goto out;
/* got a valid value, store it in cache and return it */
value[size] = '\0';
util_remove_trailing_chars(value, '\n');
dbg(udev_device->udev, "'%s' has attribute value '%s'\n", path, value);
list_entry = udev_list_entry_add(udev_device->udev, &udev_device->sysattr_list, sysattr, value, 0, 0);
val = udev_list_entry_get_value(list_entry);
out:
return val;