When trying to get a device name for an fd using sysfs, it would always fail
as it was expecting key/value pairs to be delimited by '\0', which is not the
case.
Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
unsigned int maj, min;
FILE *f;
char buf[0x40];
- static const char match[9] = "\0DEVNAME=";
+ static const char match[9] = "\nDEVNAME=";
int expected = 1;
if (dev_node_from_fd(fd, &maj, &min) < 0)
}
strcpy(buf, "/dev/");
- if (fgets(buf + 5, sizeof(buf) - 5, f))
+ if (fgets(buf + 5, sizeof(buf) - 5, f)) {
+ buf[strcspn(buf, "\n")] = '\0';
device_name = strdup(buf);
+ }
fclose(f);
return device_name;