2 * Copyright (C) 2010-2011 jeanfi@gmail.com
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #define _(str) gettext(str)
32 static int filter_sd(const char *p)
34 return strlen(p) == 8 && !strncmp(p, "/dev/sd", 7);
37 static struct psensor *
38 create_sensor(char *id, char *name, int values_max_length)
40 return psensor_create(id,
46 struct psensor **hdd_psensor_list_add(struct psensor **sensors,
47 int values_max_length)
51 struct psensor *sensor, **tmp_sensors, **result;
53 log_debug("hdd_psensor_list_add");
55 paths = dir_list("/dev", filter_sd);
60 log_debug("hdd_psensor_list_add open %s", tmp);
62 if (!sk_disk_open(*tmp, &disk)) {
63 char *id = malloc(strlen("hdd at") + strlen(*tmp) + 1);
67 sensor = create_sensor(id, *tmp, values_max_length);
69 tmp_sensors = psensor_list_add(result, sensor);
71 if (result != sensors)
76 log_err("Failed to open %s", *tmp);
87 void hdd_psensor_list_update(struct psensor **sensors)