* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- * $Id$ */
+ */
#include "conky.h"
+#include "logging.h"
+#include "common.h"
+#include "linux.h"
#include <dirent.h>
#include <ctype.h>
#include <errno.h>
} else if (strncmp(buf, "cpu", 3) == 0) {
double delta;
if (isdigit(buf[3])) {
- idx = atoi(&buf[3]);
+ idx = atoi(&buf[3]) + 1;
} else {
idx = 0;
}
char path[128];
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)
return "n/a ";
if (fscanf(fp, "%d\n", &state) != 1) {
return "failed";
}
fclose(fp);
- return state ? "frozen" : "free ";
+ return (state > 0) ? "frozen" : "free ";
}