X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fhdd_atasmart.c;h=acd4a8f2c4625467c32b651332407fa6c566cd3d;hb=cc35e177d57bc4ee2cc57ae25f130dfc168aa61d;hp=00034b27ee7a77fb1c86835e648ab852c4a6b778;hpb=a38105300e4bdeca47c11cdf5d239f23ad5ae4d3;p=psensor.git diff --git a/src/lib/hdd_atasmart.c b/src/lib/hdd_atasmart.c index 00034b2..acd4a8f 100644 --- a/src/lib/hdd_atasmart.c +++ b/src/lib/hdd_atasmart.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2012 jeanfi@gmail.com + * Copyright (C) 2010-2013 jeanfi@gmail.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -45,9 +45,14 @@ static struct psensor * create_sensor(char *id, char *name, SkDisk *disk, int values_max_length) { struct psensor *s; + int t; + + t = SENSOR_TYPE_ATASMART | SENSOR_TYPE_HDD | SENSOR_TYPE_TEMP; + s = psensor_create(id, strdup(name), - SENSOR_TYPE_HDD_TEMP_ATASMART, + strdup("HDD"), + t, values_max_length); s->disk = disk; @@ -55,8 +60,9 @@ create_sensor(char *id, char *name, SkDisk *disk, int values_max_length) return s; } -/* Performs the same tests than sk_disk_open and outputs the - result. */ +/* + * Performs the same tests than sk_disk_open and outputs the result. + */ static void analyze_disk(const char *dname) { int f; @@ -68,29 +74,38 @@ static void analyze_disk(const char *dname) f = open(dname, O_RDONLY|O_NOCTTY|O_NONBLOCK|O_CLOEXEC); if (f < 0) { - log_debug("Could not open file %s: %s", dname, strerror(errno)); + log_debug("analyze_disk(hdd_atasmart): Could not open file %s: %s", + dname, + strerror(errno)); goto fail; } if (fstat(f, &st) < 0) { - log_debug("fstat fails %s: %s", dname, strerror(errno)); + log_debug("analyze_disk(hdd_atasmart): fstat fails %s: %s", + dname, + strerror(errno)); goto fail; } if (!S_ISBLK(st.st_mode)) { - log_debug("!S_ISBLK fails %s", dname); + log_debug("analyze_disk(hdd_atasmart): !S_ISBLK fails %s", + dname); goto fail; } size = (uint64_t)-1; /* So, it's a block device. Let's make sure the ioctls work */ if (ioctl(f, BLKGETSIZE64, &size) < 0) { - log_debug("ioctl fails %s: %s", dname, strerror(errno)); + log_debug("analyze_disk(hdd_atasmart): ioctl fails %s: %s", + dname, + strerror(errno)); goto fail; } if (size <= 0 || size == (uint64_t) -1) { - log_debug("ioctl wrong size %s: %ld", dname, size); + log_debug("analyze_disk(hdd_atasmart): ioctl wrong size %s: %ld", + dname, + size); goto fail; } @@ -131,7 +146,8 @@ struct psensor **hdd_psensor_list_add(struct psensor **sensors, result = tmp_sensors; } else { - log_err("sk_disk_open %s failure", *tmp); + log_err(_("atasmart: sk_disk_open() failure: %s."), + *tmp); analyze_disk(*tmp); } @@ -153,7 +169,7 @@ void hdd_psensor_list_update(struct psensor **sensors) cur = sensors; while (*cur) { s = *cur; - if (s->type == SENSOR_TYPE_HDD_TEMP_ATASMART) { + if (s->type & SENSOR_TYPE_ATASMART) { ret = sk_disk_smart_read_data(s->disk); if (!ret) {