mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-15 01:34:11 +00:00
Merge pull request #16 from horazont/1.9.1
Make diskio work with /dev/disk/*/* paths
This commit is contained in:
commit
39e2afffdc
@ -98,9 +98,14 @@ const char *dev_name(const char *path)
|
||||
|
||||
#define DEV_NAME(x) \
|
||||
x != NULL && strlen(x) > 5 && strncmp(x, "/dev/", 5) == 0 ? x + 5 : x
|
||||
if ((buflen = readlink(path, buf, 254)) == -1)
|
||||
// realpath is POSIX.1-2008 and does what we need here.
|
||||
char *actualpath = realpath(path, 0);
|
||||
if (actualpath == 0) {
|
||||
return DEV_NAME(path);
|
||||
buf[buflen] = '\0';
|
||||
}
|
||||
strncpy(buf, actualpath, 254);
|
||||
free(actualpath);
|
||||
buf[254] = '\0';
|
||||
return DEV_NAME(buf);
|
||||
#undef DEV_NAME
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ struct diskio_stat *prepare_diskio_stat(const char *s)
|
||||
|
||||
void parse_diskio_arg(struct text_object *obj, const char *arg)
|
||||
{
|
||||
obj->data.opaque = prepare_diskio_stat(arg);
|
||||
obj->data.opaque = prepare_diskio_stat(dev_name(arg));
|
||||
}
|
||||
|
||||
/* dir indicates the direction:
|
||||
|
Loading…
Reference in New Issue
Block a user