mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-17 10:35:10 +00:00
diskio.cc: Allow 'partuuid' label usage (#598)
* diskio.cc: Allow 'partuuid' label usage * diskio.cc: Merge the if block to strncmp()
This commit is contained in:
parent
3d5e152a8b
commit
6a23cab853
@ -908,9 +908,9 @@
|
||||
<option>(device)</option>
|
||||
</term>
|
||||
<listitem>Displays current disk IO. Device is optional, and
|
||||
takes the form of sda for /dev/sda. A block device label can
|
||||
be specified with label:foo. Individual partitions are also
|
||||
allowed.
|
||||
takes the form of sda for /dev/sda. A block device label can
|
||||
be specified with label:foo and a block device partuuid can
|
||||
be specified with partuuid:40000000-01.
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
|
@ -60,6 +60,7 @@ struct diskio_stat *prepare_diskio_stat(const char *s) {
|
||||
device_s(text_buffer_size.get(*state));
|
||||
struct diskio_stat *cur = &stats;
|
||||
char *rpbuf;
|
||||
char rpbuf2[256];
|
||||
|
||||
if (s == nullptr) {
|
||||
return &stats;
|
||||
@ -68,7 +69,12 @@ struct diskio_stat *prepare_diskio_stat(const char *s) {
|
||||
if (strncmp(s, "label:", 6) == 0) {
|
||||
snprintf(&(device_name[0]), text_buffer_size.get(*state),
|
||||
"/dev/disk/by-label/%s", s + 6);
|
||||
rpbuf = realpath(&(device_name[0]), nullptr);
|
||||
} else if (0 == (strncmp(s, "partuuid:", 9))) {
|
||||
snprintf(&(device_name[0]), text_buffer_size.get(*state),
|
||||
"/dev/disk/by-partuuid/%s", s + 9);
|
||||
rpbuf = realpath(&device_name[0], nullptr);
|
||||
snprintf(rpbuf2, 255, "%s", rpbuf);
|
||||
} else {
|
||||
rpbuf = realpath(s, nullptr);
|
||||
}
|
||||
@ -92,12 +98,18 @@ struct diskio_stat *prepare_diskio_stat(const char *s) {
|
||||
* On Solaris we currently don't use the name of disk's special file so
|
||||
* this test is useless.
|
||||
*/
|
||||
snprintf(&(stat_name[0]), text_buffer_size.get(*state), "/dev/%s",
|
||||
&(device_name[0]));
|
||||
|
||||
if ((stat(&(stat_name[0]), &sb) != 0) || !S_ISBLK(sb.st_mode)) {
|
||||
NORM_ERR("diskio device '%s' does not exist", &device_s[0]);
|
||||
if (strncmp(s, "label:", 6) == 0) {
|
||||
snprintf(&(stat_name[0]), text_buffer_size.get(*state), "/dev/%s",
|
||||
&(device_name[0]));
|
||||
if ((stat(&(stat_name[0]), &sb) != 0) || !S_ISBLK(sb.st_mode)) {
|
||||
NORM_ERR("diskio device '%s' does not exist", &device_s[0]);
|
||||
}
|
||||
} else if ((0 == (strncmp(s, "partuuid:", 9))) &&
|
||||
((stat(rpbuf2, &sb) != 0) || !S_ISBLK(sb.st_mode))) {
|
||||
NORM_ERR("diskio device '%s' does not exist", &device_s[0]);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* lookup existing */
|
||||
|
Loading…
Reference in New Issue
Block a user