-#if HAVE_SYSFS
-static char *
-sysfs_get_device_name_for_fd(int fd)
-{
- char *device_name = NULL;
- unsigned int maj, min;
- FILE *f;
- char buf[0x40];
- static const char match[9] = "\nDEVNAME=";
- int expected = 1;
-
- if (dev_node_from_fd(fd, &maj, &min) < 0)
- return NULL;
-
- snprintf(buf, sizeof(buf), "/sys/dev/char/%d:%d/uevent", maj, min);
- if (!(f = fopen(buf, "r")))
- return NULL;
-
- while (expected < sizeof(match)) {
- int c = getc(f);
-
- if (c == EOF) {
- fclose(f);
- return NULL;
- } else if (c == match[expected] )
- expected++;
- else
- expected = 0;
- }
-
- strcpy(buf, "/dev/");
- if (fgets(buf + 5, sizeof(buf) - 5, f)) {
- buf[strcspn(buf, "\n")] = '\0';
- device_name = strdup(buf);
- }
-
- fclose(f);
- return device_name;
-}
-#endif
-