mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-27 17:18:33 +00:00
fix disk_protect for linux-2.6.27
The path for the sysfs attribute has changed. Also negative values show disabled disk protect, so catch this when interpreting the file's content.
This commit is contained in:
parent
7a6ce89226
commit
5445c8890a
@ -1,3 +1,6 @@
|
|||||||
|
2008-12-14
|
||||||
|
* Fix disk_protect for linux-2.6.27 (and hopefully above)
|
||||||
|
|
||||||
2008-12-09
|
2008-12-09
|
||||||
* Add an option to timed_thread_test() to not wait for the interval period
|
* Add an option to timed_thread_test() to not wait for the interval period
|
||||||
(so that IMAP IDLE works better)
|
(so that IMAP IDLE works better)
|
||||||
|
@ -2337,7 +2337,10 @@ const char *get_disk_protect_queue(const char *disk)
|
|||||||
char path[128];
|
char path[128];
|
||||||
int state;
|
int state;
|
||||||
|
|
||||||
snprintf(path, 127, "/sys/block/%s/queue/protect", disk);
|
snprintf(path, 127, "/sys/block/%s/device/unload_heads", disk);
|
||||||
|
if (access(path, F_OK)) {
|
||||||
|
snprintf(path, 127, "/sys/block/%s/queue/protect", disk);
|
||||||
|
}
|
||||||
if ((fp = fopen(path, "r")) == NULL)
|
if ((fp = fopen(path, "r")) == NULL)
|
||||||
return "n/a ";
|
return "n/a ";
|
||||||
if (fscanf(fp, "%d\n", &state) != 1) {
|
if (fscanf(fp, "%d\n", &state) != 1) {
|
||||||
@ -2345,6 +2348,6 @@ const char *get_disk_protect_queue(const char *disk)
|
|||||||
return "failed";
|
return "failed";
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return state ? "frozen" : "free ";
|
return (state > 0) ? "frozen" : "free ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user