File: | rc/./sysdeps/linux.c |
Location: | line 1879, column 2 |
Description: | Value stored to 'charge_full' is never read |
1 | /* GKrellM |
2 | | Copyright (C) 1999-2010 Bill Wilson |
3 | | |
4 | | Author: Bill Wilson billw@gkrellm.net |
5 | | Latest versions might be found at: http://gkrellm.net |
6 | | |
7 | | |
8 | | GKrellM is free software: you can redistribute it and/or modify it |
9 | | under the terms of the GNU General Public License as published by |
10 | | the Free Software Foundation, either version 3 of the License, or |
11 | | (at your option) any later version. |
12 | | |
13 | | GKrellM is distributed in the hope that it will be useful, but WITHOUT |
14 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
15 | | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
16 | | License for more details. |
17 | | |
18 | | You should have received a copy of the GNU General Public License |
19 | | along with this program. If not, see http://www.gnu.org/licenses/ |
20 | | |
21 | | |
22 | | Additional permission under GNU GPL version 3 section 7 |
23 | | |
24 | | If you modify this program, or any covered work, by linking or |
25 | | combining it with the OpenSSL project's OpenSSL library (or a |
26 | | modified version of that library), containing parts covered by |
27 | | the terms of the OpenSSL or SSLeay licenses, you are granted |
28 | | additional permission to convey the resulting work. |
29 | | Corresponding Source for a non-source form of such a combination |
30 | | shall include the source code for the parts of OpenSSL used as well |
31 | | as that of the covered work. |
32 | */ |
33 | |
34 | |
35 | #include <limits.h> |
36 | #include <errno(*__errno_location ()).h> |
37 | #include <locale.h> |
38 | #include <sys/types.h> |
39 | #include <dirent.h> |
40 | #include <string.h> |
41 | |
42 | #include <inttypes.h> |
43 | |
44 | |
45 | static gboolean need_locale_fix, |
46 | have_diskstats, |
47 | have_partition_stats, |
48 | have_sysfs, |
49 | have_sysfs_stats, |
50 | have_sysfs_sensors; |
51 | |
52 | static gchar locale_decimal_point; |
53 | |
54 | |
55 | static gboolean kernel_2_4, |
56 | kernel_2_6; |
57 | |
58 | static gint os_major, |
59 | os_minor, |
60 | os_rev; |
61 | |
62 | static gboolean |
63 | os_release(gint major, gint minor, gint rev) |
64 | { |
65 | if ( os_major > major |
66 | || (os_major == major && os_minor > minor) |
67 | || (os_major == os_major && os_minor == minor && os_rev >= rev) |
68 | ) |
69 | return TRUE(!(0)); |
70 | return FALSE(0); |
71 | } |
72 | |
73 | |
74 | void |
75 | gkrellm_sys_main_init(void) |
76 | { |
77 | FILE *f; |
78 | gchar buf[1024]; |
79 | |
80 | if ((f = fopen("/proc/sys/kernel/osrelease", "r")) != NULL((void*)0)) |
81 | { |
82 | if (fgets(buf, sizeof(buf), f) != NULL((void*)0)) |
83 | sscanf(buf, "%d.%d.%d", &os_major, &os_minor, &os_rev); |
84 | fclose(f); |
85 | kernel_2_4 = os_release(2, 4, 0); |
86 | kernel_2_6 = os_release(2, 6, 0); |
87 | } |
88 | |
89 | /* Various stats are in sysfs since 2.5.47, but it may not be mounted. |
90 | */ |
91 | if ((f = fopen("/proc/mounts", "r")) != NULL((void*)0)) |
92 | { |
93 | while (fgets(buf, sizeof(buf), f) != NULL((void*)0)) |
94 | if (strstr(buf, "sysfs")) |
95 | { |
96 | have_sysfs = TRUE(!(0)); |
97 | break; |
98 | } |
99 | fclose(f); |
100 | } |
101 | } |
102 | |
103 | void |
104 | gkrellm_sys_main_cleanup(void) |
105 | { |
106 | } |
107 | |
108 | |
109 | /* Linux /proc always reports floats with '.' decimal points, but sscanf() |
110 | | for some locales needs commas in place of periods. So, if current |
111 | | locale doesn't use periods, must insert the correct decimal point char. |
112 | */ |
113 | static void |
114 | locale_fix(gchar *buf) |
115 | { |
116 | gchar *s; |
117 | |
118 | for (s = buf; *s; ++s) |
119 | if (*s == '.') |
120 | *s = locale_decimal_point; |
121 | } |
122 | |
123 | |
124 | /* ===================================================================== */ |
125 | /* CPU, disk, and swap monitor interfaces might all get data from /proc/stat |
126 | | (depending on kernel version) so they will share reading of /proc/stat. |
127 | */ |
128 | |
129 | #define PROC_STAT_FILE"/proc/stat" "/proc/stat" |
130 | |
131 | static gint n_cpus; |
132 | static gulong swapin, |
133 | swapout; |
134 | |
135 | /* CPU, and Disk monitors call this in their update routine. |
136 | | Whoever calls it first will read the data for everyone. |
137 | | |
138 | | /proc/stat has cpu entries like: |
139 | | cpu total_user total_nice total_sys total_idle |
140 | | cpu0 cpu0_user cpu0_nice cpu0_sys cpu0_idle |
141 | | ... |
142 | | cpuN cpuN_user cpuN_nice cpuN_sys cpuN_idle |
143 | | where ticks for cpu are jiffies * smp_num_cpus |
144 | | and ticks for cpu[i] are jiffies (1/CLK_TCK) |
145 | */ |
146 | static void |
147 | linux_read_proc_stat(void) |
148 | { |
149 | static FILE *f; |
150 | gint n, i, ncpu; |
151 | gchar *s, buf[1024]; |
152 | gulong rblk[4], wblk[4]; |
153 | guint64 user, nice, sys, idle, iowait; |
154 | static gint data_read_tick = -1; |
155 | |
156 | n = gkrellm_get_timer_ticks(); |
157 | if (data_read_tick == n) |
158 | return; /* Just one read per tick (multiple monitors call this) */ |
159 | |
160 | if (!f && (f = fopen(PROC_STAT_FILE"/proc/stat", "r")) == NULL((void*)0)) |
161 | return; |
162 | |
163 | data_read_tick = n; |
164 | gkrellm_disk_reset_composite(); |
165 | |
166 | ncpu = 0; |
167 | while ((fgets(buf, sizeof(buf), f)) != NULL((void*)0)) |
168 | { |
169 | if (buf[0] == 'c' && buf[1] == 'p') |
170 | { |
171 | n = sscanf(buf, |
172 | "%*s %" PRIu64"l" "u" " %" PRIu64"l" "u" " %" PRIu64"l" "u" " %" PRIu64"l" "u" " %" PRIu64"l" "u", |
173 | &user, &nice, &sys, &idle, &iowait); |
174 | |
175 | if (n == 5) /* iowait is new in kernel 2.5 */ |
176 | idle += iowait; |
177 | |
178 | if (n_cpus > 1) |
179 | { |
180 | if (ncpu == 0) |
181 | gkrellm_cpu_assign_composite_data(user, nice, sys, idle); |
182 | else |
183 | gkrellm_cpu_assign_data(ncpu - 1, user, nice, sys, idle); |
184 | } |
185 | /* If have cpu and cpu0 on single cpu machines, won't use cpu0. |
186 | */ |
187 | else if (ncpu == 0) |
188 | gkrellm_cpu_assign_data(0, user, nice, sys, idle); |
189 | ++ncpu; |
190 | continue; |
191 | } |
192 | if (!kernel_2_6 && !strncmp("swap", buf, 4)(__extension__ (__builtin_constant_p (4) && ((__builtin_constant_p ("swap") && strlen ("swap") < ((size_t) (4))) || ( __builtin_constant_p (buf) && strlen (buf) < ((size_t ) (4)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ("swap") && __builtin_constant_p (buf) && (__s1_len = strlen ("swap"), __s2_len = strlen (buf), (!((size_t)(const void *)(("swap") + 1) - (size_t)(const void *)("swap") == 1) || __s1_len >= 4) && (!((size_t)(const void *)((buf ) + 1) - (size_t)(const void *)(buf) == 1) || __s2_len >= 4 )) ? __builtin_strcmp ("swap", buf) : (__builtin_constant_p ( "swap") && ((size_t)(const void *)(("swap") + 1) - (size_t )(const void *)("swap") == 1) && (__s1_len = strlen ( "swap"), __s1_len < 4) ? (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)( buf) == 1) ? __builtin_strcmp ("swap", buf) : (__extension__ ( { const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("swap"))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "swap"))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "swap"))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("swap" ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( buf) && ((size_t)(const void *)((buf) + 1) - (size_t) (const void *)(buf) == 1) && (__s2_len = strlen (buf) , __s2_len < 4) ? (__builtin_constant_p ("swap") && ((size_t)(const void *)(("swap") + 1) - (size_t)(const void * )("swap") == 1) ? __builtin_strcmp ("swap", buf) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("swap"); int __result = (((const unsigned char *) ( const char *) (buf))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp ("swap", buf)))); }) : strncmp ("swap", buf, 4)))) |
193 | { |
194 | sscanf(buf + 5, "%lu %lu", &swapin, &swapout); |
195 | continue; |
196 | } |
197 | if (buf[0] != 'd') |
198 | continue; |
199 | |
200 | if (!strncmp("disk_rblk", buf, 9)(__extension__ (__builtin_constant_p (9) && ((__builtin_constant_p ("disk_rblk") && strlen ("disk_rblk") < ((size_t) (9))) || (__builtin_constant_p (buf) && strlen (buf) < ((size_t) (9)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p ("disk_rblk") && __builtin_constant_p (buf) && (__s1_len = strlen ("disk_rblk"), __s2_len = strlen (buf), (!((size_t)(const void *)(("disk_rblk") + 1) - (size_t)(const void *)("disk_rblk") == 1) || __s1_len >= 4 ) && (!((size_t)(const void *)((buf) + 1) - (size_t)( const void *)(buf) == 1) || __s2_len >= 4)) ? __builtin_strcmp ("disk_rblk", buf) : (__builtin_constant_p ("disk_rblk") && ((size_t)(const void *)(("disk_rblk") + 1) - (size_t)(const void *)("disk_rblk") == 1) && (__s1_len = strlen ("disk_rblk" ), __s1_len < 4) ? (__builtin_constant_p (buf) && ( (size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf ) == 1) ? __builtin_strcmp ("disk_rblk", buf) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("disk_rblk"))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("disk_rblk"))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("disk_rblk"))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("disk_rblk"))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t )(const void *)(buf) == 1) && (__s2_len = strlen (buf ), __s2_len < 4) ? (__builtin_constant_p ("disk_rblk") && ((size_t)(const void *)(("disk_rblk") + 1) - (size_t)(const void *)("disk_rblk") == 1) ? __builtin_strcmp ("disk_rblk", buf) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("disk_rblk"); int __result = (((const unsigned char *) (const char *) (buf))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp ("disk_rblk", buf)))); }) : strncmp ("disk_rblk", buf, 9)))) |
201 | { |
202 | s = buf + 10; |
203 | for (i = 0; i < 4; ++i) |
204 | rblk[i] = strtoul(s, &s, 0); |
205 | } |
206 | else if (!strncmp("disk_wblk", buf, 9)(__extension__ (__builtin_constant_p (9) && ((__builtin_constant_p ("disk_wblk") && strlen ("disk_wblk") < ((size_t) (9))) || (__builtin_constant_p (buf) && strlen (buf) < ((size_t) (9)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p ("disk_wblk") && __builtin_constant_p (buf) && (__s1_len = strlen ("disk_wblk"), __s2_len = strlen (buf), (!((size_t)(const void *)(("disk_wblk") + 1) - (size_t)(const void *)("disk_wblk") == 1) || __s1_len >= 4 ) && (!((size_t)(const void *)((buf) + 1) - (size_t)( const void *)(buf) == 1) || __s2_len >= 4)) ? __builtin_strcmp ("disk_wblk", buf) : (__builtin_constant_p ("disk_wblk") && ((size_t)(const void *)(("disk_wblk") + 1) - (size_t)(const void *)("disk_wblk") == 1) && (__s1_len = strlen ("disk_wblk" ), __s1_len < 4) ? (__builtin_constant_p (buf) && ( (size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf ) == 1) ? __builtin_strcmp ("disk_wblk", buf) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("disk_wblk"))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("disk_wblk"))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("disk_wblk"))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("disk_wblk"))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t )(const void *)(buf) == 1) && (__s2_len = strlen (buf ), __s2_len < 4) ? (__builtin_constant_p ("disk_wblk") && ((size_t)(const void *)(("disk_wblk") + 1) - (size_t)(const void *)("disk_wblk") == 1) ? __builtin_strcmp ("disk_wblk", buf) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("disk_wblk"); int __result = (((const unsigned char *) (const char *) (buf))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp ("disk_wblk", buf)))); }) : strncmp ("disk_wblk", buf, 9)))) |
207 | { |
208 | s = buf + 10; |
209 | for (i = 0; i < 4; ++ i) |
210 | { |
211 | wblk[i] = strtoul(s, &s, 0); |
212 | gkrellm_disk_assign_data_nth(i, |
213 | 512 * rblk[i], 512 * wblk[i], FALSE(0)); |
214 | } |
215 | } |
216 | else if (!strncmp("disk_io:", buf, 8)(__extension__ (__builtin_constant_p (8) && ((__builtin_constant_p ("disk_io:") && strlen ("disk_io:") < ((size_t) ( 8))) || (__builtin_constant_p (buf) && strlen (buf) < ((size_t) (8)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p ("disk_io:") && __builtin_constant_p (buf) && (__s1_len = strlen ("disk_io:"), __s2_len = strlen (buf), (!((size_t)(const void *)(("disk_io:") + 1) - ( size_t)(const void *)("disk_io:") == 1) || __s1_len >= 4) && (!((size_t)(const void *)((buf) + 1) - (size_t)(const void * )(buf) == 1) || __s2_len >= 4)) ? __builtin_strcmp ("disk_io:" , buf) : (__builtin_constant_p ("disk_io:") && ((size_t )(const void *)(("disk_io:") + 1) - (size_t)(const void *)("disk_io:" ) == 1) && (__s1_len = strlen ("disk_io:"), __s1_len < 4) ? (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1) ? __builtin_strcmp ("disk_io:", buf) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("disk_io:"))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("disk_io:"))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("disk_io:"))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("disk_io:"))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)( buf) == 1) && (__s2_len = strlen (buf), __s2_len < 4) ? (__builtin_constant_p ("disk_io:") && ((size_t) (const void *)(("disk_io:") + 1) - (size_t)(const void *)("disk_io:" ) == 1) ? __builtin_strcmp ("disk_io:", buf) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("disk_io:"); int __result = (((const unsigned char * ) (const char *) (buf))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp ("disk_io:", buf)))); }) : strncmp ("disk_io:", buf, 8)))) /* Kernel 2.4 only */ |
217 | { |
218 | gint major, i_disk; |
219 | gulong rblk, wblk, rb1, rb2, wb1, wb2; |
220 | |
221 | s = strtok(buf + 9, " \t\n"); |
222 | while (s) |
223 | { |
224 | /* disk_io lines in 2.4.x kernels have had 2 formats */ |
225 | n = sscanf(s, "(%d,%d):(%*d,%lu,%lu,%lu,%lu)", |
226 | &major, &i_disk, &rb1, &rb2, &wb1, &wb2); |
227 | if (n == 6) /* patched as of 2.4.0-test1-ac9 */ |
228 | { /* (major,disk):(total_io,rio,rblk,wio,wblk) */ |
229 | rblk = rb2; |
230 | wblk = wb2; |
231 | } |
232 | else /* 2.3.99-pre8 to 2.4.0-testX */ |
233 | { /* (major,disk):(rio,rblk,wio,wblk) */ |
234 | rblk = rb1; |
235 | wblk = wb1; |
236 | } |
237 | /* floppys and CDroms don't show up in /proc/partitions. |
238 | */ |
239 | if (have_partition_stats) |
240 | { |
241 | gchar name[32]; |
242 | |
243 | name[0] = '\0'; |
244 | if (major == 2) |
245 | sprintf(name, "fd%d", i_disk); |
246 | else if (major == 11) |
247 | sprintf(name, "scd%d", i_disk); |
248 | if (name[0]) |
249 | gkrellm_disk_assign_data_by_name(name, |
250 | 512 * rblk, 512 * wblk, FALSE(0)); |
251 | } |
252 | else |
253 | { |
254 | gkrellm_disk_assign_data_by_device(major, i_disk, |
255 | 512 * rblk, 512 * wblk, |
256 | (major == 9) ? TRUE(!(0)) : FALSE(0)); |
257 | } |
258 | s = strtok(NULL((void*)0), " \t\n"); |
259 | } |
260 | } |
261 | } |
262 | rewind(f); |
263 | } |
264 | |
265 | |
266 | /* ===================================================================== */ |
267 | /* CPU monitor interface */ |
268 | |
269 | void |
270 | gkrellm_sys_cpu_read_data(void) |
271 | { |
272 | /* One routine reads cpu, disk, and swap data. All three monitors will |
273 | | call it, but only the first call per timer tick will do the work. |
274 | */ |
275 | linux_read_proc_stat(); |
276 | } |
277 | |
278 | gboolean |
279 | gkrellm_sys_cpu_init(void) |
280 | { |
281 | FILE *f; |
282 | gchar buf[1024]; |
283 | |
284 | if ((f = fopen(PROC_STAT_FILE"/proc/stat", "r")) == NULL((void*)0)) |
285 | return FALSE(0); |
286 | |
287 | while (fgets(buf, sizeof(buf), f)) |
288 | { |
289 | if (strncmp(buf, "cpu", 3)(__extension__ (__builtin_constant_p (3) && ((__builtin_constant_p (buf) && strlen (buf) < ((size_t) (3))) || (__builtin_constant_p ("cpu") && strlen ("cpu") < ((size_t) (3)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (buf) && __builtin_constant_p ("cpu") && (__s1_len = strlen ( buf), __s2_len = strlen ("cpu"), (!((size_t)(const void *)((buf ) + 1) - (size_t)(const void *)(buf) == 1) || __s1_len >= 4 ) && (!((size_t)(const void *)(("cpu") + 1) - (size_t )(const void *)("cpu") == 1) || __s2_len >= 4)) ? __builtin_strcmp (buf, "cpu") : (__builtin_constant_p (buf) && ((size_t )(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1 ) && (__s1_len = strlen (buf), __s1_len < 4) ? (__builtin_constant_p ("cpu") && ((size_t)(const void *)(("cpu") + 1) - (size_t )(const void *)("cpu") == 1) ? __builtin_strcmp (buf, "cpu") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("cpu"); int __result = (((const unsigned char *) (const char *) (buf))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("cpu") && ((size_t)(const void *)(("cpu") + 1) - (size_t )(const void *)("cpu") == 1) && (__s2_len = strlen ("cpu" ), __s2_len < 4) ? (__builtin_constant_p (buf) && ( (size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf ) == 1) ? __builtin_strcmp (buf, "cpu") : (- (__extension__ ( { const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("cpu"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "cpu"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "cpu"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("cpu" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (buf , "cpu")))); }) : strncmp (buf, "cpu", 3))) != 0) |
290 | continue; |
291 | ++n_cpus; |
292 | } |
293 | fclose(f); |
294 | |
295 | /* If multiple CPUs, the first one will be a composite. Report only real. |
296 | */ |
297 | if (n_cpus > 1) |
298 | --n_cpus; |
299 | gkrellm_cpu_set_number_of_cpus(n_cpus); |
300 | return TRUE(!(0)); |
301 | } |
302 | |
303 | |
304 | /* ===================================================================== */ |
305 | /* Disk monitor interface */ |
306 | |
307 | #define PROC_PARTITIONS_FILE"/proc/partitions" "/proc/partitions" |
308 | #define PROC_DISKSTATS_FILE"/proc/diskstats" "/proc/diskstats" |
309 | |
310 | #include <linux1/major.h> |
311 | #if ! defined (SCSI_DISK0_MAJOR8) |
312 | #define SCSI_DISK0_MAJOR8 8 |
313 | #endif |
314 | #if ! defined (MD_MAJOR9) |
315 | #define MD_MAJOR9 9 |
316 | #endif |
317 | #if !defined(DM_MAJOR254) |
318 | #define DM_MAJOR254 254 |
319 | #endif |
320 | |
321 | #if !defined(IDE4_MAJOR56) |
322 | #define IDE4_MAJOR56 56 |
323 | #endif |
324 | #if !defined(IDE5_MAJOR57) |
325 | #define IDE5_MAJOR57 57 |
326 | #endif |
327 | #if !defined(IDE6_MAJOR88) |
328 | #define IDE6_MAJOR88 88 |
329 | #endif |
330 | #if !defined(IDE7_MAJOR89) |
331 | #define IDE7_MAJOR89 89 |
332 | #endif |
333 | #if !defined(IDE8_MAJOR90) |
334 | #define IDE8_MAJOR90 90 |
335 | #endif |
336 | #if !defined(IDE9_MAJOR91) |
337 | #define IDE9_MAJOR91 91 |
338 | #endif |
339 | #if !defined(DAC960_MAJOR48) |
340 | #define DAC960_MAJOR48 48 |
341 | #endif |
342 | #if !defined(COMPAQ_SMART2_MAJOR72) |
343 | #define COMPAQ_SMART2_MAJOR72 72 |
344 | #endif |
345 | #if !defined(COMPAQ_CISS_MAJOR104) |
346 | #define COMPAQ_CISS_MAJOR104 104 |
347 | #endif |
348 | #if !defined(LVM_BLK_MAJOR58) |
349 | #define LVM_BLK_MAJOR58 58 |
350 | #endif |
351 | #if !defined(NBD_MAJOR43) |
352 | #define NBD_MAJOR43 43 |
353 | #endif |
354 | #if !defined(I2O_MAJOR80) |
355 | #define I2O_MAJOR80 80 |
356 | #endif |
357 | |
358 | |
359 | struct _disk_name_map |
360 | { |
361 | gchar *name; |
362 | gint major; |
363 | gint minor_mod; |
364 | gchar suffix_base; |
365 | }; |
366 | |
367 | /* Disk charts will appear in GKrellM in the same order as this table. |
368 | */ |
369 | static struct _disk_name_map |
370 | disk_name_map[] = |
371 | { |
372 | {"hd", IDE0_MAJOR3, 64, 'a' }, /* 3: hda, hdb */ |
373 | {"hd", IDE1_MAJOR22, 64, 'c' }, /* 22: hdc, hdd */ |
374 | {"hd", IDE2_MAJOR33, 64, 'e' }, /* 33: hde, hdf */ |
375 | {"hd", IDE3_MAJOR34, 64, 'g' }, /* 34: hdg, hdh */ |
376 | {"hd", IDE4_MAJOR56, 64, 'i' }, /* 56: hdi, hdj */ |
377 | {"hd", IDE5_MAJOR57, 64, 'k' }, /* 57: hdk, hdl */ |
378 | {"hd", IDE6_MAJOR88, 64, 'm' }, /* 88: hdm, hdn */ |
379 | {"hd", IDE7_MAJOR89, 64, 'o' }, /* 89: hdo, hdp */ |
380 | {"hd", IDE8_MAJOR90, 64, 'q' }, /* 90: hdq, hdr */ |
381 | {"hd", IDE9_MAJOR91, 64, 's' }, /* 91: hds, hdt */ |
382 | {"sd", SCSI_DISK0_MAJOR8, 16, 'a' }, /* 8: sda-sdh */ |
383 | {"sg", SCSI_GENERIC_MAJOR21, 16, '0' }, /* 21: sg0-sg16 */ |
384 | {"scd", SCSI_CDROM_MAJOR11, 16, '0' }, /* 11: scd0-scd16 */ |
385 | {"sr", SCSI_CDROM_MAJOR11, 16, '0' }, /* 11: sr0-sr16 */ |
386 | {"md", MD_MAJOR9, 0, '0' }, /* 9: md0-md3 */ |
387 | {"i2o/hd", I2O_MAJOR80, 16, 'a' }, /* 80: i2o/hd* */ |
388 | |
389 | {"c0d", DAC960_MAJOR48, 32, '0' }, /* 48: c0d0-c0d31 */ |
390 | {"c1d", DAC960_MAJOR48 + 1, 32, '0' }, /* 49: c1d0-c1d31 */ |
391 | {"c2d", DAC960_MAJOR48 + 2, 32, '0' }, /* 50: c2d0-c2d31 */ |
392 | {"c3d", DAC960_MAJOR48 + 3, 32, '0' }, /* 51: c3d0-c3d31 */ |
393 | {"c4d", DAC960_MAJOR48 + 4, 32, '0' }, /* 52: c4d0-c4d31 */ |
394 | {"c5d", DAC960_MAJOR48 + 5, 32, '0' }, /* 53: c5d0-c5d31 */ |
395 | {"c6d", DAC960_MAJOR48 + 6, 32, '0' }, /* 54: c6d0-c6d31 */ |
396 | {"c7d", DAC960_MAJOR48 + 7, 32, '0' }, /* 55: c7d0-c7d31 */ |
397 | |
398 | {"cs0d", COMPAQ_SMART2_MAJOR72, 16, '0' }, /* 72: c0d0-c0d15 */ |
399 | {"cs1d", COMPAQ_SMART2_MAJOR72 + 1, 16, '0' }, /* 73: c1d0-c1d15 */ |
400 | {"cs2d", COMPAQ_SMART2_MAJOR72 + 2, 16, '0' }, /* 74: c2d0-c2d15 */ |
401 | {"cs3d", COMPAQ_SMART2_MAJOR72 + 3, 16, '0' }, /* 75: c3d0-c3d15 */ |
402 | {"cs4d", COMPAQ_SMART2_MAJOR72 + 4, 16, '0' }, /* 76: c4d0-c4d15 */ |
403 | {"cs5d", COMPAQ_SMART2_MAJOR72 + 5, 16, '0' }, /* 77: c5d0-c5d15 */ |
404 | {"cs6d", COMPAQ_SMART2_MAJOR72 + 6, 16, '0' }, /* 78: c6d0-c6d15 */ |
405 | {"cs7d", COMPAQ_SMART2_MAJOR72 + 7, 16, '0' }, /* 79: c7d0-c7d15 */ |
406 | |
407 | {"cc0d", COMPAQ_CISS_MAJOR104, 16, '0' }, /* 104: c0d0-c0d15 */ |
408 | {"cc1d", COMPAQ_CISS_MAJOR104 + 1, 16, '0' }, /* 105: c1d0-c1d15 */ |
409 | {"cc2d", COMPAQ_CISS_MAJOR104 + 2, 16, '0' }, /* 106: c2d0-c2d15 */ |
410 | {"cc3d", COMPAQ_CISS_MAJOR104 + 3, 16, '0' }, /* 107: c3d0-c3d15 */ |
411 | {"cc4d", COMPAQ_CISS_MAJOR104 + 4, 16, '0' }, /* 108: c4d0-c4d15 */ |
412 | {"cc5d", COMPAQ_CISS_MAJOR104 + 5, 16, '0' }, /* 109: c5d0-c5d15 */ |
413 | {"cc6d", COMPAQ_CISS_MAJOR104 + 6, 16, '0' }, /* 110: c6d0-c6d15 */ |
414 | {"cc7d", COMPAQ_CISS_MAJOR104 + 7, 16, '0' }, /* 111: c7d0-c7d15 */ |
415 | {"dm-", DM_MAJOR254, 256, '0' }, /* 254: dm-0 - dm-255 */ |
416 | |
417 | {"fd", FLOPPY_MAJOR2, 0, '0' } /* 2: fd0-fd3 */ |
418 | }; |
419 | |
420 | static gboolean |
421 | disk_major_ok(gint major) |
422 | { |
423 | gint i; |
424 | |
425 | for (i = 0; i < sizeof(disk_name_map) / sizeof(struct _disk_name_map); ++i) |
426 | { |
427 | if (major == disk_name_map[i].major) |
428 | return TRUE(!(0)); |
429 | } |
430 | return FALSE(0); |
431 | } |
432 | |
433 | gchar * |
434 | gkrellm_sys_disk_name_from_device(gint device_number, gint unit_number, |
435 | gint *order) |
436 | { |
437 | struct _disk_name_map *dm = NULL((void*)0); |
438 | gint i; |
439 | gchar suffix; |
440 | static gchar name[32]; |
441 | |
442 | for (i = 0; i < sizeof(disk_name_map) / sizeof(struct _disk_name_map); ++i) |
443 | { |
444 | if (device_number != disk_name_map[i].major) |
445 | continue; |
446 | dm = &disk_name_map[i]; |
447 | break; |
448 | } |
449 | if (dm) |
450 | { |
451 | suffix = dm->suffix_base + unit_number; |
452 | sprintf(name, "%s%c", dm->name, suffix); |
453 | } |
454 | else |
455 | sprintf(name, "(%d,%d)", device_number, unit_number); |
456 | *order = i; |
457 | return name; |
458 | } |
459 | |
460 | gint |
461 | gkrellm_sys_disk_order_from_name(const gchar *name) |
462 | { |
463 | struct _disk_name_map *dm, *dm_next; |
464 | gint i, len, table_size; |
465 | gchar suffix; |
466 | |
467 | table_size = sizeof(disk_name_map) / sizeof(struct _disk_name_map); |
468 | for (i = 0; i < table_size; ++i) |
469 | { |
470 | dm = &disk_name_map[i]; |
471 | len = strlen(dm->name); |
472 | if (strncmp(dm->name, name, len)(__extension__ (__builtin_constant_p (len) && ((__builtin_constant_p (dm->name) && strlen (dm->name) < ((size_t) (len))) || (__builtin_constant_p (name) && strlen (name ) < ((size_t) (len)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (dm->name) && __builtin_constant_p (name) && (__s1_len = strlen (dm->name), __s2_len = strlen (name), (!((size_t)(const void *)((dm->name) + 1 ) - (size_t)(const void *)(dm->name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) || __s2_len >= 4)) ? __builtin_strcmp (dm->name, name) : (__builtin_constant_p (dm->name) && ((size_t)(const void *)((dm->name) + 1) - (size_t)(const void *)(dm->name) == 1) && (__s1_len = strlen (dm-> name), __s1_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) ? __builtin_strcmp (dm->name, name) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) (dm->name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (dm->name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (dm->name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (dm->name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) && (__s2_len = strlen (name ), __s2_len < 4) ? (__builtin_constant_p (dm->name) && ((size_t)(const void *)((dm->name) + 1) - (size_t)(const void *)(dm->name) == 1) ? __builtin_strcmp (dm->name, name) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (dm->name); int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char * ) (const char *) (name))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (dm->name, name)))); }) : strncmp (dm-> name, name, len)))) |
473 | continue; |
474 | suffix = name[len]; /* So far looked at only for "hd" series */ |
475 | if (i < table_size - 1) |
476 | { |
477 | dm_next = &disk_name_map[i + 1]; |
478 | if ( !strcmp(dm_next->name, dm->name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (dm_next->name) && __builtin_constant_p (dm->name ) && (__s1_len = strlen (dm_next->name), __s2_len = strlen (dm->name), (!((size_t)(const void *)((dm_next-> name) + 1) - (size_t)(const void *)(dm_next->name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((dm-> name) + 1) - (size_t)(const void *)(dm->name) == 1) || __s2_len >= 4)) ? __builtin_strcmp (dm_next->name, dm->name) : (__builtin_constant_p (dm_next->name) && ((size_t )(const void *)((dm_next->name) + 1) - (size_t)(const void *)(dm_next->name) == 1) && (__s1_len = strlen (dm_next ->name), __s1_len < 4) ? (__builtin_constant_p (dm-> name) && ((size_t)(const void *)((dm->name) + 1) - (size_t)(const void *)(dm->name) == 1) ? __builtin_strcmp (dm_next->name, dm->name) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (dm-> name); int __result = (((const unsigned char *) (const char * ) (dm_next->name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (dm_next->name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (dm_next->name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (dm_next->name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (dm->name) && ((size_t)(const void *)((dm->name) + 1) - (size_t)(const void *)(dm->name) == 1) && (__s2_len = strlen (dm-> name), __s2_len < 4) ? (__builtin_constant_p (dm_next-> name) && ((size_t)(const void *)((dm_next->name) + 1) - (size_t)(const void *)(dm_next->name) == 1) ? __builtin_strcmp (dm_next->name, dm->name) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (dm_next->name); int __result = (((const unsigned char *) (const char *) (dm->name))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (dm->name))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (dm->name))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (dm->name))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (dm_next->name, dm->name)))) ; }) |
479 | && dm_next->suffix_base <= suffix |
480 | ) |
481 | continue; |
482 | } |
483 | break; |
484 | } |
485 | if (i >= table_size) |
486 | i = -1; |
487 | return i; |
488 | } |
489 | |
490 | /* Given a /proc/partitions or /proc/diskstats line disk name in "partition", |
491 | | make "disk" have the whole disk name (eg hda) and "partition" have the |
492 | | partition (eg hda1) or NULL if not a partition. For simple names, |
493 | | "disk" is expected to initially have the whole disk name from the |
494 | | previous call (or NULL if this is the first call per /proc file parse). |
495 | */ |
496 | static gboolean |
497 | disk_get_device_name(gint major, gint minor, gchar *disk, gchar *partition) |
498 | { |
499 | struct _disk_name_map *dm = NULL((void*)0); |
500 | gint i, unit = 0; |
501 | gchar *p, *d; |
502 | |
503 | for (p = partition; *p; ++p) |
504 | if (*p == '/') |
505 | break; |
506 | if (!*p) |
507 | { /* Have a simple name like hda, hda1, sda, ... */ |
508 | d = disk; |
509 | p = partition; |
510 | while (*d && *p && *d++ == *p++) |
511 | ; |
512 | if (d == disk || *d || *p < '0' || *p > '9') |
513 | { |
514 | strcpy(disk, partition); |
515 | partition[0] = '\0'; |
516 | } |
517 | return TRUE(!(0)); |
518 | } |
519 | |
520 | /* Have a devfs name like ide/host0/bus0/target0/lun0/part1, so construct |
521 | | a name based on major, minor numbers and the disk_name_map[]. |
522 | */ |
523 | for (i = 0; i < sizeof(disk_name_map) / sizeof(struct _disk_name_map); ++i) |
524 | { |
525 | if (major != disk_name_map[i].major) |
526 | continue; |
527 | dm = &disk_name_map[i]; |
528 | if (dm->minor_mod > 0 && minor >= dm->minor_mod) |
529 | { |
530 | unit = minor / dm->minor_mod; |
531 | minor = minor % dm->minor_mod; |
532 | } |
533 | sprintf(disk, "%s%c", dm->name, dm->suffix_base + unit); |
534 | if (minor > 0) |
535 | sprintf(partition, "%s%d", disk, minor); |
536 | else |
537 | partition[0] = '\0'; |
538 | return TRUE(!(0)); |
539 | } |
540 | return FALSE(0); |
541 | } |
542 | |
543 | /* Kernels >= 2.5.69 have /proc/diskstats which can be more efficient to |
544 | | read than getting stats from sysfs. See: |
545 | | /usr/src/linux/Documentation/iostats.txt |
546 | | But gkrellm calls this only for 2.6+ kernels since there were some |
547 | | format incompatible /proc/diskstats patches for 2.4. |
548 | */ |
549 | static void |
550 | linux_read_proc_diskstats(void) |
551 | { |
552 | static FILE *f; |
553 | gchar buf[1024], part[128], disk[128]; |
554 | gint major, minor, n; |
555 | gulong rd, wr, rd1, wr1; |
556 | gboolean inactivity_override, is_MD; |
557 | static gboolean initial_read = TRUE(!(0)); |
558 | |
559 | if (!f && (f = fopen(PROC_DISKSTATS_FILE"/proc/diskstats", "r")) == NULL((void*)0)) |
560 | return; |
561 | |
562 | disk[0] = '\0'; |
563 | part[0] = '\0'; |
564 | |
565 | while ((fgets(buf, sizeof(buf), f)) != NULL((void*)0)) |
566 | { |
567 | /* major minor name rio rmerge rsect ruse wio wmerge wsect wuse |
568 | | running use aveq |
569 | | --or for a partition-- |
570 | | major minor name rio rsect wio wsect |
571 | */ |
572 | n = sscanf(buf, "%d %d %127s %*d %lu %lu %lu %*d %*d %lu", |
573 | &major, &minor, part, &rd, &rd1, &wr, &wr1); |
574 | if (n == 7) |
575 | { |
576 | rd = rd1; |
577 | wr = wr1; |
578 | } |
579 | |
580 | /* Make sure all real disks get reported (so they will be added to the |
581 | | disk monitor in order) the first time this function is called. |
582 | | Use disk_major_ok() instead of simply initial_read until I'm sure |
583 | | I'm testing for all the right "major" exclusions. |
584 | | Note: disk_get_device_name() assumes "part[]" retains results from |
585 | | previous calls and that disk/subdisk parsing will be in order |
586 | | (ie hda will be encountered before hda1). |
587 | */ |
588 | inactivity_override = initial_read ? disk_major_ok(major) : FALSE(0); |
589 | |
590 | if ( (n != 7 && n != 6) |
591 | || (rd == 0 && wr == 0 && !inactivity_override) |
592 | || major == LVM_BLK_MAJOR58 || major == NBD_MAJOR43 |
593 | || major == RAMDISK_MAJOR1 || major == LOOP_MAJOR7 |
594 | || major == DM_MAJOR254 |
595 | || !disk_get_device_name(major, minor, disk, part) |
596 | ) |
597 | continue; |
598 | is_MD = (major == MD_MAJOR9); |
599 | if (part[0] == '\0') |
600 | gkrellm_disk_assign_data_by_name(disk, 512 * rd, 512 * wr, is_MD); |
601 | else |
602 | gkrellm_disk_subdisk_assign_data_by_name(part, disk, |
603 | 512 * rd, 512 * wr); |
604 | } |
605 | rewind(f); |
606 | initial_read = FALSE(0); |
607 | } |
608 | |
609 | /* /proc/partitions can have diskstats in 2.4 kernels or in 2.5+ it's just |
610 | | a list of disk names which can be used to get names to look for in sysfs. |
611 | | But, with gkrellm 2.1.15 and for 2.6+kernels /proc/diskstats is |
612 | | used instead of sysfs. |
613 | */ |
614 | static void |
615 | linux_read_proc_partitions_or_sysfs(void) |
616 | { |
617 | FILE *f, *sf; |
618 | gchar buf[1024], part[128], disk[128], sysfspath[256]; |
619 | gint major, minor, n; |
620 | gulong sectors, rd, wr; |
621 | gboolean is_MD; |
622 | |
623 | if ((f = fopen(PROC_PARTITIONS_FILE"/proc/partitions", "r")) != NULL((void*)0)) |
624 | { |
625 | fgets(buf, sizeof(buf), f); /* header */ |
626 | fgets(buf, sizeof(buf), f); |
627 | disk[0] = '\0'; |
628 | part[0] = '\0'; |
629 | |
630 | while ((fgets(buf, sizeof(buf), f)) != NULL((void*)0)) |
631 | { |
632 | major = 0; |
633 | if (have_partition_stats) |
634 | { |
635 | /* major minor #blocks name |
636 | | rio rmerge rsect ruse wio wmerge wsect wuse running use aveq |
637 | */ |
638 | n = sscanf(buf, "%d %d %lu %127s %*d %*d %lu %*d %*d %*d %lu", |
639 | &major, &minor, §ors, part, &rd, &wr); |
640 | if ( n < 6 || sectors <= 1 || major == LVM_BLK_MAJOR58 |
641 | || !disk_get_device_name(major, minor, disk, part) |
642 | ) |
643 | continue; |
644 | } |
645 | if (have_sysfs_stats) |
646 | { |
647 | n = sscanf(buf, "%d %d %lu %127s", |
648 | &major, &minor, §ors, part); |
649 | if ( n < 4 || sectors <= 1 || major == LVM_BLK_MAJOR58 |
650 | || !disk_get_device_name(major, minor, disk, part) |
651 | ) |
652 | continue; |
653 | if (part[0] == '\0') |
654 | sprintf(sysfspath, "/sys/block/%s/stat", disk); |
655 | else |
656 | sprintf(sysfspath, "/sys/block/%s/%s/stat", disk, part); |
657 | if ((sf = fopen(sysfspath, "r")) != NULL((void*)0)) |
658 | { |
659 | fgets(buf, sizeof(buf), sf); |
660 | fclose(sf); |
661 | if (part[0] == '\0') |
662 | n = sscanf(buf,"%*d %*d %lu %*d %*d %*d %lu",&rd, &wr); |
663 | else |
664 | n = sscanf(buf,"%*d %lu %*d %lu", &rd, &wr); |
665 | if (n < 2) |
666 | continue; |
667 | } |
668 | } |
669 | is_MD = (major == MD_MAJOR9); |
670 | if (part[0] == '\0') |
671 | gkrellm_disk_assign_data_by_name(disk, |
672 | 512 * rd, 512 * wr, is_MD); |
673 | else |
674 | gkrellm_disk_subdisk_assign_data_by_name(part, disk, |
675 | 512 * rd, 512 * wr); |
676 | } |
677 | fclose(f); |
678 | } |
679 | } |
680 | |
681 | void |
682 | gkrellm_sys_disk_read_data(void) |
683 | { |
684 | /* If have_partition_stats, still need to get floppy and CDrom data |
685 | | from /proc/stat |
686 | */ |
687 | if (!have_sysfs_stats && !have_diskstats) |
688 | linux_read_proc_stat(); |
689 | |
690 | if (have_diskstats) |
691 | linux_read_proc_diskstats(); |
692 | else if (have_partition_stats || have_sysfs_stats) |
693 | linux_read_proc_partitions_or_sysfs(); |
694 | } |
695 | |
696 | gboolean |
697 | gkrellm_sys_disk_init(void) |
698 | { |
699 | FILE *f = NULL((void*)0); |
700 | gchar buf[1024]; |
701 | |
702 | /* There were some incompatible /proc/diskstats patches for 2.4 |
703 | */ |
704 | if (os_release(2,6,0) && (f = fopen(PROC_DISKSTATS_FILE"/proc/diskstats", "r")) != NULL((void*)0)) |
705 | have_diskstats = TRUE(!(0)); |
706 | else if ((f = fopen(PROC_PARTITIONS_FILE"/proc/partitions", "r")) != NULL((void*)0)) |
707 | { |
708 | if (fgets(buf, sizeof(buf), f)) |
709 | { |
710 | if (strstr(buf, "rsect")) |
711 | have_partition_stats = TRUE(!(0)); |
712 | else |
713 | { |
714 | if (have_sysfs) |
715 | have_sysfs_stats = TRUE(!(0)); |
716 | } |
717 | } |
718 | } |
719 | if (f) |
720 | fclose(f); |
721 | gkrellm_debug(DEBUG_SYSDEP0x1, |
722 | "diskstats=%d partition_stats=%d sysfs_stats=%d\n", have_diskstats, |
723 | have_partition_stats, have_sysfs_stats); |
724 | |
725 | return TRUE(!(0)); |
726 | } |
727 | |
728 | |
729 | /* ===================================================================== */ |
730 | /* Proc monitor interface */ |
731 | |
732 | #include <utmp.h> |
733 | #include <paths.h> |
734 | |
735 | #define PROC_LOADAVG_FILE"/proc/loadavg" "/proc/loadavg" |
736 | |
737 | void |
738 | gkrellm_sys_proc_read_data(void) |
739 | { |
740 | FILE *f; |
741 | gchar buf[160]; |
742 | gint n_running = 0, n_processes = 0; |
743 | gulong n_forks = 0; |
744 | gfloat fload = 0; |
745 | |
746 | if ((f = fopen(PROC_LOADAVG_FILE"/proc/loadavg", "r")) != NULL((void*)0)) |
747 | { |
748 | /* sscanf(buf, "%f") might fail to convert because for some locales |
749 | | commas are used for decimal points. |
750 | */ |
751 | fgets(buf, sizeof(buf), f); |
752 | if (need_locale_fix) |
753 | locale_fix(buf); |
754 | sscanf(buf,"%f %*f %*f %d/%d %lu", &fload, |
755 | &n_running, &n_processes, &n_forks); |
756 | fclose(f); |
757 | gkrellm_proc_assign_data(n_processes, n_running, n_forks, fload); |
758 | } |
759 | } |
760 | |
761 | void |
762 | gkrellm_sys_proc_read_users(void) |
763 | { |
764 | struct utmp *ut; |
765 | struct stat s; |
766 | static time_t utmp_mtime; |
767 | gint n_users = 0; |
768 | |
769 | if (stat(_PATH_UTMP"/var/run/utmp", &s) == 0 && s.st_mtimest_mtim.tv_sec != utmp_mtime) |
770 | { |
771 | setutent(); |
772 | while ((ut = getutent()) != NULL((void*)0)) |
773 | if (ut->ut_type == USER_PROCESS7 && ut->ut_nameut_user[0] != '\0') |
774 | ++n_users; |
775 | endutent(); |
776 | utmp_mtime = s.st_mtimest_mtim.tv_sec; |
777 | gkrellm_proc_assign_users(n_users); |
778 | } |
779 | } |
780 | |
781 | gboolean |
782 | gkrellm_sys_proc_init(void) |
783 | { |
784 | struct lconv *lc; |
785 | |
786 | lc = localeconv(); |
787 | locale_decimal_point = *lc->decimal_point; |
788 | if (locale_decimal_point != '.') |
789 | need_locale_fix = TRUE(!(0)); |
790 | |
791 | return TRUE(!(0)); |
792 | } |
793 | |
794 | |
795 | /* ===================================================================== */ |
796 | /* Inet monitor interface */ |
797 | |
798 | #include "../inet.h" |
799 | |
800 | #define PROC_NET_TCP_FILE"/proc/net/tcp" "/proc/net/tcp" |
801 | #define PROC_NET_UDP_FILE"/proc/net/udp" "/proc/net/udp" |
802 | #if defined(INET6) |
803 | #define PROC_NET_TCP6_FILE"/proc/net/tcp6" "/proc/net/tcp6" |
804 | #define PROC_NET_UDP6_FILE"/proc/net/udp6" "/proc/net/udp6" |
805 | #endif |
806 | |
807 | static void |
808 | inet_read_data(gchar *fname, gboolean is_udp) |
809 | { |
810 | FILE *f; |
811 | ActiveTCP tcp; |
812 | gchar buf[512]; |
813 | gint tcp_status; |
814 | gulong addr; |
815 | |
816 | if ((f = fopen(fname, "r")) != NULL((void*)0)) |
817 | { |
818 | fgets(buf, sizeof(buf), f); /* header */ |
819 | while (fgets(buf, sizeof(buf), f)) |
820 | { |
821 | sscanf(buf, "%*d: %*x:%x %lx:%x %x", &tcp.local_port, |
822 | &addr, &tcp.remote_port, &tcp_status); |
823 | tcp.remote_addr.s_addr = (uint32_t) addr; |
824 | tcp.family = AF_INET2; |
825 | if (tcp_status != TCP_ALIVE1) |
826 | continue; |
827 | tcp.is_udp = is_udp; |
828 | gkrellm_inet_log_tcp_port_data(&tcp); |
829 | } |
830 | fclose(f); |
831 | } |
832 | } |
833 | |
834 | #if defined(INET6) |
835 | static void |
836 | inet6_read_data(gchar *fname, gboolean is_udp) |
837 | { |
838 | FILE *f; |
839 | ActiveTCP tcp; |
840 | gchar buf[512]; |
841 | gint tcp_status; |
842 | |
843 | if ((f = fopen(fname, "r")) != NULL((void*)0)) |
844 | { |
845 | fgets(buf, sizeof(buf), f); /* header */ |
846 | while (fgets(buf, sizeof(buf), f)) |
847 | { |
848 | sscanf(buf, "%*d: %*x:%x %8x%8x%8x%8x:%x %x", |
849 | &tcp.local_port, |
850 | &tcp.remote_addr6.s6_addr32__in6_u.__u6_addr32[0], |
851 | &tcp.remote_addr6.s6_addr32__in6_u.__u6_addr32[1], |
852 | &tcp.remote_addr6.s6_addr32__in6_u.__u6_addr32[2], |
853 | &tcp.remote_addr6.s6_addr32__in6_u.__u6_addr32[3], |
854 | &tcp.remote_port, &tcp_status); |
855 | tcp.family = AF_INET610; |
856 | if (tcp_status != TCP_ALIVE1) |
857 | continue; |
858 | tcp.is_udp = is_udp; |
859 | gkrellm_inet_log_tcp_port_data(&tcp); |
860 | } |
861 | fclose(f); |
862 | } |
863 | } |
864 | #endif /* INET6 */ |
865 | |
866 | void |
867 | gkrellm_sys_inet_read_tcp_data(void) |
868 | { |
869 | inet_read_data(PROC_NET_TCP_FILE"/proc/net/tcp", FALSE(0)); |
870 | inet_read_data(PROC_NET_UDP_FILE"/proc/net/udp", TRUE(!(0))); |
871 | #if defined(INET6) |
872 | inet6_read_data(PROC_NET_TCP6_FILE"/proc/net/tcp6", FALSE(0)); |
873 | inet6_read_data(PROC_NET_UDP6_FILE"/proc/net/udp6", TRUE(!(0))); |
874 | #endif /* INET6 */ |
875 | } |
876 | |
877 | gboolean |
878 | gkrellm_sys_inet_init(void) |
879 | { |
880 | return TRUE(!(0)); |
881 | } |
882 | |
883 | |
884 | /* ===================================================================== */ |
885 | /* Net monitor interface */ |
886 | |
887 | #define PROC_NET_DEV_FILE"/proc/net/dev" "/proc/net/dev" |
888 | #define PROC_NET_ROUTE_FILE"/proc/net/route" "/proc/net/route" |
889 | #define PROC_NET_IPV6ROUTE_FILE"/proc/net/ipv6_route" "/proc/net/ipv6_route" |
890 | |
891 | typedef struct |
892 | { |
893 | gchar *name; |
894 | gboolean cur_up, |
895 | up; |
896 | } |
897 | NetUp; |
898 | |
899 | static GList *net_routed_list; |
900 | |
901 | static gint rx_bytes_index, |
902 | tx_bytes_index, |
903 | rx_packets_index, |
904 | tx_packets_index; |
905 | |
906 | |
907 | void |
908 | gkrellm_sys_net_check_routes(void) |
909 | { |
910 | static FILE *f=NULL((void*)0); |
911 | static FILE *f6=NULL((void*)0); |
912 | GList *list; |
913 | NetUp *net; |
914 | gchar *s; |
915 | gchar buf[512]; |
916 | gint i; |
917 | |
918 | |
919 | for (list = net_routed_list; list; list = list->next) |
920 | ((NetUp *) list->data)->cur_up = FALSE(0); |
921 | |
922 | if (f || (f = fopen(PROC_NET_ROUTE_FILE"/proc/net/route", "r")) != NULL((void*)0)) |
923 | { |
924 | fgets(buf, sizeof(buf), f); /* Waste the first line */ |
925 | while (fgets(buf, sizeof(buf), f)) |
926 | { |
927 | if ( ((s = strtok(buf, " \t\n")) == NULL((void*)0)) |
928 | || !strncmp(s, "dummy", 5)(__extension__ (__builtin_constant_p (5) && ((__builtin_constant_p (s) && strlen (s) < ((size_t) (5))) || (__builtin_constant_p ("dummy") && strlen ("dummy") < ((size_t) (5)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (s) && __builtin_constant_p ("dummy") && (__s1_len = strlen (s), __s2_len = strlen ("dummy"), (!((size_t)(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("dummy") + 1) - (size_t)(const void *)("dummy") == 1) || __s2_len >= 4) ) ? __builtin_strcmp (s, "dummy") : (__builtin_constant_p (s) && ((size_t)(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) && (__s1_len = strlen (s), __s1_len < 4) ? (__builtin_constant_p ("dummy") && ((size_t )(const void *)(("dummy") + 1) - (size_t)(const void *)("dummy" ) == 1) ? __builtin_strcmp (s, "dummy") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("dummy"); int __result = (((const unsigned char *) (const char *) (s))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( s))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (s) )[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (s))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("dummy" ) && ((size_t)(const void *)(("dummy") + 1) - (size_t )(const void *)("dummy") == 1) && (__s2_len = strlen ( "dummy"), __s2_len < 4) ? (__builtin_constant_p (s) && ((size_t)(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) ? __builtin_strcmp (s, "dummy") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (s); int __result = (((const unsigned char *) (const char *) ("dummy"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "dummy"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "dummy"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("dummy" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (s, "dummy" )))); }) : strncmp (s, "dummy", 5))) |
929 | || (*s == '*' && *(s+1) == '\0') |
930 | ) |
931 | continue; |
932 | for (list = net_routed_list; list; list = list->next) |
933 | { |
934 | net = (NetUp *) list->data; |
935 | if (!strcmp(net->name, s)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (net->name) && __builtin_constant_p (s) && (__s1_len = strlen (net->name), __s2_len = strlen (s), (! ((size_t)(const void *)((net->name) + 1) - (size_t)(const void *)(net->name) == 1) || __s1_len >= 4) && (!((size_t )(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) || __s2_len >= 4)) ? __builtin_strcmp (net->name, s) : (__builtin_constant_p (net->name) && ((size_t)(const void *)((net->name ) + 1) - (size_t)(const void *)(net->name) == 1) && (__s1_len = strlen (net->name), __s1_len < 4) ? (__builtin_constant_p (s) && ((size_t)(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) ? __builtin_strcmp (net->name, s) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (s); int __result = (((const unsigned char *) (const char *) (net->name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (net->name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (net->name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (net->name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (s) && ((size_t)(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) && (__s2_len = strlen (s), __s2_len < 4) ? (__builtin_constant_p (net->name) && (( size_t)(const void *)((net->name) + 1) - (size_t)(const void *)(net->name) == 1) ? __builtin_strcmp (net->name, s) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (net->name); int __result = (((const unsigned char *) (const char *) (s))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (s))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (s))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (s))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (net->name, s)))); })) |
936 | { |
937 | net->cur_up = TRUE(!(0)); |
938 | break; |
939 | } |
940 | } |
941 | if (!list) |
942 | { |
943 | net = g_new0(NetUp, 1)(NetUp *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s = sizeof (NetUp); gpointer __p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) && (__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s); __p ; })); |
944 | net_routed_list = g_list_append(net_routed_list, net); |
945 | net->name = g_strdup(s); |
946 | net->cur_up = TRUE(!(0)); |
947 | } |
948 | } |
949 | rewind(f); |
950 | } |
951 | |
952 | if (f6 || (f6 = fopen(PROC_NET_IPV6ROUTE_FILE"/proc/net/ipv6_route", "r")) != NULL((void*)0)) |
953 | { |
954 | while (fgets(buf, sizeof(buf), f6)) |
955 | { |
956 | if ( strtok(buf, " \t\n") == NULL((void*)0)) continue; /* Extract first field */ |
957 | |
958 | /* Extract the ninth field on the line, i.e., the name of the device */ |
959 | for (i = 1; i <= 9 && (s = strtok(NULL((void*)0), " \t\n")) != NULL((void*)0); i++); |
960 | |
961 | /* If i is not 10, strtok failed prematurely */ |
962 | if (i != 10) continue; |
963 | |
964 | if ( !strncmp(s, "dummy", 5)(__extension__ (__builtin_constant_p (5) && ((__builtin_constant_p (s) && strlen (s) < ((size_t) (5))) || (__builtin_constant_p ("dummy") && strlen ("dummy") < ((size_t) (5)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (s) && __builtin_constant_p ("dummy") && (__s1_len = strlen (s), __s2_len = strlen ("dummy"), (!((size_t)(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("dummy") + 1) - (size_t)(const void *)("dummy") == 1) || __s2_len >= 4) ) ? __builtin_strcmp (s, "dummy") : (__builtin_constant_p (s) && ((size_t)(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) && (__s1_len = strlen (s), __s1_len < 4) ? (__builtin_constant_p ("dummy") && ((size_t )(const void *)(("dummy") + 1) - (size_t)(const void *)("dummy" ) == 1) ? __builtin_strcmp (s, "dummy") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("dummy"); int __result = (((const unsigned char *) (const char *) (s))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( s))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (s) )[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (s))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("dummy" ) && ((size_t)(const void *)(("dummy") + 1) - (size_t )(const void *)("dummy") == 1) && (__s2_len = strlen ( "dummy"), __s2_len < 4) ? (__builtin_constant_p (s) && ((size_t)(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) ? __builtin_strcmp (s, "dummy") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (s); int __result = (((const unsigned char *) (const char *) ("dummy"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "dummy"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "dummy"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("dummy" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (s, "dummy" )))); }) : strncmp (s, "dummy", 5))) |
965 | || (*s == '*' && *(s+1) == '\0') |
966 | ) |
967 | continue; |
968 | for (list = net_routed_list; list; list = list->next) |
969 | { |
970 | net = (NetUp *) list->data; |
971 | if (!strcmp(net->name, s)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (net->name) && __builtin_constant_p (s) && (__s1_len = strlen (net->name), __s2_len = strlen (s), (! ((size_t)(const void *)((net->name) + 1) - (size_t)(const void *)(net->name) == 1) || __s1_len >= 4) && (!((size_t )(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) || __s2_len >= 4)) ? __builtin_strcmp (net->name, s) : (__builtin_constant_p (net->name) && ((size_t)(const void *)((net->name ) + 1) - (size_t)(const void *)(net->name) == 1) && (__s1_len = strlen (net->name), __s1_len < 4) ? (__builtin_constant_p (s) && ((size_t)(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) ? __builtin_strcmp (net->name, s) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (s); int __result = (((const unsigned char *) (const char *) (net->name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (net->name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (net->name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (net->name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (s) && ((size_t)(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) && (__s2_len = strlen (s), __s2_len < 4) ? (__builtin_constant_p (net->name) && (( size_t)(const void *)((net->name) + 1) - (size_t)(const void *)(net->name) == 1) ? __builtin_strcmp (net->name, s) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (net->name); int __result = (((const unsigned char *) (const char *) (s))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (s))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (s))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (s))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (net->name, s)))); })) |
972 | { |
973 | net->cur_up = TRUE(!(0)); |
974 | break; |
975 | } |
976 | } |
977 | if (!list) |
978 | { |
979 | net = g_new0(NetUp, 1)(NetUp *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s = sizeof (NetUp); gpointer __p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) && (__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s); __p ; })); |
980 | net_routed_list = g_list_append(net_routed_list, net); |
981 | net->name = g_strdup(s); |
982 | net->cur_up = TRUE(!(0)); |
983 | } |
984 | } |
985 | rewind(f6); |
986 | } |
987 | |
988 | for (list = net_routed_list; list; list = list->next) |
989 | { |
990 | net = (NetUp *) list->data; |
991 | if (net->up && !net->cur_up) |
992 | gkrellm_net_routed_event(net->name, FALSE(0)); |
993 | else if (!net->up && net->cur_up) |
994 | gkrellm_net_routed_event(net->name, TRUE(!(0))); |
995 | net->up = net->cur_up; |
996 | } |
997 | } |
998 | |
999 | /* I read both the bytes (kernel 2.2.x) and packets (all kernels). Some |
1000 | | net drivers for 2.2.x do not update the bytes counters. |
1001 | */ |
1002 | void |
1003 | gkrellm_sys_net_read_data(void) |
1004 | { |
1005 | static FILE *f; |
1006 | gchar buf[512]; |
1007 | gchar *name, *s, *s1; |
1008 | gint i; |
1009 | gulong rx, tx; |
1010 | gulong rx_packets = 0, |
1011 | tx_packets = 0; |
1012 | guint64 ll; |
1013 | |
1014 | if (!f && (f = fopen(PROC_NET_DEV_FILE"/proc/net/dev", "r")) == NULL((void*)0)) |
1015 | return; |
1016 | fgets(buf, sizeof(buf), f); /* 2 line header */ |
1017 | fgets(buf, sizeof(buf), f); |
1018 | while (fgets(buf, sizeof(buf), f)) |
1019 | { |
1020 | /* Virtual net interfaces have a colon in the name, and a colon seps |
1021 | | the name from data, + might be no space between data and name! |
1022 | | Eg. this is possible -> eth2:0:11249029 0 ... |
1023 | | So, replace the colon that seps data from the name with a space. |
1024 | */ |
1025 | s = strchr(buf, (int) ':')(__extension__ (__builtin_constant_p ((int) ':') && ! __builtin_constant_p (buf) && ((int) ':') == '\0' ? ( char *) __rawmemchr (buf, (int) ':') : __builtin_strchr (buf, (int) ':'))); |
1026 | if (s) |
1027 | { |
1028 | s1 = strchr(s + 1, (int) ':')(__extension__ (__builtin_constant_p ((int) ':') && ! __builtin_constant_p (s + 1) && ((int) ':') == '\0' ? (char *) __rawmemchr (s + 1, (int) ':') : __builtin_strchr ( s + 1, (int) ':'))); |
1029 | if (s1) |
1030 | *s1 = ' '; |
1031 | else |
1032 | *s = ' '; |
1033 | } |
1034 | if ((name = strtok(buf, " \t\n")) == NULL((void*)0)) /* Get name of interface */ |
1035 | { |
1036 | fclose(f); |
1037 | f = NULL((void*)0); |
1038 | return; |
1039 | } |
1040 | if (!strncmp(name, "dummy", 5)(__extension__ (__builtin_constant_p (5) && ((__builtin_constant_p (name) && strlen (name) < ((size_t) (5))) || (__builtin_constant_p ("dummy") && strlen ("dummy") < ((size_t) (5)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("dummy") && ( __s1_len = strlen (name), __s2_len = strlen ("dummy"), (!((size_t )(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) || __s1_len >= 4) && (!((size_t)(const void *) (("dummy") + 1) - (size_t)(const void *)("dummy") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "dummy") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) && (__s1_len = strlen (name ), __s1_len < 4) ? (__builtin_constant_p ("dummy") && ((size_t)(const void *)(("dummy") + 1) - (size_t)(const void *)("dummy") == 1) ? __builtin_strcmp (name, "dummy") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("dummy"); int __result = (((const unsigned char *) ( const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("dummy") && ((size_t)(const void *)(("dummy") + 1) - (size_t)(const void *)("dummy") == 1) && (__s2_len = strlen ("dummy"), __s2_len < 4) ? (__builtin_constant_p ( name) && ((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) ? __builtin_strcmp (name, "dummy" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("dummy"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("dummy"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("dummy"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("dummy"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (name, "dummy")))); }) : strncmp ( name, "dummy", 5)))) |
1041 | continue; |
1042 | rx = tx = 0; |
1043 | for (i = 1; (s = strtok(NULL((void*)0), " \t\n")) != NULL((void*)0); ++i) |
1044 | { |
1045 | if (i == rx_bytes_index) |
1046 | { |
1047 | rx = strtoul(s, NULL((void*)0), 0); |
1048 | |
1049 | /* Can have 32 bit library / 64 bit kernel mismatch. |
1050 | | If so, just using the 32 low bits of a long long is OK. |
1051 | */ |
1052 | if ( rx == ULONG_MAX(9223372036854775807L *2UL+1UL) && errno(*__errno_location ()) == ERANGE34 |
1053 | && sscanf(s, "%" PRIu64"l" "u", &ll) == 1 |
1054 | ) |
1055 | rx = (gulong) ll; |
1056 | } |
1057 | else if (i == tx_bytes_index) |
1058 | { |
1059 | tx = strtoul(s, NULL((void*)0), 0); |
1060 | if ( tx == ULONG_MAX(9223372036854775807L *2UL+1UL) && errno(*__errno_location ()) == ERANGE34 |
1061 | && sscanf(s, "%" PRIu64"l" "u", &ll) == 1 |
1062 | ) |
1063 | tx = (gulong) ll; |
1064 | } |
1065 | else if (i == rx_packets_index) |
1066 | rx_packets = strtoul(s, NULL((void*)0), 0); |
1067 | else if (i == tx_packets_index) |
1068 | tx_packets = strtoul(s, NULL((void*)0), 0); |
1069 | if (i > tx_bytes_index && i > tx_packets_index) |
1070 | break; |
1071 | } |
1072 | if (rx == 0 && tx == 0) |
1073 | { |
1074 | rx = rx_packets; |
1075 | tx = tx_packets; |
1076 | } |
1077 | gkrellm_net_assign_data(name, rx, tx); |
1078 | } |
1079 | rewind(f); |
1080 | } |
1081 | |
1082 | gboolean |
1083 | gkrellm_sys_net_isdn_online(void) |
1084 | { |
1085 | gint f = 0; |
1086 | gchar buffer[BUFSIZ8192], *p, *end; |
1087 | |
1088 | if ( (f = open("/dev/isdninfo", O_RDONLY00)) == -1 |
1089 | && (f = open("/dev/isdn/isdninfo", O_RDONLY00)) == -1 |
1090 | ) |
1091 | { |
1092 | if (_GK.debug_level & DEBUG_NET0x20) |
1093 | g_debug("sys_net_isdn__online: no /dev/isdninfo?\n"); |
1094 | return FALSE(0); |
1095 | } |
1096 | memset(buffer, 0, BUFSIZ8192); |
1097 | |
1098 | if (read(f, buffer, BUFSIZ8192) <= 0) |
1099 | { |
1100 | close(f); |
1101 | return FALSE(0); |
1102 | } |
1103 | close(f); |
1104 | |
1105 | if ((p = strstr(buffer, "flags:")) == NULL((void*)0)) |
1106 | return FALSE(0); |
1107 | |
1108 | for(p += 6; *p; ) |
1109 | { |
1110 | if (isspace(*p)((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short int) _ISspace)) |
1111 | { |
1112 | p++; |
1113 | continue; |
1114 | } |
1115 | for (end = p; *end && !isspace(*end)((*__ctype_b_loc ())[(int) ((*end))] & (unsigned short int ) _ISspace); end++) |
1116 | ; |
1117 | if (*end == '\0' || *end == '\t') |
1118 | break; |
1119 | else |
1120 | *end = 0; |
1121 | if (!strcmp(p, "?")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (p) && __builtin_constant_p ("?") && (__s1_len = strlen (p), __s2_len = strlen ("?"), (!((size_t)(const void *)((p) + 1) - (size_t)(const void *)(p) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("?") + 1) - (size_t )(const void *)("?") == 1) || __s2_len >= 4)) ? __builtin_strcmp (p, "?") : (__builtin_constant_p (p) && ((size_t)(const void *)((p) + 1) - (size_t)(const void *)(p) == 1) && (__s1_len = strlen (p), __s1_len < 4) ? (__builtin_constant_p ("?") && ((size_t)(const void *)(("?") + 1) - (size_t )(const void *)("?") == 1) ? __builtin_strcmp (p, "?") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("?"); int __result = (((const unsigned char *) (const char *) (p))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( p))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (p) )[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (p))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("?") && ((size_t)(const void *)(("?") + 1) - (size_t)(const void *)("?") == 1) && (__s2_len = strlen ("?"), __s2_len < 4) ? (__builtin_constant_p (p) && ((size_t)(const void *)((p) + 1) - (size_t)(const void *)(p) == 1) ? __builtin_strcmp (p, "?") : (- (__extension__ ({ const unsigned char *__s2 = ( const unsigned char *) (const char *) (p); int __result = ((( const unsigned char *) (const char *) ("?"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("?"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("?"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("?"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (p, "?")))); }) || !strcmp(p, "0")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (p) && __builtin_constant_p ("0") && (__s1_len = strlen (p), __s2_len = strlen ("0"), (!((size_t)(const void *)((p) + 1) - (size_t)(const void *)(p) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("0") + 1) - (size_t )(const void *)("0") == 1) || __s2_len >= 4)) ? __builtin_strcmp (p, "0") : (__builtin_constant_p (p) && ((size_t)(const void *)((p) + 1) - (size_t)(const void *)(p) == 1) && (__s1_len = strlen (p), __s1_len < 4) ? (__builtin_constant_p ("0") && ((size_t)(const void *)(("0") + 1) - (size_t )(const void *)("0") == 1) ? __builtin_strcmp (p, "0") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("0"); int __result = (((const unsigned char *) (const char *) (p))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( p))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (p) )[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (p))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("0") && ((size_t)(const void *)(("0") + 1) - (size_t)(const void *)("0") == 1) && (__s2_len = strlen ("0"), __s2_len < 4) ? (__builtin_constant_p (p) && ((size_t)(const void *)((p) + 1) - (size_t)(const void *)(p) == 1) ? __builtin_strcmp (p, "0") : (- (__extension__ ({ const unsigned char *__s2 = ( const unsigned char *) (const char *) (p); int __result = ((( const unsigned char *) (const char *) ("0"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("0"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("0"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("0"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (p, "0")))); })) |
1122 | { |
1123 | p = end+1; |
1124 | continue; |
1125 | } |
1126 | return TRUE(!(0)); /* ISDN is online */ |
1127 | } |
1128 | return FALSE(0); /* ISDN is off line */ |
1129 | } |
1130 | |
1131 | static const char *delim = " :|\t\n"; |
1132 | |
1133 | static void |
1134 | get_io_indices(void) |
1135 | { |
1136 | FILE *f; |
1137 | gchar *s; |
1138 | gchar buf[184]; |
1139 | gint i; |
1140 | |
1141 | if ((f = fopen(PROC_NET_DEV_FILE"/proc/net/dev", "r"))) |
1142 | { |
1143 | fgets(buf, sizeof(buf), f); /* Waste the first line. */ |
1144 | fgets(buf, sizeof(buf), f); /* Look for "units" in this line */ |
1145 | s = strtok(buf, delim); |
1146 | for (i = 0; s; ++i) |
1147 | { |
1148 | if (strcmp(s, "bytes")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (s) && __builtin_constant_p ("bytes") && (__s1_len = strlen (s), __s2_len = strlen ("bytes"), (!((size_t)(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("bytes") + 1) - (size_t)(const void *)("bytes") == 1) || __s2_len >= 4) ) ? __builtin_strcmp (s, "bytes") : (__builtin_constant_p (s) && ((size_t)(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) && (__s1_len = strlen (s), __s1_len < 4) ? (__builtin_constant_p ("bytes") && ((size_t )(const void *)(("bytes") + 1) - (size_t)(const void *)("bytes" ) == 1) ? __builtin_strcmp (s, "bytes") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("bytes"); int __result = (((const unsigned char *) (const char *) (s))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( s))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (s) )[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (s))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("bytes" ) && ((size_t)(const void *)(("bytes") + 1) - (size_t )(const void *)("bytes") == 1) && (__s2_len = strlen ( "bytes"), __s2_len < 4) ? (__builtin_constant_p (s) && ((size_t)(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) ? __builtin_strcmp (s, "bytes") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (s); int __result = (((const unsigned char *) (const char *) ("bytes"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "bytes"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "bytes"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("bytes" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (s, "bytes" )))); }) == 0) |
1149 | { |
1150 | if (rx_bytes_index == 0) |
1151 | rx_bytes_index = i; |
1152 | else |
1153 | tx_bytes_index = i; |
1154 | } |
1155 | if (strcmp(s, "packets")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (s) && __builtin_constant_p ("packets") && ( __s1_len = strlen (s), __s2_len = strlen ("packets"), (!((size_t )(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("packets" ) + 1) - (size_t)(const void *)("packets") == 1) || __s2_len >= 4)) ? __builtin_strcmp (s, "packets") : (__builtin_constant_p (s) && ((size_t)(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) && (__s1_len = strlen (s), __s1_len < 4) ? (__builtin_constant_p ("packets") && ((size_t )(const void *)(("packets") + 1) - (size_t)(const void *)("packets" ) == 1) ? __builtin_strcmp (s, "packets") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("packets"); int __result = (((const unsigned char *) (const char *) (s))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( s))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (s) )[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (s))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("packets" ) && ((size_t)(const void *)(("packets") + 1) - (size_t )(const void *)("packets") == 1) && (__s2_len = strlen ("packets"), __s2_len < 4) ? (__builtin_constant_p (s) && ((size_t)(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) ? __builtin_strcmp (s, "packets") : (- (__extension__ ( { const unsigned char *__s2 = (const unsigned char *) (const char *) (s); int __result = (((const unsigned char *) (const char *) ("packets"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("packets"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("packets"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("packets"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (s, "packets")))); }) == 0) |
1156 | { |
1157 | if (rx_packets_index == 0) |
1158 | rx_packets_index = i; |
1159 | else |
1160 | tx_packets_index = i; |
1161 | } |
1162 | s = strtok(NULL((void*)0), delim); |
1163 | } |
1164 | fclose(f); |
1165 | } |
1166 | if (_GK.debug_level & DEBUG_NET0x20) |
1167 | g_debug("rx_bytes=%d tx_bytes=%d rx_packets=%d tx_packets=%d\n", |
1168 | rx_bytes_index, tx_bytes_index, |
1169 | rx_packets_index, tx_packets_index); |
1170 | } |
1171 | |
1172 | gboolean |
1173 | gkrellm_sys_net_init(void) |
1174 | { |
1175 | get_io_indices(); |
1176 | gkrellm_net_set_lock_directory("/var/lock"); |
1177 | gkrellm_net_add_timer_type_ppp("ppp0"); |
1178 | gkrellm_net_add_timer_type_ippp("ippp0"); |
1179 | gkrellm_net_use_routed(TRUE(!(0)) /* Always TRUE from sysdep code */); |
1180 | return TRUE(!(0)); |
1181 | } |
1182 | |
1183 | |
1184 | /* ===================================================================== */ |
1185 | /* Memory/Swap monitor interface */ |
1186 | |
1187 | #define PROC_MEMINFO_FILE"/proc/meminfo" "/proc/meminfo" |
1188 | #define PROC_VMSTAT_FILE"/proc/vmstat" "/proc/vmstat" |
1189 | |
1190 | static guint64 swap_total, swap_used; |
1191 | |
1192 | /* Kernels >= 2.5.x have tagged formats only in kb units. |
1193 | */ |
1194 | static void |
1195 | tagged_format_meminfo(gchar *buf, guint64 *mint) |
1196 | { |
1197 | sscanf(buf,"%" PRIu64"l" "u", mint); |
1198 | *mint *= 1024; |
1199 | } |
1200 | |
1201 | void |
1202 | gkrellm_sys_mem_read_data(void) |
1203 | { |
1204 | FILE *f; |
1205 | gchar buf[160]; |
1206 | gboolean using_tagged = FALSE(0); |
1207 | guint64 total, used, x_used, free, shared, buffers, cached, slab; |
1208 | |
1209 | /* Default 0, so we don't get arbitrary values if not found, |
1210 | | e.g. MemShared is not present in 2.6. |
1211 | */ |
1212 | total = used = x_used = free = shared = buffers = cached = slab = 0LL; |
1213 | |
1214 | if ((f = fopen(PROC_MEMINFO_FILE"/proc/meminfo", "r")) == NULL((void*)0)) |
1215 | return; |
1216 | while ((fgets(buf, sizeof(buf), f)) != NULL((void*)0)) |
1217 | { |
1218 | if (buf[0] == 'M') |
1219 | { |
1220 | if (!strncmp(buf, "Mem:", 4)(__extension__ (__builtin_constant_p (4) && ((__builtin_constant_p (buf) && strlen (buf) < ((size_t) (4))) || (__builtin_constant_p ("Mem:") && strlen ("Mem:") < ((size_t) (4)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (buf) && __builtin_constant_p ("Mem:") && (__s1_len = strlen ( buf), __s2_len = strlen ("Mem:"), (!((size_t)(const void *)(( buf) + 1) - (size_t)(const void *)(buf) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("Mem:") + 1) - (size_t )(const void *)("Mem:") == 1) || __s2_len >= 4)) ? __builtin_strcmp (buf, "Mem:") : (__builtin_constant_p (buf) && ((size_t )(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1 ) && (__s1_len = strlen (buf), __s1_len < 4) ? (__builtin_constant_p ("Mem:") && ((size_t)(const void *)(("Mem:") + 1) - ( size_t)(const void *)("Mem:") == 1) ? __builtin_strcmp (buf, "Mem:" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("Mem:"); int __result = (((const unsigned char *) (const char *) (buf))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("Mem:") && ((size_t)(const void *)(("Mem:") + 1) - ( size_t)(const void *)("Mem:") == 1) && (__s2_len = strlen ("Mem:"), __s2_len < 4) ? (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)( buf) == 1) ? __builtin_strcmp (buf, "Mem:") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("Mem:"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("Mem:"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("Mem:"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("Mem:"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (buf, "Mem:")))); }) : strncmp (buf, "Mem:", 4)))) |
1221 | sscanf(buf + 5, |
1222 | "%" PRIu64"l" "u" " %" PRIu64"l" "u" " %" PRIu64"l" "u" " %" PRIu64"l" "u" " %" PRIu64"l" "u" " %" PRIu64"l" "u", |
1223 | &total, &x_used, &free, |
1224 | &shared, &buffers, &cached); |
1225 | else if (!strncmp(buf, "MemTotal:", 9)(__extension__ (__builtin_constant_p (9) && ((__builtin_constant_p (buf) && strlen (buf) < ((size_t) (9))) || (__builtin_constant_p ("MemTotal:") && strlen ("MemTotal:") < ((size_t) (9)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (buf) && __builtin_constant_p ("MemTotal:") && (__s1_len = strlen (buf), __s2_len = strlen ("MemTotal:"), ( !((size_t)(const void *)((buf) + 1) - (size_t)(const void *)( buf) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("MemTotal:") + 1) - (size_t)(const void *)("MemTotal:") == 1) || __s2_len >= 4)) ? __builtin_strcmp (buf, "MemTotal:" ) : (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1) && (__s1_len = strlen (buf), __s1_len < 4) ? (__builtin_constant_p ("MemTotal:") && ((size_t)(const void *)(("MemTotal:" ) + 1) - (size_t)(const void *)("MemTotal:") == 1) ? __builtin_strcmp (buf, "MemTotal:") : (__extension__ ({ const unsigned char * __s2 = (const unsigned char *) (const char *) ("MemTotal:"); int __result = (((const unsigned char *) (const char *) (buf))[0 ] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1 ] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2 ] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[ 3]); } } __result; }))) : (__builtin_constant_p ("MemTotal:") && ((size_t)(const void *)(("MemTotal:") + 1) - (size_t )(const void *)("MemTotal:") == 1) && (__s2_len = strlen ("MemTotal:"), __s2_len < 4) ? (__builtin_constant_p (buf ) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1) ? __builtin_strcmp (buf, "MemTotal:") : ( - (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("MemTotal:"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("MemTotal:"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("MemTotal:"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("MemTotal:"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (buf, "MemTotal:")))); }) : strncmp (buf, "MemTotal:", 9)))) |
1226 | { |
1227 | tagged_format_meminfo(buf + 10, &total); |
1228 | using_tagged = TRUE(!(0)); |
1229 | } |
1230 | else if (!strncmp(buf, "MemFree:", 8)(__extension__ (__builtin_constant_p (8) && ((__builtin_constant_p (buf) && strlen (buf) < ((size_t) (8))) || (__builtin_constant_p ("MemFree:") && strlen ("MemFree:") < ((size_t) ( 8)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (buf) && __builtin_constant_p ("MemFree:") && (__s1_len = strlen (buf), __s2_len = strlen ("MemFree:"), (! ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("MemFree:") + 1) - (size_t)(const void *)("MemFree:") == 1) || __s2_len >= 4)) ? __builtin_strcmp (buf, "MemFree:" ) : (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1) && (__s1_len = strlen (buf), __s1_len < 4) ? (__builtin_constant_p ("MemFree:") && ((size_t)(const void *)(("MemFree:") + 1) - (size_t)(const void *)("MemFree:") == 1) ? __builtin_strcmp (buf, "MemFree:") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("MemFree:"); int __result = (((const unsigned char *) (const char *) (buf))[0] - __s2[ 0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1] - __s2[ 1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2] - __s2[ 2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[3] ); } } __result; }))) : (__builtin_constant_p ("MemFree:") && ((size_t)(const void *)(("MemFree:") + 1) - (size_t)(const void *)("MemFree:") == 1) && (__s2_len = strlen ("MemFree:" ), __s2_len < 4) ? (__builtin_constant_p (buf) && ( (size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf ) == 1) ? __builtin_strcmp (buf, "MemFree:") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("MemFree:"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("MemFree:"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("MemFree:"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("MemFree:"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (buf, "MemFree:")))); }) : strncmp (buf, "MemFree:", 8)))) |
1231 | tagged_format_meminfo(buf + 9, &free); |
1232 | else if (!strncmp(buf, "MemShared:", 10)(__extension__ (__builtin_constant_p (10) && ((__builtin_constant_p (buf) && strlen (buf) < ((size_t) (10))) || (__builtin_constant_p ("MemShared:") && strlen ("MemShared:") < ((size_t ) (10)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (buf) && __builtin_constant_p ("MemShared:") && (__s1_len = strlen (buf), __s2_len = strlen ("MemShared:"), ( !((size_t)(const void *)((buf) + 1) - (size_t)(const void *)( buf) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("MemShared:") + 1) - (size_t)(const void *)("MemShared:" ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (buf, "MemShared:" ) : (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1) && (__s1_len = strlen (buf), __s1_len < 4) ? (__builtin_constant_p ("MemShared:") && ((size_t)(const void *)(("MemShared:" ) + 1) - (size_t)(const void *)("MemShared:") == 1) ? __builtin_strcmp (buf, "MemShared:") : (__extension__ ({ const unsigned char * __s2 = (const unsigned char *) (const char *) ("MemShared:"); int __result = (((const unsigned char *) (const char *) (buf ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (buf) )[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (buf) )[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (buf))[ 3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("MemShared:" ) && ((size_t)(const void *)(("MemShared:") + 1) - (size_t )(const void *)("MemShared:") == 1) && (__s2_len = strlen ("MemShared:"), __s2_len < 4) ? (__builtin_constant_p (buf ) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1) ? __builtin_strcmp (buf, "MemShared:") : ( - (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("MemShared:"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("MemShared:"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("MemShared:"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("MemShared:"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (buf, "MemShared:")))); }) : strncmp (buf, "MemShared:", 10)))) |
1233 | tagged_format_meminfo(buf + 11, &shared); |
1234 | } |
1235 | else if (buf[0] == 'S') |
1236 | { |
1237 | if (!strncmp(buf, "Swap:", 5)(__extension__ (__builtin_constant_p (5) && ((__builtin_constant_p (buf) && strlen (buf) < ((size_t) (5))) || (__builtin_constant_p ("Swap:") && strlen ("Swap:") < ((size_t) (5)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (buf) && __builtin_constant_p ("Swap:") && ( __s1_len = strlen (buf), __s2_len = strlen ("Swap:"), (!((size_t )(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1 ) || __s1_len >= 4) && (!((size_t)(const void *)(( "Swap:") + 1) - (size_t)(const void *)("Swap:") == 1) || __s2_len >= 4)) ? __builtin_strcmp (buf, "Swap:") : (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t )(const void *)(buf) == 1) && (__s1_len = strlen (buf ), __s1_len < 4) ? (__builtin_constant_p ("Swap:") && ((size_t)(const void *)(("Swap:") + 1) - (size_t)(const void *)("Swap:") == 1) ? __builtin_strcmp (buf, "Swap:") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("Swap:"); int __result = (((const unsigned char *) ( const char *) (buf))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("Swap:") && ((size_t)(const void *)(("Swap:") + 1) - (size_t)(const void *)("Swap:") == 1) && (__s2_len = strlen ("Swap:"), __s2_len < 4) ? (__builtin_constant_p ( buf) && ((size_t)(const void *)((buf) + 1) - (size_t) (const void *)(buf) == 1) ? __builtin_strcmp (buf, "Swap:") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("Swap:"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("Swap:"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("Swap:"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("Swap:"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (buf, "Swap:")))); }) : strncmp (buf , "Swap:", 5)))) |
1238 | sscanf(buf + 6,"%" PRIu64"l" "u" " %" PRIu64"l" "u", |
1239 | &swap_total, &swap_used); |
1240 | else if (!strncmp(buf, "SwapTotal:", 10)(__extension__ (__builtin_constant_p (10) && ((__builtin_constant_p (buf) && strlen (buf) < ((size_t) (10))) || (__builtin_constant_p ("SwapTotal:") && strlen ("SwapTotal:") < ((size_t ) (10)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (buf) && __builtin_constant_p ("SwapTotal:") && (__s1_len = strlen (buf), __s2_len = strlen ("SwapTotal:"), ( !((size_t)(const void *)((buf) + 1) - (size_t)(const void *)( buf) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("SwapTotal:") + 1) - (size_t)(const void *)("SwapTotal:" ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (buf, "SwapTotal:" ) : (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1) && (__s1_len = strlen (buf), __s1_len < 4) ? (__builtin_constant_p ("SwapTotal:") && ((size_t)(const void *)(("SwapTotal:" ) + 1) - (size_t)(const void *)("SwapTotal:") == 1) ? __builtin_strcmp (buf, "SwapTotal:") : (__extension__ ({ const unsigned char * __s2 = (const unsigned char *) (const char *) ("SwapTotal:"); int __result = (((const unsigned char *) (const char *) (buf ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (buf) )[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (buf) )[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (buf))[ 3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("SwapTotal:" ) && ((size_t)(const void *)(("SwapTotal:") + 1) - (size_t )(const void *)("SwapTotal:") == 1) && (__s2_len = strlen ("SwapTotal:"), __s2_len < 4) ? (__builtin_constant_p (buf ) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1) ? __builtin_strcmp (buf, "SwapTotal:") : ( - (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("SwapTotal:"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("SwapTotal:"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("SwapTotal:"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("SwapTotal:"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (buf, "SwapTotal:")))); }) : strncmp (buf, "SwapTotal:", 10)))) |
1241 | tagged_format_meminfo(buf + 11, &swap_total); |
1242 | else if (!strncmp(buf, "SwapFree:", 9)(__extension__ (__builtin_constant_p (9) && ((__builtin_constant_p (buf) && strlen (buf) < ((size_t) (9))) || (__builtin_constant_p ("SwapFree:") && strlen ("SwapFree:") < ((size_t) (9)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (buf) && __builtin_constant_p ("SwapFree:") && (__s1_len = strlen (buf), __s2_len = strlen ("SwapFree:"), ( !((size_t)(const void *)((buf) + 1) - (size_t)(const void *)( buf) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("SwapFree:") + 1) - (size_t)(const void *)("SwapFree:") == 1) || __s2_len >= 4)) ? __builtin_strcmp (buf, "SwapFree:" ) : (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1) && (__s1_len = strlen (buf), __s1_len < 4) ? (__builtin_constant_p ("SwapFree:") && ((size_t)(const void *)(("SwapFree:" ) + 1) - (size_t)(const void *)("SwapFree:") == 1) ? __builtin_strcmp (buf, "SwapFree:") : (__extension__ ({ const unsigned char * __s2 = (const unsigned char *) (const char *) ("SwapFree:"); int __result = (((const unsigned char *) (const char *) (buf))[0 ] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1 ] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2 ] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[ 3]); } } __result; }))) : (__builtin_constant_p ("SwapFree:") && ((size_t)(const void *)(("SwapFree:") + 1) - (size_t )(const void *)("SwapFree:") == 1) && (__s2_len = strlen ("SwapFree:"), __s2_len < 4) ? (__builtin_constant_p (buf ) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1) ? __builtin_strcmp (buf, "SwapFree:") : ( - (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("SwapFree:"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("SwapFree:"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("SwapFree:"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("SwapFree:"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (buf, "SwapFree:")))); }) : strncmp (buf, "SwapFree:", 9)))) |
1243 | tagged_format_meminfo(buf + 10, &swap_used); |
1244 | else if (!strncmp(buf, "Slab:", 5)(__extension__ (__builtin_constant_p (5) && ((__builtin_constant_p (buf) && strlen (buf) < ((size_t) (5))) || (__builtin_constant_p ("Slab:") && strlen ("Slab:") < ((size_t) (5)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (buf) && __builtin_constant_p ("Slab:") && ( __s1_len = strlen (buf), __s2_len = strlen ("Slab:"), (!((size_t )(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1 ) || __s1_len >= 4) && (!((size_t)(const void *)(( "Slab:") + 1) - (size_t)(const void *)("Slab:") == 1) || __s2_len >= 4)) ? __builtin_strcmp (buf, "Slab:") : (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t )(const void *)(buf) == 1) && (__s1_len = strlen (buf ), __s1_len < 4) ? (__builtin_constant_p ("Slab:") && ((size_t)(const void *)(("Slab:") + 1) - (size_t)(const void *)("Slab:") == 1) ? __builtin_strcmp (buf, "Slab:") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("Slab:"); int __result = (((const unsigned char *) ( const char *) (buf))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("Slab:") && ((size_t)(const void *)(("Slab:") + 1) - (size_t)(const void *)("Slab:") == 1) && (__s2_len = strlen ("Slab:"), __s2_len < 4) ? (__builtin_constant_p ( buf) && ((size_t)(const void *)((buf) + 1) - (size_t) (const void *)(buf) == 1) ? __builtin_strcmp (buf, "Slab:") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("Slab:"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("Slab:"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("Slab:"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("Slab:"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (buf, "Slab:")))); }) : strncmp (buf , "Slab:", 5)))) |
1245 | tagged_format_meminfo(buf + 6, &slab); |
1246 | } |
1247 | else if (buf[0] == 'B' && !strncmp(buf, "Buffers:", 8)(__extension__ (__builtin_constant_p (8) && ((__builtin_constant_p (buf) && strlen (buf) < ((size_t) (8))) || (__builtin_constant_p ("Buffers:") && strlen ("Buffers:") < ((size_t) ( 8)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (buf) && __builtin_constant_p ("Buffers:") && (__s1_len = strlen (buf), __s2_len = strlen ("Buffers:"), (! ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("Buffers:") + 1) - (size_t)(const void *)("Buffers:") == 1) || __s2_len >= 4)) ? __builtin_strcmp (buf, "Buffers:" ) : (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1) && (__s1_len = strlen (buf), __s1_len < 4) ? (__builtin_constant_p ("Buffers:") && ((size_t)(const void *)(("Buffers:") + 1) - (size_t)(const void *)("Buffers:") == 1) ? __builtin_strcmp (buf, "Buffers:") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("Buffers:"); int __result = (((const unsigned char *) (const char *) (buf))[0] - __s2[ 0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1] - __s2[ 1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2] - __s2[ 2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[3] ); } } __result; }))) : (__builtin_constant_p ("Buffers:") && ((size_t)(const void *)(("Buffers:") + 1) - (size_t)(const void *)("Buffers:") == 1) && (__s2_len = strlen ("Buffers:" ), __s2_len < 4) ? (__builtin_constant_p (buf) && ( (size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf ) == 1) ? __builtin_strcmp (buf, "Buffers:") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("Buffers:"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("Buffers:"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("Buffers:"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("Buffers:"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (buf, "Buffers:")))); }) : strncmp (buf, "Buffers:", 8)))) |
1248 | tagged_format_meminfo(buf + 9, &buffers); |
1249 | else if (buf[0] == 'C' && !strncmp(buf, "Cached:", 7)(__extension__ (__builtin_constant_p (7) && ((__builtin_constant_p (buf) && strlen (buf) < ((size_t) (7))) || (__builtin_constant_p ("Cached:") && strlen ("Cached:") < ((size_t) (7) ))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (buf) && __builtin_constant_p ("Cached:") && (__s1_len = strlen (buf), __s2_len = strlen ("Cached:"), (!( (size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("Cached:") + 1) - (size_t)(const void *)("Cached:") == 1 ) || __s2_len >= 4)) ? __builtin_strcmp (buf, "Cached:") : (__builtin_constant_p (buf) && ((size_t)(const void * )((buf) + 1) - (size_t)(const void *)(buf) == 1) && ( __s1_len = strlen (buf), __s1_len < 4) ? (__builtin_constant_p ("Cached:") && ((size_t)(const void *)(("Cached:") + 1) - (size_t)(const void *)("Cached:") == 1) ? __builtin_strcmp (buf, "Cached:") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("Cached:"); int __result = (((const unsigned char *) (const char *) (buf))[0] - __s2[ 0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1] - __s2[ 1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2] - __s2[ 2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[3] ); } } __result; }))) : (__builtin_constant_p ("Cached:") && ((size_t)(const void *)(("Cached:") + 1) - (size_t)(const void *)("Cached:") == 1) && (__s2_len = strlen ("Cached:" ), __s2_len < 4) ? (__builtin_constant_p (buf) && ( (size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf ) == 1) ? __builtin_strcmp (buf, "Cached:") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("Cached:"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("Cached:"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("Cached:"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("Cached:"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (buf, "Cached:")))); }) : strncmp (buf, "Cached:", 7)))) |
1250 | tagged_format_meminfo(buf + 8, &cached); |
1251 | } |
1252 | fclose(f); |
1253 | if (using_tagged) |
1254 | { |
1255 | x_used = total - free; |
1256 | swap_used = swap_total - swap_used; |
1257 | } |
1258 | used = x_used - buffers - cached - slab; |
1259 | gkrellm_mem_assign_data(total, used, free, shared, buffers, cached + slab); |
1260 | } |
1261 | |
1262 | /* Kernel >= 2.6 swap page in/out is in /proc/vmstat. |
1263 | | Kernel <= 2.4 swap page in/out is in /proc/stat read in read_proc_stat(). |
1264 | | Swap total/used for all kernels is read in mem_read_data() above. |
1265 | */ |
1266 | void |
1267 | gkrellm_sys_swap_read_data(void) |
1268 | { |
1269 | static FILE *f; |
1270 | gchar buf[128]; |
1271 | |
1272 | if (!f && kernel_2_6) |
1273 | f = fopen(PROC_VMSTAT_FILE"/proc/vmstat", "r"); |
1274 | |
1275 | if (f) |
1276 | { |
1277 | while (fgets(buf, sizeof(buf), f) != NULL((void*)0)) |
1278 | { |
1279 | if (buf[0] != 'p' || buf[1] != 's') |
1280 | continue; |
1281 | sscanf(buf, "pswpin %lu", &swapin); |
1282 | if (fgets(buf, sizeof(buf), f) == NULL((void*)0)) |
1283 | break; |
1284 | sscanf(buf, "pswpout %lu", &swapout); |
1285 | } |
1286 | rewind(f); |
1287 | } |
1288 | gkrellm_swap_assign_data(swap_total, swap_used, swapin, swapout); |
1289 | } |
1290 | |
1291 | gboolean |
1292 | gkrellm_sys_mem_init(void) |
1293 | { |
1294 | return TRUE(!(0)); |
1295 | } |
1296 | |
1297 | |
1298 | /* ===================================================================== */ |
1299 | /* FS monitor interface */ |
1300 | |
1301 | #include <sys/vfs.h> |
1302 | #include <sys/wait.h> |
1303 | #include <sys/ioctl.h> |
1304 | #include <linux1/cdrom.h> |
1305 | #include <mntent.h> |
1306 | |
1307 | #define PROC_MOUNTS_FILE"/proc/mounts" "/proc/mounts" |
1308 | |
1309 | /* A list of mounted file systems can be read from /proc/mounts or |
1310 | | /etc/mtab (getmntent). Using /proc/mounts eliminates disk accesses, |
1311 | | but for some reason /proc/mounts reports a "." for the mounted |
1312 | | directory for smbfs types. So I use /proc/mounts with a fallback |
1313 | | to using getmntent(). |
1314 | */ |
1315 | #if !defined (_PATH_MOUNTED"/etc/mtab") |
1316 | #define _PATH_MOUNTED"/etc/mtab" "/etc/mtab" |
1317 | #endif |
1318 | |
1319 | |
1320 | static void |
1321 | fix_fstab_name(gchar *buf) |
1322 | { |
1323 | gchar *rp, |
1324 | *wp; |
1325 | |
1326 | if (buf[0] == '\0') |
1327 | return; |
1328 | rp = buf; |
1329 | wp = buf; |
1330 | do /* This loop same as in libc6 getmntent() */ |
1331 | if (rp[0] == '\\' && rp[1] == '0' && rp[2] == '4' && rp[3] == '0') |
1332 | { |
1333 | *wp++ = ' '; /* \040 is a SPACE. */ |
1334 | rp += 3; |
1335 | } |
1336 | else if (rp[0] == '\\' && rp[1] == '0' && rp[2] == '1' && rp[3] == '2') |
1337 | { |
1338 | *wp++ = '\t'; /* \012 is a TAB. */ |
1339 | rp += 3; |
1340 | } |
1341 | else if (rp[0] == '\\' && rp[1] == '\\') |
1342 | { |
1343 | *wp++ = '\\'; /* \\ is a \ */ |
1344 | rp += 1; |
1345 | } |
1346 | else |
1347 | *wp++ = *rp; |
1348 | while (*rp++ != '\0'); |
1349 | } |
1350 | |
1351 | gboolean |
1352 | gkrellm_sys_fs_fstab_modified(void) |
1353 | { |
1354 | struct stat s; |
1355 | static time_t fstab_mtime; |
1356 | gint modified = FALSE(0); |
1357 | |
1358 | if (stat("/etc/fstab", &s) == 0 && s.st_mtimest_mtim.tv_sec != fstab_mtime) |
1359 | modified = TRUE(!(0)); |
1360 | fstab_mtime = s.st_mtimest_mtim.tv_sec; |
1361 | return modified; |
1362 | } |
1363 | |
1364 | void |
1365 | gkrellm_sys_fs_get_fstab_list(void) |
1366 | { |
1367 | FILE *f; |
1368 | gchar buf[1024], *s; |
1369 | gchar dev[512], dir[512], type[128], opt[256]; |
1370 | |
1371 | if ((f = fopen("/etc/fstab", "r")) == NULL((void*)0)) |
1372 | return; |
1373 | while (fgets(buf, sizeof(buf), f)) |
1374 | { |
1375 | s = buf; |
1376 | while (*s == ' ' || *s == '\t') |
1377 | ++s; |
1378 | if (*s == '\0' || *s == '#' || *s == '\n') |
1379 | continue; |
1380 | dev[0] = dir[0] = type[0] = opt[0] = '\0'; |
1381 | sscanf(s, "%511s %511s %127s %255s", dev, dir, type, opt); |
1382 | fix_fstab_name(dev); |
1383 | fix_fstab_name(dir); |
1384 | fix_fstab_name(type); |
1385 | fix_fstab_name(opt); |
1386 | |
1387 | if ( type[0] == '\0' |
1388 | || !strcmp(type, "devpts")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (type) && __builtin_constant_p ("devpts") && (__s1_len = strlen (type), __s2_len = strlen ("devpts"), (!( (size_t)(const void *)((type) + 1) - (size_t)(const void *)(type ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("devpts") + 1) - (size_t)(const void *)("devpts") == 1) || __s2_len >= 4)) ? __builtin_strcmp (type, "devpts") : (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) && (__s1_len = strlen (type ), __s1_len < 4) ? (__builtin_constant_p ("devpts") && ((size_t)(const void *)(("devpts") + 1) - (size_t)(const void *)("devpts") == 1) ? __builtin_strcmp (type, "devpts") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("devpts"); int __result = (((const unsigned char *) (const char *) (type))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (type))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("devpts") && ((size_t)(const void *)(("devpts") + 1 ) - (size_t)(const void *)("devpts") == 1) && (__s2_len = strlen ("devpts"), __s2_len < 4) ? (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) ? __builtin_strcmp (type, "devpts" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (type); int __result = (((const unsigned char *) (const char *) ("devpts"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("devpts"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("devpts"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("devpts"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (type, "devpts")))); }) |
1389 | || !strcmp(type, "swap")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (type) && __builtin_constant_p ("swap") && ( __s1_len = strlen (type), __s2_len = strlen ("swap"), (!((size_t )(const void *)((type) + 1) - (size_t)(const void *)(type) == 1) || __s1_len >= 4) && (!((size_t)(const void *) (("swap") + 1) - (size_t)(const void *)("swap") == 1) || __s2_len >= 4)) ? __builtin_strcmp (type, "swap") : (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) && (__s1_len = strlen (type ), __s1_len < 4) ? (__builtin_constant_p ("swap") && ((size_t)(const void *)(("swap") + 1) - (size_t)(const void * )("swap") == 1) ? __builtin_strcmp (type, "swap") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("swap"); int __result = (((const unsigned char *) ( const char *) (type))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (type))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("swap") && ((size_t)(const void *)(("swap") + 1) - ( size_t)(const void *)("swap") == 1) && (__s2_len = strlen ("swap"), __s2_len < 4) ? (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t)(const void *) (type) == 1) ? __builtin_strcmp (type, "swap") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (type); int __result = (((const unsigned char *) (const char *) ("swap"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("swap"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("swap"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("swap"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (type, "swap")))); }) |
1390 | || !strcmp(type, "proc")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (type) && __builtin_constant_p ("proc") && ( __s1_len = strlen (type), __s2_len = strlen ("proc"), (!((size_t )(const void *)((type) + 1) - (size_t)(const void *)(type) == 1) || __s1_len >= 4) && (!((size_t)(const void *) (("proc") + 1) - (size_t)(const void *)("proc") == 1) || __s2_len >= 4)) ? __builtin_strcmp (type, "proc") : (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) && (__s1_len = strlen (type ), __s1_len < 4) ? (__builtin_constant_p ("proc") && ((size_t)(const void *)(("proc") + 1) - (size_t)(const void * )("proc") == 1) ? __builtin_strcmp (type, "proc") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("proc"); int __result = (((const unsigned char *) ( const char *) (type))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (type))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("proc") && ((size_t)(const void *)(("proc") + 1) - ( size_t)(const void *)("proc") == 1) && (__s2_len = strlen ("proc"), __s2_len < 4) ? (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t)(const void *) (type) == 1) ? __builtin_strcmp (type, "proc") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (type); int __result = (((const unsigned char *) (const char *) ("proc"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("proc"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("proc"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("proc"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (type, "proc")))); }) |
1391 | || !strcmp(type, "sysfs")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (type) && __builtin_constant_p ("sysfs") && ( __s1_len = strlen (type), __s2_len = strlen ("sysfs"), (!((size_t )(const void *)((type) + 1) - (size_t)(const void *)(type) == 1) || __s1_len >= 4) && (!((size_t)(const void *) (("sysfs") + 1) - (size_t)(const void *)("sysfs") == 1) || __s2_len >= 4)) ? __builtin_strcmp (type, "sysfs") : (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) && (__s1_len = strlen (type ), __s1_len < 4) ? (__builtin_constant_p ("sysfs") && ((size_t)(const void *)(("sysfs") + 1) - (size_t)(const void *)("sysfs") == 1) ? __builtin_strcmp (type, "sysfs") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("sysfs"); int __result = (((const unsigned char *) ( const char *) (type))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (type))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("sysfs") && ((size_t)(const void *)(("sysfs") + 1) - (size_t)(const void *)("sysfs") == 1) && (__s2_len = strlen ("sysfs"), __s2_len < 4) ? (__builtin_constant_p ( type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) ? __builtin_strcmp (type, "sysfs" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (type); int __result = (((const unsigned char *) (const char *) ("sysfs"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("sysfs"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("sysfs"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("sysfs"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (type, "sysfs")))); }) |
1392 | || !strcmp(type, "usbdevfs")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (type) && __builtin_constant_p ("usbdevfs") && (__s1_len = strlen (type), __s2_len = strlen ("usbdevfs"), ( !((size_t)(const void *)((type) + 1) - (size_t)(const void *) (type) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("usbdevfs") + 1) - (size_t)(const void *)("usbdevfs" ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (type, "usbdevfs" ) : (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t)(const void *)(type) == 1) && (__s1_len = strlen (type), __s1_len < 4) ? (__builtin_constant_p ("usbdevfs") && ((size_t)(const void *)(("usbdevfs") + 1) - (size_t)(const void *)("usbdevfs") == 1) ? __builtin_strcmp (type, "usbdevfs") : (__extension__ ({ const unsigned char * __s2 = (const unsigned char *) (const char *) ("usbdevfs"); int __result = (((const unsigned char *) (const char *) (type))[ 0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[ 1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[ 2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (type))[3] - __s2 [3]); } } __result; }))) : (__builtin_constant_p ("usbdevfs") && ((size_t)(const void *)(("usbdevfs") + 1) - (size_t )(const void *)("usbdevfs") == 1) && (__s2_len = strlen ("usbdevfs"), __s2_len < 4) ? (__builtin_constant_p (type ) && ((size_t)(const void *)((type) + 1) - (size_t)(const void *)(type) == 1) ? __builtin_strcmp (type, "usbdevfs") : ( - (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (type); int __result = (((const unsigned char *) (const char *) ("usbdevfs"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("usbdevfs"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("usbdevfs"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("usbdevfs"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (type, "usbdevfs")))); }) |
1393 | || !strcmp(type, "usbfs")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (type) && __builtin_constant_p ("usbfs") && ( __s1_len = strlen (type), __s2_len = strlen ("usbfs"), (!((size_t )(const void *)((type) + 1) - (size_t)(const void *)(type) == 1) || __s1_len >= 4) && (!((size_t)(const void *) (("usbfs") + 1) - (size_t)(const void *)("usbfs") == 1) || __s2_len >= 4)) ? __builtin_strcmp (type, "usbfs") : (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) && (__s1_len = strlen (type ), __s1_len < 4) ? (__builtin_constant_p ("usbfs") && ((size_t)(const void *)(("usbfs") + 1) - (size_t)(const void *)("usbfs") == 1) ? __builtin_strcmp (type, "usbfs") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("usbfs"); int __result = (((const unsigned char *) ( const char *) (type))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (type))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("usbfs") && ((size_t)(const void *)(("usbfs") + 1) - (size_t)(const void *)("usbfs") == 1) && (__s2_len = strlen ("usbfs"), __s2_len < 4) ? (__builtin_constant_p ( type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) ? __builtin_strcmp (type, "usbfs" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (type); int __result = (((const unsigned char *) (const char *) ("usbfs"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("usbfs"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("usbfs"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("usbfs"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (type, "usbfs")))); }) |
1394 | || !strcmp(type, "ignore")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (type) && __builtin_constant_p ("ignore") && (__s1_len = strlen (type), __s2_len = strlen ("ignore"), (!( (size_t)(const void *)((type) + 1) - (size_t)(const void *)(type ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("ignore") + 1) - (size_t)(const void *)("ignore") == 1) || __s2_len >= 4)) ? __builtin_strcmp (type, "ignore") : (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) && (__s1_len = strlen (type ), __s1_len < 4) ? (__builtin_constant_p ("ignore") && ((size_t)(const void *)(("ignore") + 1) - (size_t)(const void *)("ignore") == 1) ? __builtin_strcmp (type, "ignore") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("ignore"); int __result = (((const unsigned char *) (const char *) (type))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (type))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("ignore") && ((size_t)(const void *)(("ignore") + 1 ) - (size_t)(const void *)("ignore") == 1) && (__s2_len = strlen ("ignore"), __s2_len < 4) ? (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) ? __builtin_strcmp (type, "ignore" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (type); int __result = (((const unsigned char *) (const char *) ("ignore"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("ignore"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("ignore"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("ignore"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (type, "ignore")))); }) |
1395 | ) |
1396 | continue; |
1397 | gkrellm_fs_add_to_fstab_list(dir, dev, type, opt); |
1398 | } |
1399 | fclose(f); |
1400 | } |
1401 | |
1402 | static void |
1403 | getmntent_fallback(gchar *dir, gint dirsize, gchar *dev) |
1404 | { |
1405 | FILE *f; |
1406 | struct mntent *mnt; |
1407 | |
1408 | if ((f = setmntent(_PATH_MOUNTED"/etc/mtab", "r")) == NULL((void*)0)) |
1409 | return; |
1410 | while ((mnt = getmntent(f)) != NULL((void*)0)) |
1411 | { |
1412 | if (!strcmp(dev, mnt->mnt_fsname)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (dev) && __builtin_constant_p (mnt->mnt_fsname) && (__s1_len = strlen (dev), __s2_len = strlen (mnt->mnt_fsname ), (!((size_t)(const void *)((dev) + 1) - (size_t)(const void *)(dev) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((mnt->mnt_fsname) + 1) - (size_t)(const void *)(mnt ->mnt_fsname) == 1) || __s2_len >= 4)) ? __builtin_strcmp (dev, mnt->mnt_fsname) : (__builtin_constant_p (dev) && ((size_t)(const void *)((dev) + 1) - (size_t)(const void *)( dev) == 1) && (__s1_len = strlen (dev), __s1_len < 4) ? (__builtin_constant_p (mnt->mnt_fsname) && ( (size_t)(const void *)((mnt->mnt_fsname) + 1) - (size_t)(const void *)(mnt->mnt_fsname) == 1) ? __builtin_strcmp (dev, mnt ->mnt_fsname) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (mnt->mnt_fsname ); int __result = (((const unsigned char *) (const char *) (dev ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (dev) )[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (dev) )[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (dev))[ 3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (mnt ->mnt_fsname) && ((size_t)(const void *)((mnt-> mnt_fsname) + 1) - (size_t)(const void *)(mnt->mnt_fsname) == 1) && (__s2_len = strlen (mnt->mnt_fsname), __s2_len < 4) ? (__builtin_constant_p (dev) && ((size_t)(const void *)((dev) + 1) - (size_t)(const void *)(dev) == 1) ? __builtin_strcmp (dev, mnt->mnt_fsname) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (dev); int __result = (((const unsigned char *) (const char *) (mnt-> mnt_fsname))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( mnt->mnt_fsname))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (mnt->mnt_fsname))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (mnt->mnt_fsname))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (dev, mnt->mnt_fsname)))); })) |
1413 | { |
1414 | snprintf(dir, dirsize, "%s", mnt->mnt_dir); |
1415 | break; |
1416 | } |
1417 | } |
1418 | endmntent(f); |
1419 | } |
1420 | |
1421 | void |
1422 | gkrellm_sys_fs_get_mounts_list(void) |
1423 | { |
1424 | FILE *f; |
1425 | gchar *s, buf[1024], dev[512], dir[512], type[128]; |
1426 | |
1427 | if ((f = fopen(PROC_MOUNTS_FILE"/proc/mounts", "r")) == NULL((void*)0)) |
1428 | return; |
1429 | while (fgets(buf, sizeof(buf), f)) |
1430 | { |
1431 | dev[0] = dir[0] = type[0] = '\0'; |
1432 | sscanf(buf, "%512s %512s %127s", dev, dir, type); |
1433 | fix_fstab_name(dev); |
1434 | fix_fstab_name(dir); |
1435 | fix_fstab_name(type); |
1436 | |
1437 | if ( !strcmp(type, "devpts")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (type) && __builtin_constant_p ("devpts") && (__s1_len = strlen (type), __s2_len = strlen ("devpts"), (!( (size_t)(const void *)((type) + 1) - (size_t)(const void *)(type ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("devpts") + 1) - (size_t)(const void *)("devpts") == 1) || __s2_len >= 4)) ? __builtin_strcmp (type, "devpts") : (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) && (__s1_len = strlen (type ), __s1_len < 4) ? (__builtin_constant_p ("devpts") && ((size_t)(const void *)(("devpts") + 1) - (size_t)(const void *)("devpts") == 1) ? __builtin_strcmp (type, "devpts") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("devpts"); int __result = (((const unsigned char *) (const char *) (type))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (type))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("devpts") && ((size_t)(const void *)(("devpts") + 1 ) - (size_t)(const void *)("devpts") == 1) && (__s2_len = strlen ("devpts"), __s2_len < 4) ? (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) ? __builtin_strcmp (type, "devpts" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (type); int __result = (((const unsigned char *) (const char *) ("devpts"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("devpts"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("devpts"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("devpts"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (type, "devpts")))); }) |
1438 | || !strcmp(type, "proc")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (type) && __builtin_constant_p ("proc") && ( __s1_len = strlen (type), __s2_len = strlen ("proc"), (!((size_t )(const void *)((type) + 1) - (size_t)(const void *)(type) == 1) || __s1_len >= 4) && (!((size_t)(const void *) (("proc") + 1) - (size_t)(const void *)("proc") == 1) || __s2_len >= 4)) ? __builtin_strcmp (type, "proc") : (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) && (__s1_len = strlen (type ), __s1_len < 4) ? (__builtin_constant_p ("proc") && ((size_t)(const void *)(("proc") + 1) - (size_t)(const void * )("proc") == 1) ? __builtin_strcmp (type, "proc") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("proc"); int __result = (((const unsigned char *) ( const char *) (type))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (type))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("proc") && ((size_t)(const void *)(("proc") + 1) - ( size_t)(const void *)("proc") == 1) && (__s2_len = strlen ("proc"), __s2_len < 4) ? (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t)(const void *) (type) == 1) ? __builtin_strcmp (type, "proc") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (type); int __result = (((const unsigned char *) (const char *) ("proc"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("proc"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("proc"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("proc"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (type, "proc")))); }) |
1439 | || !strcmp(type, "usbdevfs")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (type) && __builtin_constant_p ("usbdevfs") && (__s1_len = strlen (type), __s2_len = strlen ("usbdevfs"), ( !((size_t)(const void *)((type) + 1) - (size_t)(const void *) (type) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("usbdevfs") + 1) - (size_t)(const void *)("usbdevfs" ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (type, "usbdevfs" ) : (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t)(const void *)(type) == 1) && (__s1_len = strlen (type), __s1_len < 4) ? (__builtin_constant_p ("usbdevfs") && ((size_t)(const void *)(("usbdevfs") + 1) - (size_t)(const void *)("usbdevfs") == 1) ? __builtin_strcmp (type, "usbdevfs") : (__extension__ ({ const unsigned char * __s2 = (const unsigned char *) (const char *) ("usbdevfs"); int __result = (((const unsigned char *) (const char *) (type))[ 0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[ 1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[ 2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (type))[3] - __s2 [3]); } } __result; }))) : (__builtin_constant_p ("usbdevfs") && ((size_t)(const void *)(("usbdevfs") + 1) - (size_t )(const void *)("usbdevfs") == 1) && (__s2_len = strlen ("usbdevfs"), __s2_len < 4) ? (__builtin_constant_p (type ) && ((size_t)(const void *)((type) + 1) - (size_t)(const void *)(type) == 1) ? __builtin_strcmp (type, "usbdevfs") : ( - (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (type); int __result = (((const unsigned char *) (const char *) ("usbdevfs"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("usbdevfs"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("usbdevfs"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("usbdevfs"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (type, "usbdevfs")))); }) |
1440 | || !strcmp(type, "usbfs")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (type) && __builtin_constant_p ("usbfs") && ( __s1_len = strlen (type), __s2_len = strlen ("usbfs"), (!((size_t )(const void *)((type) + 1) - (size_t)(const void *)(type) == 1) || __s1_len >= 4) && (!((size_t)(const void *) (("usbfs") + 1) - (size_t)(const void *)("usbfs") == 1) || __s2_len >= 4)) ? __builtin_strcmp (type, "usbfs") : (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) && (__s1_len = strlen (type ), __s1_len < 4) ? (__builtin_constant_p ("usbfs") && ((size_t)(const void *)(("usbfs") + 1) - (size_t)(const void *)("usbfs") == 1) ? __builtin_strcmp (type, "usbfs") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("usbfs"); int __result = (((const unsigned char *) ( const char *) (type))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (type))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("usbfs") && ((size_t)(const void *)(("usbfs") + 1) - (size_t)(const void *)("usbfs") == 1) && (__s2_len = strlen ("usbfs"), __s2_len < 4) ? (__builtin_constant_p ( type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) ? __builtin_strcmp (type, "usbfs" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (type); int __result = (((const unsigned char *) (const char *) ("usbfs"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("usbfs"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("usbfs"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("usbfs"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (type, "usbfs")))); }) |
1441 | || !strcmp(type, "sysfs")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (type) && __builtin_constant_p ("sysfs") && ( __s1_len = strlen (type), __s2_len = strlen ("sysfs"), (!((size_t )(const void *)((type) + 1) - (size_t)(const void *)(type) == 1) || __s1_len >= 4) && (!((size_t)(const void *) (("sysfs") + 1) - (size_t)(const void *)("sysfs") == 1) || __s2_len >= 4)) ? __builtin_strcmp (type, "sysfs") : (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) && (__s1_len = strlen (type ), __s1_len < 4) ? (__builtin_constant_p ("sysfs") && ((size_t)(const void *)(("sysfs") + 1) - (size_t)(const void *)("sysfs") == 1) ? __builtin_strcmp (type, "sysfs") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("sysfs"); int __result = (((const unsigned char *) ( const char *) (type))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (type))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("sysfs") && ((size_t)(const void *)(("sysfs") + 1) - (size_t)(const void *)("sysfs") == 1) && (__s2_len = strlen ("sysfs"), __s2_len < 4) ? (__builtin_constant_p ( type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) ? __builtin_strcmp (type, "sysfs" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (type); int __result = (((const unsigned char *) (const char *) ("sysfs"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("sysfs"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("sysfs"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("sysfs"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (type, "sysfs")))); }) |
1442 | || !strcmp(type, "autofs")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (type) && __builtin_constant_p ("autofs") && (__s1_len = strlen (type), __s2_len = strlen ("autofs"), (!( (size_t)(const void *)((type) + 1) - (size_t)(const void *)(type ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("autofs") + 1) - (size_t)(const void *)("autofs") == 1) || __s2_len >= 4)) ? __builtin_strcmp (type, "autofs") : (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) && (__s1_len = strlen (type ), __s1_len < 4) ? (__builtin_constant_p ("autofs") && ((size_t)(const void *)(("autofs") + 1) - (size_t)(const void *)("autofs") == 1) ? __builtin_strcmp (type, "autofs") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("autofs"); int __result = (((const unsigned char *) (const char *) (type))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (type))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (type))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("autofs") && ((size_t)(const void *)(("autofs") + 1 ) - (size_t)(const void *)("autofs") == 1) && (__s2_len = strlen ("autofs"), __s2_len < 4) ? (__builtin_constant_p (type) && ((size_t)(const void *)((type) + 1) - (size_t )(const void *)(type) == 1) ? __builtin_strcmp (type, "autofs" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (type); int __result = (((const unsigned char *) (const char *) ("autofs"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("autofs"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("autofs"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("autofs"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (type, "autofs")))); }) |
1443 | ) |
1444 | continue; |
1445 | /* Strip trailing / from the directory. |
1446 | */ |
1447 | s = strrchr(dir, (int) '/'); |
1448 | if (s && s != dir && *(s+1) == '\0') |
1449 | *s = '\0'; |
1450 | if (dir[0] == '.') |
1451 | getmntent_fallback(dir, sizeof(dir), dev); |
1452 | gkrellm_fs_add_to_mounts_list(dir, dev, type); |
1453 | } |
1454 | fclose(f); |
1455 | } |
1456 | |
1457 | void |
1458 | gkrellm_sys_fs_get_fsusage(gpointer fs, gchar *dir) |
1459 | { |
1460 | struct statfs st; |
1461 | |
1462 | if (!statfs(dir, &st)) |
1463 | gkrellm_fs_assign_fsusage_data(fs, |
1464 | (glong) st.f_blocks, (glong) st.f_bavail, |
1465 | (glong) st.f_bfree, (glong) st.f_bsize); |
1466 | else |
1467 | gkrellm_fs_assign_fsusage_data(fs, 0, 0, 0, 0); |
1468 | } |
1469 | |
1470 | |
1471 | static void |
1472 | eject_linux_cdrom(gchar *device) |
1473 | { |
1474 | #if defined(CDROMEJECT0x5309) |
1475 | gint d; |
1476 | |
1477 | if ((d = open(device, O_RDONLY00|O_NONBLOCK04000)) >= 0) |
1478 | { |
1479 | ioctl(d, CDROMEJECT0x5309); |
1480 | close(d); |
1481 | } |
1482 | #endif |
1483 | } |
1484 | |
1485 | gboolean |
1486 | gkrellm_sys_fs_init(void) |
1487 | { |
1488 | gchar *eject_command = NULL((void*)0), |
1489 | *close_command = NULL((void*)0); |
1490 | |
1491 | #if defined(WEXITSTATUS) |
1492 | gint n; |
1493 | |
1494 | n = system("eject -d > /dev/null 2>&1"); |
1495 | if (WEXITSTATUS(n)((((__extension__ (((union { __typeof(n) __in; int __i; }) { . __in = (n) }).__i))) & 0xff00) >> 8) == 0) |
1496 | { |
1497 | eject_command = "eject '%s'"; |
1498 | close_command = "eject -t '%s'"; |
1499 | } |
1500 | #endif |
1501 | gkrellm_fs_setup_eject(eject_command, close_command, |
1502 | eject_linux_cdrom, NULL((void*)0)); |
1503 | return TRUE(!(0)); |
1504 | } |
1505 | |
1506 | /* ===================================================================== */ |
1507 | /* Battery monitor interface */ |
1508 | |
1509 | /* ---------------------- */ |
1510 | /* ACPI battery interface */ |
1511 | |
1512 | #define ACPI_BATTERY_DIR"/proc/acpi/battery/" "/proc/acpi/battery/" |
1513 | #define ACPI_AC_ADAPTOR_DIR"/proc/acpi/ac_adapter/" "/proc/acpi/ac_adapter/" |
1514 | |
1515 | |
1516 | typedef struct |
1517 | { |
1518 | gint id; |
1519 | gchar *info, |
1520 | *state; |
1521 | gint full_cap; |
1522 | gboolean got_full_cap, |
1523 | full_cap_bug; |
1524 | } |
1525 | BatteryFile; |
1526 | |
1527 | static gchar *acpi_ac_state_file; |
1528 | static GList *acpi_battery_list; |
1529 | |
1530 | #if !defined(F_OK0) |
1531 | #define F_OK0 0 |
1532 | #endif |
1533 | |
1534 | static gchar * |
1535 | get_acpi_battery_file(gchar *dir, gchar *subdir, gchar *name) |
1536 | { |
1537 | gchar *path; |
1538 | |
1539 | /* dir is expected to have trailing '/' |
1540 | */ |
1541 | path = g_strconcat(dir, subdir, "/", name, NULL((void*)0)); |
1542 | if (!access(path, F_OK0)) |
1543 | return path; |
1544 | g_free(path); |
1545 | return NULL((void*)0); |
1546 | } |
1547 | |
1548 | static gboolean |
1549 | setup_acpi_battery(gchar *bat) |
1550 | { |
1551 | BatteryFile *bf; |
1552 | gchar *info; |
1553 | static gint id; |
1554 | |
1555 | info = g_strconcat(ACPI_BATTERY_DIR"/proc/acpi/battery/", bat, "/info", NULL((void*)0)); |
1556 | if (_GK.debug_level & DEBUG_BATTERY0x8000) |
1557 | g_debug("setup_acpi_battery: %s\n", info); |
1558 | if (!access(info, F_OK0)) |
1559 | { |
1560 | bf = g_new0(BatteryFile, 1)(BatteryFile *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s = sizeof (BatteryFile); gpointer __p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) && (__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s )) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s ); __p; })); |
1561 | bf->id = id++; |
1562 | bf->info = info; |
1563 | bf->state = get_acpi_battery_file(ACPI_BATTERY_DIR"/proc/acpi/battery/", bat, "state"); |
1564 | if (!bf->state) |
1565 | bf->state = get_acpi_battery_file(ACPI_BATTERY_DIR"/proc/acpi/battery/", bat, "status"); |
1566 | acpi_battery_list = g_list_append(acpi_battery_list, bf); |
1567 | if (_GK.debug_level & DEBUG_BATTERY0x8000) |
1568 | g_debug("setup_acpi_battery: %s\n", |
1569 | bf->state ? bf->state : "no state"); |
1570 | return TRUE(!(0)); |
1571 | } |
1572 | g_free(info); |
1573 | return FALSE(0); |
1574 | } |
1575 | |
1576 | static gboolean |
1577 | setup_ac_adapter(gchar **state, gchar *ac) |
1578 | { |
1579 | gchar *path; |
1580 | |
1581 | path = get_acpi_battery_file(ACPI_AC_ADAPTOR_DIR"/proc/acpi/ac_adapter/", ac, "state"); |
1582 | if (!path) |
1583 | path = get_acpi_battery_file(ACPI_AC_ADAPTOR_DIR"/proc/acpi/ac_adapter/", ac, "status"); |
1584 | *state = path; |
1585 | if (_GK.debug_level & DEBUG_BATTERY0x8000) |
1586 | g_debug("setup_ac_adaptor: %s\n", path ? path : "no state"); |
1587 | |
1588 | return path ? TRUE(!(0)) : FALSE(0); |
1589 | } |
1590 | |
1591 | static void |
1592 | acpi_setup(void) |
1593 | { |
1594 | DIR *d; |
1595 | struct dirent *de; |
1596 | |
1597 | if ((d = opendir(ACPI_BATTERY_DIR"/proc/acpi/battery/")) == NULL((void*)0)) |
1598 | return; |
1599 | |
1600 | while ((de = readdir(d)) != NULL((void*)0)) |
1601 | { |
1602 | if ( strcmp(de->d_name, ".")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (de->d_name) && __builtin_constant_p (".") && (__s1_len = strlen (de->d_name), __s2_len = strlen ("."), (!((size_t)(const void *)((de->d_name) + 1) - (size_t)(const void *)(de->d_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((".") + 1) - (size_t)(const void * )(".") == 1) || __s2_len >= 4)) ? __builtin_strcmp (de-> d_name, ".") : (__builtin_constant_p (de->d_name) && ((size_t)(const void *)((de->d_name) + 1) - (size_t)(const void *)(de->d_name) == 1) && (__s1_len = strlen ( de->d_name), __s1_len < 4) ? (__builtin_constant_p ("." ) && ((size_t)(const void *)((".") + 1) - (size_t)(const void *)(".") == 1) ? __builtin_strcmp (de->d_name, ".") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("."); int __result = (((const unsigned char *) (const char *) (de->d_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (de->d_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (de->d_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (de->d_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p (".") && ((size_t)(const void *)((".") + 1) - (size_t)(const void *)(".") == 1) && (__s2_len = strlen ("."), __s2_len < 4) ? (__builtin_constant_p (de->d_name) && ((size_t)(const void *)((de->d_name ) + 1) - (size_t)(const void *)(de->d_name) == 1) ? __builtin_strcmp (de->d_name, ".") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (de->d_name ); int __result = (((const unsigned char *) (const char *) ("." ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (".") )[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (".") )[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("."))[ 3] - __s2[3]); } } __result; })))) : __builtin_strcmp (de-> d_name, ".")))); }) |
1603 | && strcmp(de->d_name, "..")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (de->d_name) && __builtin_constant_p ("..") && (__s1_len = strlen (de->d_name), __s2_len = strlen ("..") , (!((size_t)(const void *)((de->d_name) + 1) - (size_t)(const void *)(de->d_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("..") + 1) - (size_t)(const void * )("..") == 1) || __s2_len >= 4)) ? __builtin_strcmp (de-> d_name, "..") : (__builtin_constant_p (de->d_name) && ((size_t)(const void *)((de->d_name) + 1) - (size_t)(const void *)(de->d_name) == 1) && (__s1_len = strlen ( de->d_name), __s1_len < 4) ? (__builtin_constant_p (".." ) && ((size_t)(const void *)(("..") + 1) - (size_t)(const void *)("..") == 1) ? __builtin_strcmp (de->d_name, "..") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (".."); int __result = (((const unsigned char *) (const char *) (de->d_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (de->d_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (de->d_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (de->d_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("..") && ((size_t)(const void *)(("..") + 1) - (size_t)(const void *)("..") == 1) && (__s2_len = strlen (".."), __s2_len < 4) ? (__builtin_constant_p (de->d_name) && ((size_t)(const void *)((de->d_name ) + 1) - (size_t)(const void *)(de->d_name) == 1) ? __builtin_strcmp (de->d_name, "..") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (de->d_name ); int __result = (((const unsigned char *) (const char *) (".." ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (".." ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (".." ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("..")) [3] - __s2[3]); } } __result; })))) : __builtin_strcmp (de-> d_name, "..")))); }) |
1604 | ) |
1605 | setup_acpi_battery(de->d_name); |
1606 | } |
1607 | closedir(d); |
1608 | |
1609 | if (!acpi_battery_list) |
1610 | return; |
1611 | |
1612 | if ((d = opendir(ACPI_AC_ADAPTOR_DIR"/proc/acpi/ac_adapter/")) != NULL((void*)0)) |
1613 | { |
1614 | while ((de = readdir(d)) != NULL((void*)0)) |
1615 | { |
1616 | if ( strcmp(de->d_name, ".")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (de->d_name) && __builtin_constant_p (".") && (__s1_len = strlen (de->d_name), __s2_len = strlen ("."), (!((size_t)(const void *)((de->d_name) + 1) - (size_t)(const void *)(de->d_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((".") + 1) - (size_t)(const void * )(".") == 1) || __s2_len >= 4)) ? __builtin_strcmp (de-> d_name, ".") : (__builtin_constant_p (de->d_name) && ((size_t)(const void *)((de->d_name) + 1) - (size_t)(const void *)(de->d_name) == 1) && (__s1_len = strlen ( de->d_name), __s1_len < 4) ? (__builtin_constant_p ("." ) && ((size_t)(const void *)((".") + 1) - (size_t)(const void *)(".") == 1) ? __builtin_strcmp (de->d_name, ".") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("."); int __result = (((const unsigned char *) (const char *) (de->d_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (de->d_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (de->d_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (de->d_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p (".") && ((size_t)(const void *)((".") + 1) - (size_t)(const void *)(".") == 1) && (__s2_len = strlen ("."), __s2_len < 4) ? (__builtin_constant_p (de->d_name) && ((size_t)(const void *)((de->d_name ) + 1) - (size_t)(const void *)(de->d_name) == 1) ? __builtin_strcmp (de->d_name, ".") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (de->d_name ); int __result = (((const unsigned char *) (const char *) ("." ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (".") )[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (".") )[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("."))[ 3] - __s2[3]); } } __result; })))) : __builtin_strcmp (de-> d_name, ".")))); }) |
1617 | && strcmp(de->d_name, "..")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (de->d_name) && __builtin_constant_p ("..") && (__s1_len = strlen (de->d_name), __s2_len = strlen ("..") , (!((size_t)(const void *)((de->d_name) + 1) - (size_t)(const void *)(de->d_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("..") + 1) - (size_t)(const void * )("..") == 1) || __s2_len >= 4)) ? __builtin_strcmp (de-> d_name, "..") : (__builtin_constant_p (de->d_name) && ((size_t)(const void *)((de->d_name) + 1) - (size_t)(const void *)(de->d_name) == 1) && (__s1_len = strlen ( de->d_name), __s1_len < 4) ? (__builtin_constant_p (".." ) && ((size_t)(const void *)(("..") + 1) - (size_t)(const void *)("..") == 1) ? __builtin_strcmp (de->d_name, "..") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (".."); int __result = (((const unsigned char *) (const char *) (de->d_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (de->d_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (de->d_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (de->d_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("..") && ((size_t)(const void *)(("..") + 1) - (size_t)(const void *)("..") == 1) && (__s2_len = strlen (".."), __s2_len < 4) ? (__builtin_constant_p (de->d_name) && ((size_t)(const void *)((de->d_name ) + 1) - (size_t)(const void *)(de->d_name) == 1) ? __builtin_strcmp (de->d_name, "..") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (de->d_name ); int __result = (((const unsigned char *) (const char *) (".." ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (".." ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (".." ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("..")) [3] - __s2[3]); } } __result; })))) : __builtin_strcmp (de-> d_name, "..")))); }) |
1618 | && setup_ac_adapter(&acpi_ac_state_file, de->d_name) |
1619 | ) |
1620 | break; |
1621 | } |
1622 | closedir(d); |
1623 | } |
1624 | } |
1625 | |
1626 | |
1627 | static gboolean |
1628 | fgets_lower_case(gchar *buf, gint len, FILE *f) |
1629 | { |
1630 | guchar *s; |
1631 | |
1632 | if (!fgets(buf, len, f)) |
1633 | return FALSE(0); |
1634 | s = (guchar *) buf; |
1635 | if (isupper(*s)((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISupper)) |
1636 | while (*s) |
1637 | { |
1638 | if (isupper(*s)((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISupper)) |
1639 | *s = tolower(*s)(__extension__ ({ int __res; if (sizeof (*s) > 1) { if (__builtin_constant_p (*s)) { int __c = (*s); __res = __c < -128 || __c > 255 ? __c : (*__ctype_tolower_loc ())[__c]; } else __res = tolower (*s); } else __res = (*__ctype_tolower_loc ())[(int) (*s)]; __res ; })); |
1640 | ++s; |
1641 | } |
1642 | return TRUE(!(0)); |
1643 | } |
1644 | |
1645 | static gboolean |
1646 | acpi_battery_data(BatteryFile *bf) |
1647 | { |
1648 | FILE *f; |
1649 | gchar buf[128], s1[32]; |
1650 | gboolean on_line, charging, available, have_charging_state; |
1651 | gint percent = 0, time_left = -1; |
1652 | gint cur_cap = 0, cur_rate = 0; |
1653 | extern gint gkrellm_battery_full_cap_fallback(void); |
1654 | |
1655 | if (!bf->got_full_cap) /* get battery capacity */ |
1656 | { |
1657 | if (_GK.debug_level & DEBUG_BATTERY0x8000) |
1658 | g_debug("getting full capacity: %s\n", bf->info); |
1659 | if ((f = fopen(bf->info, "r")) == NULL((void*)0)) |
1660 | return FALSE(0); |
1661 | bf->got_full_cap = TRUE(!(0)); |
1662 | while (fgets_lower_case(buf, sizeof(buf), f)) |
1663 | { |
1664 | /* present: {yes|no} |
1665 | | design capacity: 53280 mWh |
1666 | | last full capacity: 51282 mWh |
1667 | | battery technology: rechargeable |
1668 | | design voltage: 14800 mV |
1669 | | design capacity warning: 5120 mWh |
1670 | | design capacity low: 0 mWh |
1671 | | capacity granularity 1: 1480 mWh |
1672 | | capacity granularity 2: 1480 mWh |
1673 | | model number: 6000 |
1674 | | serial number: 1 |
1675 | | battery type: 4 |
1676 | | OEM info: XXXX |
1677 | */ |
1678 | if (sscanf(buf, "design capacity: %d", &bf->full_cap) == 1) |
1679 | if (_GK.debug_level & DEBUG_BATTERY0x8000) |
1680 | g_debug("%s: %d <- %s", bf->info, bf->full_cap, buf); |
1681 | if (sscanf(buf, "last full capacity: %d", &bf->full_cap) == 1) |
1682 | if (_GK.debug_level & DEBUG_BATTERY0x8000) |
1683 | g_debug("%s: %d <- %s", bf->info, bf->full_cap, buf); |
1684 | } |
1685 | fclose(f); |
1686 | } |
1687 | if (bf->full_cap == 0) |
1688 | { |
1689 | bf->full_cap = gkrellm_battery_full_cap_fallback(); |
1690 | bf->full_cap_bug = TRUE(!(0)); |
1691 | } |
1692 | |
1693 | on_line = FALSE(0); |
1694 | |
1695 | if ( acpi_ac_state_file |
1696 | && (f = fopen(acpi_ac_state_file, "r")) != NULL((void*)0) |
1697 | ) |
1698 | { |
1699 | while (fgets_lower_case(buf, sizeof(buf), f)) |
1700 | { |
1701 | /* state: {on-line|off-line} |
1702 | */ |
1703 | if ( ( sscanf (buf, "state: %31s", s1) == 1 |
1704 | || sscanf (buf, "status: %31s", s1) == 1 |
1705 | ) |
1706 | && !strcmp(s1, "on-line")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (s1) && __builtin_constant_p ("on-line") && ( __s1_len = strlen (s1), __s2_len = strlen ("on-line"), (!((size_t )(const void *)((s1) + 1) - (size_t)(const void *)(s1) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("on-line" ) + 1) - (size_t)(const void *)("on-line") == 1) || __s2_len >= 4)) ? __builtin_strcmp (s1, "on-line") : (__builtin_constant_p (s1) && ((size_t)(const void *)((s1) + 1) - (size_t) (const void *)(s1) == 1) && (__s1_len = strlen (s1), __s1_len < 4) ? (__builtin_constant_p ("on-line") && ((size_t )(const void *)(("on-line") + 1) - (size_t)(const void *)("on-line" ) == 1) ? __builtin_strcmp (s1, "on-line") : (__extension__ ( { const unsigned char *__s2 = (const unsigned char *) (const char *) ("on-line"); int __result = (((const unsigned char *) (const char *) (s1))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( s1))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (s1 ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (s1))[3 ] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("on-line" ) && ((size_t)(const void *)(("on-line") + 1) - (size_t )(const void *)("on-line") == 1) && (__s2_len = strlen ("on-line"), __s2_len < 4) ? (__builtin_constant_p (s1) && ((size_t)(const void *)((s1) + 1) - (size_t)(const void *)(s1 ) == 1) ? __builtin_strcmp (s1, "on-line") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (s1); int __result = (((const unsigned char *) (const char *) ("on-line"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("on-line"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("on-line"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("on-line"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (s1, "on-line")))); }) |
1707 | ) |
1708 | on_line = TRUE(!(0)); |
1709 | } |
1710 | fclose(f); |
1711 | } |
1712 | |
1713 | if ((f = fopen(bf->state, "r")) == NULL((void*)0)) |
1714 | return FALSE(0); |
1715 | charging = FALSE(0); |
1716 | available = FALSE(0); |
1717 | have_charging_state = FALSE(0); |
1718 | while (fgets_lower_case(buf, sizeof(buf), f)) |
1719 | { |
1720 | /* present: {yes|no} |
1721 | | capacity state: ok |
1722 | | charging state: {charged|charging|discharging|unknown} |
1723 | | present rate: 15000 mW |
1724 | | remaining capacity: 31282 mWh |
1725 | | present voltage: 16652 mV |
1726 | */ |
1727 | if (sscanf(buf, "charging state: %31s", s1) == 1) |
1728 | { |
1729 | have_charging_state = TRUE(!(0)); |
1730 | if ( (!strcmp(s1, "unknown")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (s1) && __builtin_constant_p ("unknown") && ( __s1_len = strlen (s1), __s2_len = strlen ("unknown"), (!((size_t )(const void *)((s1) + 1) - (size_t)(const void *)(s1) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("unknown" ) + 1) - (size_t)(const void *)("unknown") == 1) || __s2_len >= 4)) ? __builtin_strcmp (s1, "unknown") : (__builtin_constant_p (s1) && ((size_t)(const void *)((s1) + 1) - (size_t) (const void *)(s1) == 1) && (__s1_len = strlen (s1), __s1_len < 4) ? (__builtin_constant_p ("unknown") && ((size_t )(const void *)(("unknown") + 1) - (size_t)(const void *)("unknown" ) == 1) ? __builtin_strcmp (s1, "unknown") : (__extension__ ( { const unsigned char *__s2 = (const unsigned char *) (const char *) ("unknown"); int __result = (((const unsigned char *) (const char *) (s1))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( s1))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (s1 ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (s1))[3 ] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("unknown" ) && ((size_t)(const void *)(("unknown") + 1) - (size_t )(const void *)("unknown") == 1) && (__s2_len = strlen ("unknown"), __s2_len < 4) ? (__builtin_constant_p (s1) && ((size_t)(const void *)((s1) + 1) - (size_t)(const void *)(s1 ) == 1) ? __builtin_strcmp (s1, "unknown") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (s1); int __result = (((const unsigned char *) (const char *) ("unknown"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("unknown"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("unknown"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("unknown"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (s1, "unknown")))); }) && on_line) |
1731 | || !strcmp(s1, "charging")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (s1) && __builtin_constant_p ("charging") && (__s1_len = strlen (s1), __s2_len = strlen ("charging"), (!( (size_t)(const void *)((s1) + 1) - (size_t)(const void *)(s1) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("charging") + 1) - (size_t)(const void *)("charging") == 1) || __s2_len >= 4)) ? __builtin_strcmp (s1, "charging") : (__builtin_constant_p (s1) && ((size_t)(const void *)((s1) + 1) - (size_t)(const void *)(s1) == 1) && ( __s1_len = strlen (s1), __s1_len < 4) ? (__builtin_constant_p ("charging") && ((size_t)(const void *)(("charging") + 1) - (size_t)(const void *)("charging") == 1) ? __builtin_strcmp (s1, "charging") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("charging"); int __result = (((const unsigned char *) (const char *) (s1))[0] - __s2[0 ]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (s1))[1] - __s2[1]) ; if (__s1_len > 1 && __result == 0) { __result = ( ((const unsigned char *) (const char *) (s1))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (s1))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("charging") && ((size_t )(const void *)(("charging") + 1) - (size_t)(const void *)("charging" ) == 1) && (__s2_len = strlen ("charging"), __s2_len < 4) ? (__builtin_constant_p (s1) && ((size_t)(const void *)((s1) + 1) - (size_t)(const void *)(s1) == 1) ? __builtin_strcmp (s1, "charging") : (- (__extension__ ({ const unsigned char * __s2 = (const unsigned char *) (const char *) (s1); int __result = (((const unsigned char *) (const char *) ("charging"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("charging"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("charging"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("charging"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (s1, "charging" )))); }) |
1732 | || !strcmp(s1, "charged")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (s1) && __builtin_constant_p ("charged") && ( __s1_len = strlen (s1), __s2_len = strlen ("charged"), (!((size_t )(const void *)((s1) + 1) - (size_t)(const void *)(s1) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("charged" ) + 1) - (size_t)(const void *)("charged") == 1) || __s2_len >= 4)) ? __builtin_strcmp (s1, "charged") : (__builtin_constant_p (s1) && ((size_t)(const void *)((s1) + 1) - (size_t) (const void *)(s1) == 1) && (__s1_len = strlen (s1), __s1_len < 4) ? (__builtin_constant_p ("charged") && ((size_t )(const void *)(("charged") + 1) - (size_t)(const void *)("charged" ) == 1) ? __builtin_strcmp (s1, "charged") : (__extension__ ( { const unsigned char *__s2 = (const unsigned char *) (const char *) ("charged"); int __result = (((const unsigned char *) (const char *) (s1))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( s1))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (s1 ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (s1))[3 ] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("charged" ) && ((size_t)(const void *)(("charged") + 1) - (size_t )(const void *)("charged") == 1) && (__s2_len = strlen ("charged"), __s2_len < 4) ? (__builtin_constant_p (s1) && ((size_t)(const void *)((s1) + 1) - (size_t)(const void *)(s1 ) == 1) ? __builtin_strcmp (s1, "charged") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (s1); int __result = (((const unsigned char *) (const char *) ("charged"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("charged"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("charged"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("charged"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (s1, "charged")))); }) |
1733 | ) |
1734 | charging = TRUE(!(0)); |
1735 | continue; |
1736 | } |
1737 | if (sscanf(buf, "remaining capacity: %d", &cur_cap) == 1) |
1738 | { |
1739 | if (_GK.debug_level & DEBUG_BATTERY0x8000) |
1740 | g_debug("%s: %d <- %s", bf->state, cur_cap, buf); |
1741 | continue; |
1742 | } |
1743 | if (sscanf(buf, "present rate: %d", &cur_rate) == 1) |
1744 | continue; |
1745 | if ( sscanf(buf, "present: %31s", s1) == 1 |
1746 | && !strcmp(s1, "yes")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (s1) && __builtin_constant_p ("yes") && (__s1_len = strlen (s1), __s2_len = strlen ("yes"), (!((size_t)(const void *)((s1) + 1) - (size_t)(const void *)(s1) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("yes") + 1) - (size_t )(const void *)("yes") == 1) || __s2_len >= 4)) ? __builtin_strcmp (s1, "yes") : (__builtin_constant_p (s1) && ((size_t )(const void *)((s1) + 1) - (size_t)(const void *)(s1) == 1) && (__s1_len = strlen (s1), __s1_len < 4) ? (__builtin_constant_p ("yes") && ((size_t)(const void *)(("yes") + 1) - (size_t )(const void *)("yes") == 1) ? __builtin_strcmp (s1, "yes") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("yes"); int __result = (((const unsigned char *) (const char *) (s1))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (s1))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (s1))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (s1 ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "yes") && ((size_t)(const void *)(("yes") + 1) - (size_t )(const void *)("yes") == 1) && (__s2_len = strlen ("yes" ), __s2_len < 4) ? (__builtin_constant_p (s1) && ( (size_t)(const void *)((s1) + 1) - (size_t)(const void *)(s1) == 1) ? __builtin_strcmp (s1, "yes") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (s1); int __result = (((const unsigned char *) (const char * ) ("yes"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "yes"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "yes"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("yes" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (s1, "yes")))); }) |
1747 | ) |
1748 | available = TRUE(!(0)); |
1749 | } |
1750 | fclose(f); |
1751 | |
1752 | if (_GK.debug_level & DEBUG_BATTERY0x8000) |
1753 | g_debug( |
1754 | "Battery: on_line=%d charging=%d have_charging=%d state_file=%d\n", |
1755 | on_line, charging, have_charging_state, |
1756 | acpi_ac_state_file ? TRUE(!(0)) : FALSE(0)); |
1757 | |
1758 | if (!acpi_ac_state_file && charging) /* Assumption for buggy ACPI */ |
1759 | on_line = TRUE(!(0)); |
1760 | |
1761 | if (!have_charging_state && on_line) /* Another buggy ACPI */ |
1762 | charging = TRUE(!(0)); |
1763 | |
1764 | if (charging) |
1765 | bf->got_full_cap = FALSE(0); /* reread full_cap */ |
1766 | |
1767 | percent = cur_cap * 100 / bf->full_cap; |
1768 | if (percent > 100) |
1769 | { |
1770 | percent = 100; |
1771 | if (bf->full_cap_bug) |
1772 | bf->full_cap = cur_cap; |
1773 | else |
1774 | bf->got_full_cap = FALSE(0); /* reread full_cap */ |
1775 | } |
1776 | |
1777 | if (cur_rate > 0) |
1778 | { |
1779 | if (charging) |
1780 | time_left = 60 * (bf->full_cap - cur_cap) / cur_rate; |
1781 | else |
1782 | time_left = 60 * cur_cap / cur_rate; |
1783 | } |
1784 | |
1785 | if (_GK.debug_level & DEBUG_BATTERY0x8000) |
1786 | { |
1787 | g_debug("Battery %d: percent=%d time_left=%d cur_cap=%d full_cap=%d\n", |
1788 | bf->id, percent, time_left, cur_cap, bf->full_cap); |
1789 | g_debug(" available=%d on_line=%d charging=%d fc_bug=%d\n", |
1790 | available, on_line, charging, bf->full_cap_bug); |
1791 | } |
1792 | gkrellm_battery_assign_data(bf->id, available, on_line, charging, |
1793 | percent, time_left); |
1794 | return TRUE(!(0)); |
1795 | } |
1796 | |
1797 | |
1798 | /* ---------------------------- */ |
1799 | /* sysfs power interface */ |
1800 | #define SYSFS_POWER_SUPPLIES"/sys/class/power_supply/" "/sys/class/power_supply/" |
1801 | #define SYSFS_TYPE_BATTERY"battery" "battery" |
1802 | #define SYSFS_TYPE_AC_ADAPTER"mains" "mains" |
1803 | |
1804 | |
1805 | #define VARIANTS5 5 |
1806 | typedef struct syspower |
1807 | { |
1808 | gint type; |
1809 | gint id; |
1810 | gint charge_units[VARIANTS5]; |
1811 | gchar const *sysdir; |
1812 | gchar const *sys_charge_full[VARIANTS5]; |
1813 | gchar const *sys_charge_now[VARIANTS5]; |
1814 | gboolean present; |
1815 | gboolean ac_present; |
1816 | gboolean charging; |
1817 | } |
1818 | syspower; |
1819 | #define PWRTYPE_BATTERY0 0 |
1820 | #define PWRTYPE_UPS1 1 |
1821 | #define PWRTYPE_MAINS2 2 |
1822 | #define PWRTYPE_USB3 3 |
1823 | |
1824 | #define CHGUNITS_INVALID0 0 |
1825 | #define CHGUNITS_PERCENT1 1 /* 'capacity' */ |
1826 | #define CHGUNITS_uWH2 2 /* 'energy' */ |
1827 | #define CHGUNITS_uAH3 3 /* 'charge' */ |
1828 | |
1829 | /* |
1830 | * Ordering in this list is significant: Mains power sources appear before |
1831 | * battery sources. |
1832 | */ |
1833 | static GList *g_sysfs_power_list; |
1834 | static gint g_on_line; |
1835 | static gint g_pwr_id; |
1836 | |
1837 | |
1838 | static gboolean |
1839 | read_sysfs_entry (gchar *buf, gint buflen, gchar const *sysentry) |
1840 | { |
1841 | FILE *f; |
1842 | |
1843 | if ((f = fopen (sysentry, "r"))) |
1844 | { |
1845 | if (fgets (buf, buflen, f)) |
1846 | { |
1847 | gchar *nl; |
1848 | |
1849 | /* Squash trailing newline if present. */ |
1850 | nl = buf + strlen (buf) - 1; |
1851 | if (*nl == '\n') |
1852 | *nl = '\0'; |
1853 | fclose (f); |
1854 | if (_GK.debug_level & DEBUG_BATTERY0x8000) |
1855 | g_debug ("read_sysfs_entry: %s = %s\n", |
1856 | sysentry, buf); |
1857 | return TRUE(!(0)); |
1858 | } |
1859 | fclose (f); |
1860 | } |
1861 | if (_GK.debug_level & DEBUG_BATTERY0x8000) |
1862 | g_debug ("read_sysfs_entry: cannot read %s\n", sysentry); |
1863 | return FALSE(0); |
1864 | } |
1865 | |
1866 | static gboolean |
1867 | sysfs_power_data (struct syspower *sp) |
1868 | { |
1869 | uint64_t charge_full, charge_now; |
1870 | gint time_left; |
1871 | gint present; |
1872 | gint percent; |
1873 | gchar sysentry[128]; |
1874 | gchar buf[128]; |
1875 | gchar *syszap; |
1876 | gboolean charging; |
1877 | |
1878 | time_left = -1; |
1879 | charge_full = charge_now = 0; |
Value stored to 'charge_full' is never read | |
1880 | present = 0; |
1881 | percent = 0; |
1882 | charging = FALSE(0); |
1883 | |
1884 | strcpy (sysentry, sp->sysdir); |
1885 | syszap = sysentry + strlen (sysentry); |
1886 | |
1887 | /* What type of entry is this? */ |
1888 | if (sp->type == PWRTYPE_MAINS2) |
1889 | { |
1890 | /* Get the 'on-line' status. */ |
1891 | *syszap = '\0'; |
1892 | strcat (sysentry, "/online"); |
1893 | if (read_sysfs_entry (buf, sizeof (buf), sysentry)) |
1894 | g_on_line = strtol (buf, NULL((void*)0), 0); |
1895 | return TRUE(!(0)); |
1896 | } |
1897 | |
1898 | /* |
1899 | * The rest of this code doesn't know how to handle anything other than |
1900 | * a battery. |
1901 | */ |
1902 | if (sp->type != PWRTYPE_BATTERY0) |
1903 | return FALSE(0); |
1904 | |
1905 | /* Is the battery still there? */ |
1906 | *syszap = '\0'; |
1907 | strcat (sysentry, "/present"); |
1908 | if (read_sysfs_entry (buf, sizeof (buf), sysentry)) |
1909 | present = strtol (buf, NULL((void*)0), 0); |
1910 | |
1911 | if (present) |
1912 | { |
1913 | int i; |
1914 | |
1915 | for (i = 0; i < VARIANTS5; i++) { |
1916 | if (read_sysfs_entry (buf, sizeof (buf), sp->sys_charge_full[i])) |
1917 | { |
1918 | charge_full = strtoll (buf, NULL((void*)0), 0); |
1919 | } |
1920 | else |
1921 | { |
1922 | continue; |
1923 | } |
1924 | if (read_sysfs_entry (buf, sizeof (buf), sp->sys_charge_now[i])) |
1925 | { |
1926 | charge_now = strtoll (buf, NULL((void*)0), 0); |
1927 | } |
1928 | else |
1929 | { |
1930 | continue; |
1931 | } |
1932 | if (sp->charge_units[i] == CHGUNITS_PERCENT1) |
1933 | { |
1934 | percent = charge_now; |
1935 | } |
1936 | else |
1937 | { |
1938 | if (charge_full > 0) |
1939 | percent = charge_now * 100 / charge_full; |
1940 | } |
1941 | break; |
1942 | } |
1943 | |
1944 | /* Get charging status. */ |
1945 | *syszap = '\0'; |
1946 | strcat (sysentry, "/status"); |
1947 | if (read_sysfs_entry (buf, sizeof (buf), sysentry)) |
1948 | { |
1949 | charging = !strcasecmp (buf, "charging"); |
1950 | } |
1951 | } |
1952 | |
1953 | gkrellm_battery_assign_data (sp->id, present, g_on_line, charging, |
1954 | percent, time_left); |
1955 | return TRUE(!(0)); |
1956 | } |
1957 | |
1958 | |
1959 | static gboolean |
1960 | setup_sysfs_ac_power (gchar const *sysdir) |
1961 | { |
1962 | syspower *sp; |
1963 | |
1964 | if (_GK.debug_level & DEBUG_BATTERY0x8000) |
1965 | g_debug ("setup_sysfs_ac_power: %s\n", sysdir); |
1966 | sp = g_new0 (syspower, 1)(syspower *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s = sizeof (syspower); gpointer __p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) && (__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s); __p ; })); |
1967 | memset(sp, 0, sizeof(*sp)); |
1968 | sp->type = PWRTYPE_MAINS2; |
1969 | sp->id = g_pwr_id++; |
1970 | sp->sysdir = g_strdup (sysdir); |
1971 | |
1972 | /* Add mains power sources to head of list. */ |
1973 | g_sysfs_power_list = g_list_prepend (g_sysfs_power_list, sp); |
1974 | |
1975 | return TRUE(!(0)); |
1976 | } |
1977 | |
1978 | static gboolean |
1979 | setup_sysfs_battery (gchar const *sysdir) |
1980 | { |
1981 | syspower *sp; |
1982 | |
1983 | sp = g_new0 (syspower, 1)(syspower *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s = sizeof (syspower); gpointer __p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) && (__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s); __p ; })); |
1984 | sp->type = PWRTYPE_BATTERY0; |
1985 | sp->id = g_pwr_id++; |
1986 | sp->sysdir = g_strdup (sysdir); |
1987 | /* |
1988 | * There are three flavors of reporting: 'energy', 'charge', and |
1989 | * 'capacity'. Check for them in that order. |
1990 | */ |
1991 | sp->charge_units[0] = CHGUNITS_uWH2; |
1992 | sp->sys_charge_full[0] = g_strconcat (sysdir, "/energy_full", NULL((void*)0)); |
1993 | sp->sys_charge_now[0] = g_strconcat (sysdir, "/energy_now", NULL((void*)0)); |
1994 | |
1995 | sp->charge_units[1] = CHGUNITS_uWH2; |
1996 | sp->sys_charge_full[1] = g_strconcat (sysdir, "/energy_full_design", NULL((void*)0)); |
1997 | sp->sys_charge_now[1] = g_strconcat (sysdir, "/energy_now", NULL((void*)0)); |
1998 | |
1999 | sp->charge_units[2] = CHGUNITS_uAH3; |
2000 | sp->sys_charge_full[2] = g_strconcat (sysdir, "/charge_full", NULL((void*)0)); |
2001 | sp->sys_charge_now[2] = g_strconcat (sysdir, "/charge_now", NULL((void*)0)); |
2002 | |
2003 | sp->charge_units[3] = CHGUNITS_uAH3; |
2004 | sp->sys_charge_full[3] = g_strconcat (sysdir, "/charge_full_design", NULL((void*)0)); |
2005 | sp->sys_charge_now[3] = g_strconcat (sysdir, "/charge_now", NULL((void*)0)); |
2006 | |
2007 | sp->charge_units[4] = CHGUNITS_PERCENT1; |
2008 | sp->sys_charge_full[4] = g_strconcat (sysdir, "/capacity_full", NULL((void*)0)); |
2009 | sp->sys_charge_now[4] = g_strconcat (sysdir, "/capacity_now", NULL((void*)0)); |
2010 | |
2011 | /* Battery power sources are appended to the end of the list. */ |
2012 | g_sysfs_power_list = g_list_append (g_sysfs_power_list, sp); |
2013 | |
2014 | return TRUE(!(0)); |
2015 | } |
2016 | |
2017 | static gboolean |
2018 | setup_sysfs_power_entry (gchar const *sysentry) |
2019 | { |
2020 | gchar *sysdir; |
2021 | gboolean retval = FALSE(0); |
2022 | |
2023 | sysdir = g_strconcat (SYSFS_POWER_SUPPLIES"/sys/class/power_supply/", sysentry, NULL((void*)0)); |
2024 | if (!access (sysdir, F_OK0 | R_OK4)) |
2025 | { |
2026 | /* |
2027 | * Read the type of this power source, and setup the appropriate |
2028 | * entry for it. |
2029 | */ |
2030 | gchar *type; |
2031 | gchar buf[64]; |
2032 | |
2033 | type = g_strconcat (sysdir, "/type", NULL((void*)0)); |
2034 | if (_GK.debug_level & DEBUG_BATTERY0x8000) |
2035 | g_debug ("setup_sysfs_power_entry: checking %s\n", type); |
2036 | if (read_sysfs_entry (buf, sizeof (buf), type)) |
2037 | { |
2038 | if (!strcasecmp (buf, SYSFS_TYPE_AC_ADAPTER"mains")) |
2039 | retval = setup_sysfs_ac_power (sysdir); |
2040 | else if (!strcasecmp (buf, SYSFS_TYPE_BATTERY"battery")) |
2041 | retval = setup_sysfs_battery (sysdir); |
2042 | else if (_GK.debug_level & DEBUG_BATTERY0x8000) |
2043 | g_debug ("setup_sysfs_power_entry: unknown power type: %s\n", |
2044 | buf); |
2045 | } |
2046 | g_free (type); |
2047 | } |
2048 | g_free (sysdir); |
2049 | |
2050 | return retval; |
2051 | } |
2052 | |
2053 | static gboolean |
2054 | sysfs_power_setup (void) |
2055 | { |
2056 | DIR *d; |
2057 | struct dirent *de; |
2058 | gboolean retval = FALSE(0); |
2059 | |
2060 | if (_GK.debug_level & DEBUG_BATTERY0x8000) |
2061 | g_debug ("sysfs_power_setup() entry\n"); |
2062 | if ((d = opendir (SYSFS_POWER_SUPPLIES"/sys/class/power_supply/")) == NULL((void*)0)) |
2063 | return retval; |
2064 | |
2065 | while ((de = readdir (d)) != NULL((void*)0)) |
2066 | { |
2067 | if ( !strcmp (de->d_name, ".")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (de->d_name) && __builtin_constant_p (".") && (__s1_len = strlen (de->d_name), __s2_len = strlen ("."), (!((size_t)(const void *)((de->d_name) + 1) - (size_t)(const void *)(de->d_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((".") + 1) - (size_t)(const void * )(".") == 1) || __s2_len >= 4)) ? __builtin_strcmp (de-> d_name, ".") : (__builtin_constant_p (de->d_name) && ((size_t)(const void *)((de->d_name) + 1) - (size_t)(const void *)(de->d_name) == 1) && (__s1_len = strlen ( de->d_name), __s1_len < 4) ? (__builtin_constant_p ("." ) && ((size_t)(const void *)((".") + 1) - (size_t)(const void *)(".") == 1) ? __builtin_strcmp (de->d_name, ".") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("."); int __result = (((const unsigned char *) (const char *) (de->d_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (de->d_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (de->d_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (de->d_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p (".") && ((size_t)(const void *)((".") + 1) - (size_t)(const void *)(".") == 1) && (__s2_len = strlen ("."), __s2_len < 4) ? (__builtin_constant_p (de->d_name) && ((size_t)(const void *)((de->d_name ) + 1) - (size_t)(const void *)(de->d_name) == 1) ? __builtin_strcmp (de->d_name, ".") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (de->d_name ); int __result = (((const unsigned char *) (const char *) ("." ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (".") )[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (".") )[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("."))[ 3] - __s2[3]); } } __result; })))) : __builtin_strcmp (de-> d_name, ".")))); }) |
2068 | || !strcmp (de->d_name, "..")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (de->d_name) && __builtin_constant_p ("..") && (__s1_len = strlen (de->d_name), __s2_len = strlen ("..") , (!((size_t)(const void *)((de->d_name) + 1) - (size_t)(const void *)(de->d_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("..") + 1) - (size_t)(const void * )("..") == 1) || __s2_len >= 4)) ? __builtin_strcmp (de-> d_name, "..") : (__builtin_constant_p (de->d_name) && ((size_t)(const void *)((de->d_name) + 1) - (size_t)(const void *)(de->d_name) == 1) && (__s1_len = strlen ( de->d_name), __s1_len < 4) ? (__builtin_constant_p (".." ) && ((size_t)(const void *)(("..") + 1) - (size_t)(const void *)("..") == 1) ? __builtin_strcmp (de->d_name, "..") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (".."); int __result = (((const unsigned char *) (const char *) (de->d_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (de->d_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (de->d_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (de->d_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("..") && ((size_t)(const void *)(("..") + 1) - (size_t)(const void *)("..") == 1) && (__s2_len = strlen (".."), __s2_len < 4) ? (__builtin_constant_p (de->d_name) && ((size_t)(const void *)((de->d_name ) + 1) - (size_t)(const void *)(de->d_name) == 1) ? __builtin_strcmp (de->d_name, "..") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (de->d_name ); int __result = (((const unsigned char *) (const char *) (".." ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (".." ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (".." ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("..")) [3] - __s2[3]); } } __result; })))) : __builtin_strcmp (de-> d_name, "..")))); })) |
2069 | { |
2070 | continue; |
2071 | } |
2072 | retval |= setup_sysfs_power_entry (de->d_name); |
2073 | } |
2074 | closedir (d); |
2075 | |
2076 | return retval; |
2077 | } |
2078 | |
2079 | |
2080 | /* ---------------------------- */ |
2081 | /* APM battery interface */ |
2082 | |
2083 | #define PROC_APM_FILE"/proc/apm" "/proc/apm" |
2084 | |
2085 | /* From: arch/i386/kernel/apm.c |
2086 | | |
2087 | | 0) Linux driver version (this will change if format changes) |
2088 | | 1) APM BIOS Version. Usually 1.0, 1.1 or 1.2. |
2089 | | 2) APM flags from APM Installation Check (0x00): |
2090 | | bit 0: APM_16_BIT_SUPPORT |
2091 | | bit 1: APM_32_BIT_SUPPORT |
2092 | | bit 2: APM_IDLE_SLOWS_CLOCK |
2093 | | bit 3: APM_BIOS_DISABLED |
2094 | | bit 4: APM_BIOS_DISENGAGED |
2095 | | 3) AC line status |
2096 | | 0x00: Off-line |
2097 | | 0x01: On-line |
2098 | | 0x02: On backup power (BIOS >= 1.1 only) |
2099 | | 0xff: Unknown |
2100 | | 4) Battery status |
2101 | | 0x00: High |
2102 | | 0x01: Low |
2103 | | 0x02: Critical |
2104 | | 0x03: Charging |
2105 | | 0x04: Selected battery not present (BIOS >= 1.2 only) |
2106 | | 0xff: Unknown |
2107 | | 5) Battery flag |
2108 | | bit 0: High |
2109 | | bit 1: Low |
2110 | | bit 2: Critical |
2111 | | bit 3: Charging |
2112 | | bit 7: No system battery |
2113 | | 0xff: Unknown |
2114 | | 6) Remaining battery life (percentage of charge): |
2115 | | 0-100: valid |
2116 | | -1: Unknown |
2117 | | 7) Remaining battery life (time units): |
2118 | | Number of remaining minutes or seconds |
2119 | | -1: Unknown |
2120 | | 8) min = minutes; sec = seconds |
2121 | */ |
2122 | |
2123 | #define APM_BIOS_VERSION(major, minor)( bios_major > (major) || (bios_major == (major) && bios_minor >= (minor)) ) \ |
2124 | ( bios_major > (major) \ |
2125 | || (bios_major == (major) && bios_minor >= (minor)) \ |
2126 | ) |
2127 | |
2128 | /* AC line status values */ |
2129 | #define APM_ON_LINE1 1 |
2130 | |
2131 | /* Battery status values */ |
2132 | #define APM_CHARGING3 3 |
2133 | #define APM_NOT_PRESENT4 4 |
2134 | |
2135 | /* Battery flag bits */ |
2136 | #define APM_NO_BATTERY0x80 0x80 |
2137 | |
2138 | #define APM_UNKNOWN0xFF 0xFF |
2139 | |
2140 | |
2141 | static void |
2142 | apm_battery_assign(gint id, gint bios_major, gint bios_minor, |
2143 | gint ac_line_status, gint battery_status, gint battery_flag, |
2144 | gint percent, gint time_left, gchar *units) |
2145 | { |
2146 | gboolean available, on_line, charging; |
2147 | |
2148 | if ( (battery_flag != APM_UNKNOWN0xFF && (battery_flag & APM_NO_BATTERY0x80)) |
2149 | || (battery_status == APM_UNKNOWN0xFF && ac_line_status == APM_UNKNOWN0xFF) |
2150 | || (battery_status == APM_NOT_PRESENT4 && APM_BIOS_VERSION(1,2)( bios_major > (1) || (bios_major == (1) && bios_minor >= (2)) )) |
2151 | ) |
2152 | available = FALSE(0); |
2153 | else |
2154 | available = TRUE(!(0)); |
2155 | |
2156 | if (ac_line_status != APM_UNKNOWN0xFF) |
2157 | on_line = (ac_line_status == APM_ON_LINE1) ? TRUE(!(0)) : FALSE(0); |
2158 | else |
2159 | on_line = (battery_status == APM_CHARGING3) ? FALSE(0) : TRUE(!(0)); |
2160 | |
2161 | if (battery_status != APM_UNKNOWN0xFF) |
2162 | charging= (battery_status == APM_CHARGING3) ? TRUE(!(0)) : FALSE(0); |
2163 | else |
2164 | charging = (ac_line_status == APM_ON_LINE1) ? TRUE(!(0)) : FALSE(0); |
2165 | |
2166 | if (!strcmp(units, "sec")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (units) && __builtin_constant_p ("sec") && ( __s1_len = strlen (units), __s2_len = strlen ("sec"), (!((size_t )(const void *)((units) + 1) - (size_t)(const void *)(units) == 1) || __s1_len >= 4) && (!((size_t)(const void *) (("sec") + 1) - (size_t)(const void *)("sec") == 1) || __s2_len >= 4)) ? __builtin_strcmp (units, "sec") : (__builtin_constant_p (units) && ((size_t)(const void *)((units) + 1) - (size_t )(const void *)(units) == 1) && (__s1_len = strlen (units ), __s1_len < 4) ? (__builtin_constant_p ("sec") && ((size_t)(const void *)(("sec") + 1) - (size_t)(const void * )("sec") == 1) ? __builtin_strcmp (units, "sec") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("sec"); int __result = (((const unsigned char *) (const char *) (units))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (units))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (units))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (units))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("sec") && ((size_t)(const void *)(("sec") + 1) - (size_t )(const void *)("sec") == 1) && (__s2_len = strlen ("sec" ), __s2_len < 4) ? (__builtin_constant_p (units) && ((size_t)(const void *)((units) + 1) - (size_t)(const void * )(units) == 1) ? __builtin_strcmp (units, "sec") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (units); int __result = (((const unsigned char *) (const char *) ("sec"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("sec"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("sec"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("sec"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (units, "sec")))); }) && time_left > 0) |
2167 | time_left /= 60; |
2168 | |
2169 | gkrellm_battery_assign_data(id, available, on_line, charging, |
2170 | percent, time_left); |
2171 | } |
2172 | |
2173 | static gboolean |
2174 | apm_battery_data(void) |
2175 | { |
2176 | FILE *f; |
2177 | gchar buf[128], units[32]; |
2178 | gint percent = 0, time_left = 0; |
2179 | gint ac_line_status, battery_status, battery_flag; |
2180 | gint bios_major, bios_minor; |
2181 | gint id, n_batteries = 1; |
2182 | |
2183 | if ((f = fopen(PROC_APM_FILE"/proc/apm", "r")) == NULL((void*)0)) |
2184 | return FALSE(0); |
2185 | fgets(buf, sizeof(buf), f); |
2186 | |
2187 | sscanf(buf, "%*s %d.%d %*x %x %x %x %d%% %d %31s\n", |
2188 | &bios_major, &bios_minor, |
2189 | &ac_line_status, &battery_status, &battery_flag, |
2190 | &percent, &time_left, units); |
2191 | |
2192 | /* If have APM dual battery patch, next line will be number of batteries. |
2193 | */ |
2194 | if (fgets(buf, sizeof(buf), f)) |
2195 | sscanf(buf, "%d\n", &n_batteries); |
2196 | |
2197 | if (n_batteries < 2) |
2198 | apm_battery_assign(0, bios_major, bios_minor, ac_line_status, |
2199 | battery_status, battery_flag, percent, time_left, units); |
2200 | else |
2201 | { |
2202 | apm_battery_assign(GKRELLM_BATTERY_COMPOSITE_ID-1, |
2203 | bios_major, bios_minor, ac_line_status, |
2204 | battery_status, battery_flag, percent, time_left, units); |
2205 | while (n_batteries-- > 0 && fgets(buf, sizeof(buf), f)) |
2206 | { |
2207 | sscanf(buf, "%d %x %x %d%% %d %31s\n", &id, |
2208 | &battery_status, &battery_flag, |
2209 | &percent, &time_left, units); |
2210 | apm_battery_assign(id - 1, bios_major, bios_minor, ac_line_status, |
2211 | battery_status, battery_flag, percent, time_left, units); |
2212 | } |
2213 | } |
2214 | |
2215 | fclose(f); |
2216 | return TRUE(!(0)); |
2217 | } |
2218 | |
2219 | void |
2220 | gkrellm_sys_battery_read_data(void) |
2221 | { |
2222 | GList *list; |
2223 | |
2224 | if (g_sysfs_power_list) |
2225 | { |
2226 | for (list = g_sysfs_power_list; list; list = list->next) |
2227 | sysfs_power_data ((syspower *) (list->data)); |
2228 | } |
2229 | else if (acpi_battery_list) |
2230 | { |
2231 | for (list = acpi_battery_list; list; list = list->next) |
2232 | acpi_battery_data((BatteryFile *)(list->data)); |
2233 | } |
2234 | else |
2235 | apm_battery_data(); |
2236 | } |
2237 | |
2238 | gboolean |
2239 | gkrellm_sys_battery_init() |
2240 | { |
2241 | /* Prefer sysfs power data to /proc/acpi (which is deprecated). |
2242 | | But temporarily allow command line override in case transition trouble |
2243 | */ |
2244 | if (_GK.use_acpi_battery || !sysfs_power_setup ()) |
2245 | acpi_setup(); |
2246 | return TRUE(!(0)); |
2247 | } |
2248 | |
2249 | |
2250 | |
2251 | /* ===================================================================== */ |
2252 | /* Uptime monitor interface */ |
2253 | |
2254 | /* Calculating an uptime based on system time has a fuzzy meaning for |
2255 | | laptops since /proc/uptime does not include time system has been |
2256 | | sleeping. So, read /proc/uptime always. |
2257 | */ |
2258 | time_t |
2259 | gkrellm_sys_uptime_read_uptime(void) |
2260 | { |
2261 | FILE *f; |
2262 | gulong l = 0; |
2263 | |
2264 | if ((f = fopen("/proc/uptime", "r")) != NULL((void*)0)) |
2265 | { |
2266 | fscanf(f, "%lu", &l); |
2267 | fclose(f); |
2268 | } |
2269 | return (time_t) l; |
2270 | } |
2271 | |
2272 | gboolean |
2273 | gkrellm_sys_uptime_init(void) |
2274 | { |
2275 | return TRUE(!(0)); |
2276 | } |
2277 | |
2278 | |
2279 | /* ===================================================================== */ |
2280 | /* Sensor monitor interface */ |
2281 | /* ------- Linux ------------------------------------------------------- */ |
2282 | |
2283 | |
2284 | #define THERMAL_ZONE_DIR"/proc/acpi/thermal_zone" "/proc/acpi/thermal_zone" |
2285 | #define THERMAL_DIR"/proc/acpi/thermal" "/proc/acpi/thermal" |
2286 | #define SYS_THERMAL_DIR"/sys/class/thermal" "/sys/class/thermal" |
2287 | #define SENSORS_DIR"/proc/sys/dev/sensors" "/proc/sys/dev/sensors" |
2288 | #define SYSFS_I2C_DIR"/sys/bus/i2c/devices" "/sys/bus/i2c/devices" |
2289 | #define SYSFS_HWMON_DIR"/sys/class/hwmon" "/sys/class/hwmon" |
2290 | #define UNINORTH_DIR"/sys/devices/temperatures" "/sys/devices/temperatures" |
2291 | #define WINDFARM_DIR"/sys/devices/platform/windfarm.%d" "/sys/devices/platform/windfarm.%d" |
2292 | |
2293 | /* mbmon and hddtemp sensor interfaces are handled in sensors-common.c |
2294 | */ |
2295 | #define LIBSENSORS_INTERFACE1 1 |
2296 | #define THERMAL_INTERFACE2 2 |
2297 | #define THERMAL_ZONE_INTERFACE3 3 |
2298 | #define NVIDIA_SETTINGS_INTERFACE4 4 |
2299 | #define NVCLOCK_INTERFACE5 5 |
2300 | #define IBM_ACPI_INTERFACE6 6 |
2301 | #define UNINORTH_INTERFACE7 7 |
2302 | #define WINDFARM_INTERFACE8 8 |
2303 | #define SYS_THERMAL_INTERFACE9 9 |
2304 | #define NVIDIA_SMI_INTERFACE10 10 |
2305 | |
2306 | #define IBM_ACPI_FAN_FILE"/proc/acpi/ibm/fan" "/proc/acpi/ibm/fan" |
2307 | #define IBM_ACPI_THERMAL"/proc/acpi/ibm/thermal" "/proc/acpi/ibm/thermal" |
2308 | #define IBM_ACPI_CPU_TEMP0 0 |
2309 | #define IBM_ACPI_PCI_TEMP1 1 |
2310 | #define IBM_ACPI_HDD_TEMP2 2 |
2311 | #define IBM_ACPI_GPU_TEMP3 3 |
2312 | #define IBM_ACPI_BAT1_TEMP4 4 |
2313 | #define IBM_ACPI_NA1_TEMP5 5 |
2314 | #define IBM_ACPI_BAT2_TEMP6 6 |
2315 | #define IBM_ACPI_NA2_TEMP7 7 |
2316 | #define IBM_ACPI_FAN8 8 |
2317 | |
2318 | #define SENSOR_NAMES_I2C0 0 |
2319 | #define SENSOR_NAMES_HWMON1 1 |
2320 | #define SENSOR_NAMES_LIBSENSORS2 2 |
2321 | |
2322 | /* 2.2.10 uses libsensors or SYSFS_HWMON_DIR if available, |
2323 | | so try to save users old sensors-config that used SYSFS_I2C_DIR. |
2324 | */ |
2325 | typedef struct |
2326 | { |
2327 | gchar *current_name, |
2328 | *i2c_name, |
2329 | *hwmon_name; |
2330 | } |
2331 | ConfigMap; |
2332 | |
2333 | GList *config_map_list; |
2334 | |
2335 | static gboolean |
2336 | sensors_config_migrate(gchar *current_name, gchar *config_name, |
2337 | gint current, gint config) |
2338 | { |
2339 | ConfigMap *config_map; |
2340 | GList *list; |
2341 | gchar *p0, *p1; |
2342 | gint n; |
2343 | |
2344 | /* Migrating to a libsensor name can be based on |
2345 | | existing detected sysfs names stored in the config_map_list |
2346 | */ |
2347 | if ( ( current == SENSOR_NAMES_LIBSENSORS2 |
2348 | && (config == SENSOR_NAMES_I2C0 || config == SENSOR_NAMES_HWMON1) |
2349 | ) |
2350 | || (current == SENSOR_NAMES_HWMON1 && config == SENSOR_NAMES_I2C0) |
2351 | ) |
2352 | { |
2353 | for (list = config_map_list; list; list = list->next) |
2354 | { |
2355 | config_map = (ConfigMap *) list->data; |
2356 | if ( !strcmp(current_name, config_map->current_name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (current_name) && __builtin_constant_p (config_map-> current_name) && (__s1_len = strlen (current_name), __s2_len = strlen (config_map->current_name), (!((size_t)(const void *)((current_name) + 1) - (size_t)(const void *)(current_name ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((config_map->current_name) + 1) - (size_t)(const void * )(config_map->current_name) == 1) || __s2_len >= 4)) ? __builtin_strcmp (current_name, config_map->current_name) : (__builtin_constant_p (current_name) && ((size_t)(const void *)((current_name ) + 1) - (size_t)(const void *)(current_name) == 1) && (__s1_len = strlen (current_name), __s1_len < 4) ? (__builtin_constant_p (config_map->current_name) && ((size_t)(const void *)((config_map->current_name) + 1) - (size_t)(const void * )(config_map->current_name) == 1) ? __builtin_strcmp (current_name , config_map->current_name) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config_map ->current_name); int __result = (((const unsigned char *) ( const char *) (current_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (current_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (current_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (current_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p (config_map->current_name) && ((size_t)(const void *)((config_map->current_name) + 1) - (size_t)(const void *)(config_map->current_name) == 1) && (__s2_len = strlen (config_map->current_name), __s2_len < 4) ? (__builtin_constant_p (current_name) && ((size_t )(const void *)((current_name) + 1) - (size_t)(const void *)( current_name) == 1) ? __builtin_strcmp (current_name, config_map ->current_name) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (current_name ); int __result = (((const unsigned char *) (const char *) (config_map ->current_name))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (config_map->current_name))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (config_map->current_name))[2] - __s2 [2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (config_map->current_name ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (current_name , config_map->current_name)))); }) |
2357 | && ( ( config_map->i2c_name |
2358 | && !strcmp(config_name, config_map->i2c_name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config_name) && __builtin_constant_p (config_map-> i2c_name) && (__s1_len = strlen (config_name), __s2_len = strlen (config_map->i2c_name), (!((size_t)(const void * )((config_name) + 1) - (size_t)(const void *)(config_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *) ((config_map->i2c_name) + 1) - (size_t)(const void *)(config_map ->i2c_name) == 1) || __s2_len >= 4)) ? __builtin_strcmp (config_name, config_map->i2c_name) : (__builtin_constant_p (config_name) && ((size_t)(const void *)((config_name ) + 1) - (size_t)(const void *)(config_name) == 1) && (__s1_len = strlen (config_name), __s1_len < 4) ? (__builtin_constant_p (config_map->i2c_name) && ((size_t)(const void *) ((config_map->i2c_name) + 1) - (size_t)(const void *)(config_map ->i2c_name) == 1) ? __builtin_strcmp (config_name, config_map ->i2c_name) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config_map->i2c_name ); int __result = (((const unsigned char *) (const char *) (config_name ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (config_name ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (config_name ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (config_name ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( config_map->i2c_name) && ((size_t)(const void *)(( config_map->i2c_name) + 1) - (size_t)(const void *)(config_map ->i2c_name) == 1) && (__s2_len = strlen (config_map ->i2c_name), __s2_len < 4) ? (__builtin_constant_p (config_name ) && ((size_t)(const void *)((config_name) + 1) - (size_t )(const void *)(config_name) == 1) ? __builtin_strcmp (config_name , config_map->i2c_name) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config_name ); int __result = (((const unsigned char *) (const char *) (config_map ->i2c_name))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (config_map->i2c_name))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (config_map->i2c_name))[2] - __s2[ 2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (config_map->i2c_name ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config_name , config_map->i2c_name)))); }) |
2359 | ) |
2360 | || ( config_map->hwmon_name |
2361 | && !strcmp(config_name, config_map->hwmon_name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config_name) && __builtin_constant_p (config_map-> hwmon_name) && (__s1_len = strlen (config_name), __s2_len = strlen (config_map->hwmon_name), (!((size_t)(const void *)((config_name) + 1) - (size_t)(const void *)(config_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *) ((config_map->hwmon_name) + 1) - (size_t)(const void *)(config_map ->hwmon_name) == 1) || __s2_len >= 4)) ? __builtin_strcmp (config_name, config_map->hwmon_name) : (__builtin_constant_p (config_name) && ((size_t)(const void *)((config_name ) + 1) - (size_t)(const void *)(config_name) == 1) && (__s1_len = strlen (config_name), __s1_len < 4) ? (__builtin_constant_p (config_map->hwmon_name) && ((size_t)(const void * )((config_map->hwmon_name) + 1) - (size_t)(const void *)(config_map ->hwmon_name) == 1) ? __builtin_strcmp (config_name, config_map ->hwmon_name) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config_map->hwmon_name ); int __result = (((const unsigned char *) (const char *) (config_name ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (config_name ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (config_name ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (config_name ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( config_map->hwmon_name) && ((size_t)(const void *) ((config_map->hwmon_name) + 1) - (size_t)(const void *)(config_map ->hwmon_name) == 1) && (__s2_len = strlen (config_map ->hwmon_name), __s2_len < 4) ? (__builtin_constant_p (config_name ) && ((size_t)(const void *)((config_name) + 1) - (size_t )(const void *)(config_name) == 1) ? __builtin_strcmp (config_name , config_map->hwmon_name) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config_name ); int __result = (((const unsigned char *) (const char *) (config_map ->hwmon_name))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (config_map->hwmon_name))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (config_map->hwmon_name))[2] - __s2 [2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (config_map->hwmon_name ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config_name , config_map->hwmon_name)))); }) |
2362 | ) |
2363 | ) |
2364 | ) |
2365 | { |
2366 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2367 | { |
2368 | g_debug("migrate name %s->%s: %s -> %s\n", |
2369 | (config == SENSOR_NAMES_I2C0) ? "i2c" : "hwmon", |
2370 | (current == SENSOR_NAMES_LIBSENSORS2) ? |
2371 | "libsensors" : "hwmon", |
2372 | config_name, current_name); |
2373 | } |
2374 | return TRUE(!(0)); |
2375 | } |
2376 | } |
2377 | } |
2378 | |
2379 | /* But changing from a libsensor name to a sysfs name can only be guessed |
2380 | | since libsensors may not be compiled in and so don't have a libsensor |
2381 | | name to test against. |
2382 | */ |
2383 | if ( ( (current == SENSOR_NAMES_I2C0 || current == SENSOR_NAMES_HWMON1) |
2384 | && config == SENSOR_NAMES_LIBSENSORS2 |
2385 | ) |
2386 | /* This case should not happen unless downgrading kernel */ |
2387 | || (current == SENSOR_NAMES_I2C0 && config == SENSOR_NAMES_HWMON1) |
2388 | ) |
2389 | { |
2390 | /* Eg, migrate current sysdep name: w83627ehf-hwmon0/temp1 |
2391 | | from a config sysdep name: w83627ehf@a10/temp1 |
2392 | */ |
2393 | p0 = strchr(current_name, (gint) '-')(__extension__ (__builtin_constant_p ((gint) '-') && ! __builtin_constant_p (current_name) && ((gint) '-') == '\0' ? (char *) __rawmemchr (current_name, (gint) '-') : __builtin_strchr (current_name, (gint) '-'))); |
2394 | n = (p0 ? p0 - current_name : -1); |
2395 | if (n > 0 && !strncmp(current_name, config_name, n)(__extension__ (__builtin_constant_p (n) && ((__builtin_constant_p (current_name) && strlen (current_name) < ((size_t ) (n))) || (__builtin_constant_p (config_name) && strlen (config_name) < ((size_t) (n)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (current_name) && __builtin_constant_p (config_name) && (__s1_len = strlen (current_name), __s2_len = strlen (config_name), (!((size_t) (const void *)((current_name) + 1) - (size_t)(const void *)(current_name ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((config_name) + 1) - (size_t)(const void *)(config_name) == 1) || __s2_len >= 4)) ? __builtin_strcmp (current_name, config_name ) : (__builtin_constant_p (current_name) && ((size_t) (const void *)((current_name) + 1) - (size_t)(const void *)(current_name ) == 1) && (__s1_len = strlen (current_name), __s1_len < 4) ? (__builtin_constant_p (config_name) && ((size_t )(const void *)((config_name) + 1) - (size_t)(const void *)(config_name ) == 1) ? __builtin_strcmp (current_name, config_name) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config_name); int __result = (((const unsigned char *) (const char *) (current_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (current_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (current_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (current_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p (config_name) && ((size_t )(const void *)((config_name) + 1) - (size_t)(const void *)(config_name ) == 1) && (__s2_len = strlen (config_name), __s2_len < 4) ? (__builtin_constant_p (current_name) && (( size_t)(const void *)((current_name) + 1) - (size_t)(const void *)(current_name) == 1) ? __builtin_strcmp (current_name, config_name ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (current_name); int __result = (((const unsigned char *) (const char *) (config_name))[0] - __s2[0]) ; if (__s2_len > 0 && __result == 0) { __result = ( ((const unsigned char *) (const char *) (config_name))[1] - __s2 [1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (config_name))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (config_name))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (current_name , config_name)))); }) : strncmp (current_name, config_name, n )))) |
2396 | { |
2397 | p0 = strrchr(current_name, (gint) '/'); |
2398 | p1 = strrchr(config_name, (gint) '/'); |
2399 | if (p0 && p1 && !strcmp(p0, p1)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (p0) && __builtin_constant_p (p1) && (__s1_len = strlen (p0), __s2_len = strlen (p1), (!((size_t)(const void *)((p0) + 1) - (size_t)(const void *)(p0) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((p1) + 1) - (size_t) (const void *)(p1) == 1) || __s2_len >= 4)) ? __builtin_strcmp (p0, p1) : (__builtin_constant_p (p0) && ((size_t)(const void *)((p0) + 1) - (size_t)(const void *)(p0) == 1) && (__s1_len = strlen (p0), __s1_len < 4) ? (__builtin_constant_p (p1) && ((size_t)(const void *)((p1) + 1) - (size_t) (const void *)(p1) == 1) ? __builtin_strcmp (p0, p1) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (p1); int __result = (((const unsigned char *) (const char *) (p0))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( p0))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (p0 ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (p0))[3 ] - __s2[3]); } } __result; }))) : (__builtin_constant_p (p1) && ((size_t)(const void *)((p1) + 1) - (size_t)(const void *)(p1) == 1) && (__s2_len = strlen (p1), __s2_len < 4) ? (__builtin_constant_p (p0) && ((size_t)(const void *)((p0) + 1) - (size_t)(const void *)(p0) == 1) ? __builtin_strcmp (p0, p1) : (- (__extension__ ({ const unsigned char *__s2 = ( const unsigned char *) (const char *) (p0); int __result = (( (const unsigned char *) (const char *) (p1))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (p1))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (p1))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (p1))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (p0, p1)))); })) |
2400 | { |
2401 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2402 | { |
2403 | g_debug("migrate name %s->%s: %s -> %s\n", |
2404 | (config == SENSOR_NAMES_LIBSENSORS2) ? |
2405 | "libsensors" : "hwmon", |
2406 | (current == SENSOR_NAMES_I2C0) ? "i2c" : "hwmon", |
2407 | config_name, current_name); |
2408 | } |
2409 | return TRUE(!(0)); |
2410 | } |
2411 | } |
2412 | } |
2413 | return FALSE(0); |
2414 | } |
2415 | |
2416 | static gboolean |
2417 | check_voltage_name(const gchar *name, gint *id) |
2418 | { |
2419 | gint i = 0, |
2420 | len; |
2421 | static gint id_default; |
2422 | |
2423 | if (!name) |
2424 | return FALSE(0); |
2425 | len = strlen(name); |
2426 | if (!strncmp(name, "in", 2)(__extension__ (__builtin_constant_p (2) && ((__builtin_constant_p (name) && strlen (name) < ((size_t) (2))) || (__builtin_constant_p ("in") && strlen ("in") < ((size_t) (2)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("in") && (__s1_len = strlen (name ), __s2_len = strlen ("in"), (!((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) || __s1_len >= 4 ) && (!((size_t)(const void *)(("in") + 1) - (size_t) (const void *)("in") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "in") : (__builtin_constant_p (name) && ((size_t )(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) && (__s1_len = strlen (name), __s1_len < 4) ? ( __builtin_constant_p ("in") && ((size_t)(const void * )(("in") + 1) - (size_t)(const void *)("in") == 1) ? __builtin_strcmp (name, "in") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("in"); int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0 ]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1 ]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2 ]); if (__s1_len > 2 && __result == 0) __result = ( ((const unsigned char *) (const char *) (name))[3] - __s2[3]) ; } } __result; }))) : (__builtin_constant_p ("in") && ((size_t)(const void *)(("in") + 1) - (size_t)(const void *) ("in") == 1) && (__s2_len = strlen ("in"), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) ? __builtin_strcmp (name, "in") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("in"))[0] - __s2 [0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("in"))[1] - __s2 [1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("in"))[2] - __s2 [2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("in"))[3] - __s2[3 ]); } } __result; })))) : __builtin_strcmp (name, "in")))); } ) : strncmp (name, "in", 2))) && isdigit(name[2])((*__ctype_b_loc ())[(int) ((name[2]))] & (unsigned short int) _ISdigit)) /* inX */ |
2427 | i = atoi(name + 2); |
2428 | else if (!strncmp(name, "vi", 2)(__extension__ (__builtin_constant_p (2) && ((__builtin_constant_p (name) && strlen (name) < ((size_t) (2))) || (__builtin_constant_p ("vi") && strlen ("vi") < ((size_t) (2)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("vi") && (__s1_len = strlen (name ), __s2_len = strlen ("vi"), (!((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) || __s1_len >= 4 ) && (!((size_t)(const void *)(("vi") + 1) - (size_t) (const void *)("vi") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "vi") : (__builtin_constant_p (name) && ((size_t )(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) && (__s1_len = strlen (name), __s1_len < 4) ? ( __builtin_constant_p ("vi") && ((size_t)(const void * )(("vi") + 1) - (size_t)(const void *)("vi") == 1) ? __builtin_strcmp (name, "vi") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("vi"); int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0 ]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1 ]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2 ]); if (__s1_len > 2 && __result == 0) __result = ( ((const unsigned char *) (const char *) (name))[3] - __s2[3]) ; } } __result; }))) : (__builtin_constant_p ("vi") && ((size_t)(const void *)(("vi") + 1) - (size_t)(const void *) ("vi") == 1) && (__s2_len = strlen ("vi"), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) ? __builtin_strcmp (name, "vi") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("vi"))[0] - __s2 [0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("vi"))[1] - __s2 [1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("vi"))[2] - __s2 [2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("vi"))[3] - __s2[3 ]); } } __result; })))) : __builtin_strcmp (name, "vi")))); } ) : strncmp (name, "vi", 2))) && isdigit(name[3])((*__ctype_b_loc ())[(int) ((name[3]))] & (unsigned short int) _ISdigit)) /* vidX/vinX */ |
2429 | i = atoi(name + 3); |
2430 | else if (!strcmp(name, "vdd")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("vdd") && (__s1_len = strlen (name), __s2_len = strlen ("vdd"), (!((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("vdd") + 1) - (size_t)(const void *)("vdd") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "vdd") : (__builtin_constant_p (name) && ((size_t )(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) && (__s1_len = strlen (name), __s1_len < 4) ? ( __builtin_constant_p ("vdd") && ((size_t)(const void * )(("vdd") + 1) - (size_t)(const void *)("vdd") == 1) ? __builtin_strcmp (name, "vdd") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("vdd"); int __result = (((const unsigned char *) (const char *) (name))[0] - __s2 [0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2 [1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2 [2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name))[3] - __s2[3 ]); } } __result; }))) : (__builtin_constant_p ("vdd") && ((size_t)(const void *)(("vdd") + 1) - (size_t)(const void * )("vdd") == 1) && (__s2_len = strlen ("vdd"), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)( const void *)((name) + 1) - (size_t)(const void *)(name) == 1 ) ? __builtin_strcmp (name, "vdd") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("vdd"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "vdd"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "vdd"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("vdd" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (name , "vdd")))); })) |
2431 | i = 0; |
2432 | else if (isdigit(name[0])((*__ctype_b_loc ())[(int) ((name[0]))] & (unsigned short int) _ISdigit) && name[len - 1] == 'V') /* via686a 2.0V etc */ |
2433 | i = id_default++; |
2434 | else |
2435 | return FALSE(0); |
2436 | if (id) |
2437 | *id = i; |
2438 | return TRUE(!(0)); |
2439 | } |
2440 | |
2441 | #ifdef HAVE_LIBSENSORS1 |
2442 | #include <sensors/sensors.h> |
2443 | |
2444 | static gboolean |
2445 | libsensors_init(void) |
2446 | { |
2447 | gint nr, len, iodev; |
2448 | const sensors_chip_name *name; |
2449 | gchar *label, *busname, *s; |
2450 | gchar id_name[512], sensor_path[512]; |
2451 | gint type, n_sensors_added; |
2452 | ConfigMap *config_map; |
2453 | #if SENSORS_API_VERSION0x432 < 0x400 /* libsensor 3 code */ |
2454 | FILE *f; |
2455 | |
2456 | f = fopen("/etc/sensors.conf", "r"); |
2457 | if (!f) |
2458 | { |
2459 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2460 | g_debug("libsensors: could not open /etc/sensors.conf\n"); |
2461 | return FALSE(0); |
2462 | } |
2463 | |
2464 | if (sensors_init(f) != 0) |
2465 | { |
2466 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2467 | g_debug("libsensors: init failed!\n"); |
2468 | return FALSE(0); |
2469 | } |
2470 | fclose(f); |
2471 | |
2472 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2473 | g_debug("libsensors: init OK\n"); |
2474 | |
2475 | n_sensors_added = 0; |
2476 | nr = 0; |
2477 | while ((name = sensors_get_detected_chips(&nr))) |
2478 | { |
2479 | const sensors_feature_data *feature; |
2480 | gint nr1 = 0, nr2 = 0; |
2481 | while ((feature = sensors_get_all_features(*name, &nr1, &nr2))) |
2482 | { |
2483 | if ( sensors_get_ignored(*name, feature->number) |
2484 | && feature->mapping == SENSORS_NO_MAPPING |
2485 | ) |
2486 | { |
2487 | if (name->bus >= 0) |
2488 | snprintf(id_name, sizeof(id_name), "%s@%d:%x/%s", |
2489 | name->prefix, name->bus, name->addr, feature->name); |
2490 | else |
2491 | snprintf(id_name, sizeof(id_name), "%s@%x/%s", |
2492 | name->prefix, name->addr, feature->name); |
2493 | /* We need to store both the prefix and the busname, but we |
2494 | | only have one string, so concat them together separated by : |
2495 | */ |
2496 | snprintf(sensor_path, sizeof (sensor_path), "%s:%s", |
2497 | name->prefix, name->busname ? name->busname : "NULL"); |
2498 | |
2499 | if (!strncmp(feature->name, "temp", 4)(__extension__ (__builtin_constant_p (4) && ((__builtin_constant_p (feature->name) && strlen (feature->name) < ((size_t) (4))) || (__builtin_constant_p ("temp") && strlen ("temp") < ((size_t) (4)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (feature->name) && __builtin_constant_p ("temp") && (__s1_len = strlen (feature->name), __s2_len = strlen ("temp"), (!( (size_t)(const void *)((feature->name) + 1) - (size_t)(const void *)(feature->name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("temp") + 1) - (size_t)(const void *)("temp") == 1) || __s2_len >= 4)) ? __builtin_strcmp (feature ->name, "temp") : (__builtin_constant_p (feature->name) && ((size_t)(const void *)((feature->name) + 1) - (size_t)(const void *)(feature->name) == 1) && (__s1_len = strlen (feature->name), __s1_len < 4) ? (__builtin_constant_p ("temp") && ((size_t)(const void *)(("temp") + 1) - ( size_t)(const void *)("temp") == 1) ? __builtin_strcmp (feature ->name, "temp") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("temp"); int __result = (((const unsigned char *) (const char *) (feature->name ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (feature ->name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ( feature->name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (feature->name))[3] - __s2[3]); } } __result; }))) : ( __builtin_constant_p ("temp") && ((size_t)(const void *)(("temp") + 1) - (size_t)(const void *)("temp") == 1) && (__s2_len = strlen ("temp"), __s2_len < 4) ? (__builtin_constant_p (feature->name) && ((size_t)(const void *)((feature ->name) + 1) - (size_t)(const void *)(feature->name) == 1) ? __builtin_strcmp (feature->name, "temp") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (feature->name); int __result = (((const unsigned char *) (const char *) ("temp"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("temp"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("temp"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("temp"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (feature->name, "temp")))); }) : strncmp (feature->name, "temp", 4)))) |
2500 | type = SENSOR_TEMPERATURE0; |
2501 | else if (!strncmp(feature->name, "fan", 3)(__extension__ (__builtin_constant_p (3) && ((__builtin_constant_p (feature->name) && strlen (feature->name) < ((size_t) (3))) || (__builtin_constant_p ("fan") && strlen ("fan") < ((size_t) (3)))) ? __extension__ ({ size_t __s1_len , __s2_len; (__builtin_constant_p (feature->name) && __builtin_constant_p ("fan") && (__s1_len = strlen ( feature->name), __s2_len = strlen ("fan"), (!((size_t)(const void *)((feature->name) + 1) - (size_t)(const void *)(feature ->name) == 1) || __s1_len >= 4) && (!((size_t)( const void *)(("fan") + 1) - (size_t)(const void *)("fan") == 1) || __s2_len >= 4)) ? __builtin_strcmp (feature->name , "fan") : (__builtin_constant_p (feature->name) && ((size_t)(const void *)((feature->name) + 1) - (size_t)(const void *)(feature->name) == 1) && (__s1_len = strlen (feature->name), __s1_len < 4) ? (__builtin_constant_p ("fan") && ((size_t)(const void *)(("fan") + 1) - (size_t )(const void *)("fan") == 1) ? __builtin_strcmp (feature-> name, "fan") : (__extension__ ({ const unsigned char *__s2 = ( const unsigned char *) (const char *) ("fan"); int __result = (((const unsigned char *) (const char *) (feature->name)) [0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (feature ->name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ( feature->name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (feature->name))[3] - __s2[3]); } } __result; }))) : ( __builtin_constant_p ("fan") && ((size_t)(const void * )(("fan") + 1) - (size_t)(const void *)("fan") == 1) && (__s2_len = strlen ("fan"), __s2_len < 4) ? (__builtin_constant_p (feature->name) && ((size_t)(const void *)((feature ->name) + 1) - (size_t)(const void *)(feature->name) == 1) ? __builtin_strcmp (feature->name, "fan") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (feature->name); int __result = (((const unsigned char *) (const char *) ("fan"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("fan"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("fan"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char * ) (const char *) ("fan"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (feature->name, "fan")))); }) : strncmp ( feature->name, "fan", 3)))) |
2502 | type = SENSOR_FAN1; |
2503 | else if (check_voltage_name(feature->name, NULL((void*)0))) |
2504 | type = SENSOR_VOLTAGE2; |
2505 | else |
2506 | { |
2507 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2508 | g_debug("libsensors: error determining type for: %s\n", |
2509 | id_name); |
2510 | continue; |
2511 | } |
2512 | |
2513 | /* failsafe tests, will bus and addr fit in 16 bits (signed) |
2514 | */ |
2515 | if (name->bus != ((name->bus << 16) >> 16)) |
2516 | { |
2517 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2518 | g_debug("libsensors: bus bigger than 16 bits: %s\n", |
2519 | id_name); |
2520 | continue; |
2521 | } |
2522 | if (name->addr != ((name->addr << 16) >> 16)) |
2523 | { |
2524 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2525 | g_debug("libsensors: addr bigger than 16 bits: %s\n", |
2526 | id_name); |
2527 | continue; |
2528 | } |
2529 | |
2530 | /* notice that we store the bus and addr both in iodev as |
2531 | | 2 _signed 16 bit ints. */ |
2532 | iodev = (name->bus & 0xFFFF) | (name->addr << 16); |
2533 | busname = name->busname; |
2534 | |
2535 | if (sensors_get_label(*name, feature->number, &label) != 0) |
2536 | { |
2537 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2538 | g_debug("libsensors: error getting label for: %s\n", |
2539 | id_name); |
2540 | label = NULL((void*)0); |
2541 | } |
2542 | #else /* libsensors4 code */ |
2543 | if (sensors_init(NULL((void*)0)) != 0) |
2544 | { |
2545 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2546 | g_debug("libsensors: init failed!\n"); |
2547 | return FALSE(0); |
2548 | } |
2549 | |
2550 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2551 | g_debug("libsensors: init OK\n"); |
2552 | |
2553 | n_sensors_added = 0; |
2554 | nr = 0; |
2555 | while ((name = sensors_get_detected_chips(NULL((void*)0), &nr))) |
2556 | { |
2557 | const sensors_subfeature *feature; |
2558 | const sensors_feature *main_feature; |
2559 | gint nr1 = 0; |
2560 | while ((main_feature = sensors_get_features(name, &nr1))) |
2561 | { |
2562 | switch (name->bus.type) |
2563 | { |
2564 | case SENSORS_BUS_TYPE_I2C0: |
2565 | case SENSORS_BUS_TYPE_SPI3: |
2566 | snprintf(id_name, sizeof(id_name), "%s@%d:%x/%s", |
2567 | name->prefix, name->bus.nr, name->addr, main_feature->name); |
2568 | break; |
2569 | default: |
2570 | snprintf(id_name, sizeof(id_name), "%s@%x/%s", |
2571 | name->prefix, name->addr, main_feature->name); |
2572 | |
2573 | } |
2574 | /* We need to store both the prefix and the path, but we |
2575 | | only have one string, so concat them together separated by : |
2576 | */ |
2577 | snprintf(sensor_path, sizeof (sensor_path), "%s:%s", |
2578 | name->prefix, name->path ? name->path : "NULL"); |
2579 | |
2580 | switch (main_feature->type) |
2581 | { |
2582 | case SENSORS_FEATURE_IN: |
2583 | type = SENSOR_VOLTAGE2; |
2584 | feature = sensors_get_subfeature(name, |
2585 | main_feature, SENSORS_SUBFEATURE_IN_INPUT); |
2586 | break; |
2587 | case SENSORS_FEATURE_FAN: |
2588 | type = SENSOR_FAN1; |
2589 | feature = sensors_get_subfeature(name, |
2590 | main_feature, SENSORS_SUBFEATURE_FAN_INPUT); |
2591 | break; |
2592 | case SENSORS_FEATURE_TEMP: |
2593 | type = SENSOR_TEMPERATURE0; |
2594 | feature = sensors_get_subfeature(name, |
2595 | main_feature, SENSORS_SUBFEATURE_TEMP_INPUT); |
2596 | break; |
2597 | default: |
2598 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2599 | g_debug("libsensors: error determining type for: %s\n", |
2600 | id_name); |
2601 | continue; |
2602 | } |
2603 | |
2604 | if (!feature) |
2605 | { |
2606 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2607 | g_debug("libsensors: error could not get input subfeature for: %s\n", |
2608 | id_name); |
2609 | continue; |
2610 | } |
2611 | |
2612 | /* failsafe tests, will bus type and nr fit in 8 bits |
2613 | signed and addr fit in 16 bits signed ? |
2614 | */ |
2615 | if (name->bus.type != ((name->bus.type << 24) >> 24)) |
2616 | { |
2617 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2618 | g_debug("libsensors: bus-type bigger than 8 bits: %s\n", |
2619 | id_name); |
2620 | continue; |
2621 | } |
2622 | if (name->bus.nr != ((name->bus.nr << 24) >> 24)) |
2623 | { |
2624 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2625 | g_debug("libsensors: bus-nr bigger than 8 bits: %s\n", |
2626 | id_name); |
2627 | continue; |
2628 | } |
2629 | if (name->addr != ((name->addr << 16) >> 16)) |
2630 | { |
2631 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2632 | g_debug("libsensors: addr bigger than 16 bits: %s\n", |
2633 | id_name); |
2634 | continue; |
2635 | } |
2636 | |
2637 | /* notice that we store the bus id, type and addr in |
2638 | iodev as 2 signed 8 bit ints and one 16 bit int */ |
2639 | iodev = (name->bus.type & 0xFF) | |
2640 | ((name->bus.nr & 0xFF) << 8) | |
2641 | (name->addr << 16); |
2642 | busname = name->path; |
2643 | |
2644 | label = sensors_get_label(name, main_feature); |
2645 | if (!label && (_GK.debug_level & DEBUG_SENSORS0x80)) |
2646 | g_debug("libsensors: error getting label for: %s\n", |
2647 | id_name); |
2648 | |
2649 | /* additional { to match "if (get_ignored(..) {" |
2650 | from libsensors3 code */ |
2651 | { |
2652 | #endif |
2653 | if (label) |
2654 | { |
2655 | /* Strip some common post/prefixes for smaller default labels |
2656 | */ |
2657 | len = strlen(label); |
2658 | switch (type) |
2659 | { |
2660 | case SENSOR_TEMPERATURE0: |
2661 | if (len > 5 && !strcasecmp(label + len - 5, " Temp")) |
2662 | label[len - 5] = 0; |
2663 | if (len > 12 |
2664 | && !strcasecmp(label + len - 12, " Temperature")) |
2665 | label[len - 12] = 0; |
2666 | break; |
2667 | case SENSOR_FAN1: |
2668 | if (len > 4 && !strcasecmp(label + len - 4, " Fan")) |
2669 | label[len - 4] = 0; |
2670 | if (len > 10 |
2671 | && !strcasecmp(label + len - 10, " FAN Speed")) |
2672 | label[len - 10] = 0; |
2673 | break; |
2674 | case SENSOR_VOLTAGE2: |
2675 | if (len > 8 && !strcasecmp(label + len - 8, " Voltage")) |
2676 | label[len - 8] = 0; |
2677 | if (!strncmp(label, "ATX ", 4)(__extension__ (__builtin_constant_p (4) && ((__builtin_constant_p (label) && strlen (label) < ((size_t) (4))) || (__builtin_constant_p ("ATX ") && strlen ("ATX ") < ((size_t) (4)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (label) && __builtin_constant_p ("ATX ") && (__s1_len = strlen ( label), __s2_len = strlen ("ATX "), (!((size_t)(const void *) ((label) + 1) - (size_t)(const void *)(label) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("ATX ") + 1) - (size_t)(const void *)("ATX ") == 1) || __s2_len >= 4)) ? __builtin_strcmp (label, "ATX ") : (__builtin_constant_p (label ) && ((size_t)(const void *)((label) + 1) - (size_t)( const void *)(label) == 1) && (__s1_len = strlen (label ), __s1_len < 4) ? (__builtin_constant_p ("ATX ") && ((size_t)(const void *)(("ATX ") + 1) - (size_t)(const void * )("ATX ") == 1) ? __builtin_strcmp (label, "ATX ") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("ATX "); int __result = (((const unsigned char *) ( const char *) (label))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (label))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (label))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (label))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("ATX ") && ((size_t)(const void *)(("ATX ") + 1) - ( size_t)(const void *)("ATX ") == 1) && (__s2_len = strlen ("ATX "), __s2_len < 4) ? (__builtin_constant_p (label) && ((size_t)(const void *)((label) + 1) - (size_t)(const void * )(label) == 1) ? __builtin_strcmp (label, "ATX ") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (label); int __result = (((const unsigned char *) (const char *) ("ATX "))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("ATX "))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("ATX "))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("ATX "))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (label, "ATX ")))); }) : strncmp (label, "ATX ", 4)))) |
2678 | memmove(label, label + 4, strlen (label + 4) + 1); |
2679 | break; |
2680 | } |
2681 | } |
2682 | /* Default factor of zero tells sensor.c |
2683 | | that sensor formula is handled, ie via |
2684 | | /etc/sensors.conf. |
2685 | */ |
2686 | gkrellm_sensors_add_sensor(type, sensor_path, id_name, |
2687 | feature->number, iodev, |
2688 | LIBSENSORS_INTERFACE1, 0.0, 0.0, |
2689 | NULL((void*)0), label); |
2690 | ++n_sensors_added; |
2691 | if (label) |
2692 | free(label); |
2693 | |
2694 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2695 | g_debug("%s %s %x\n", |
2696 | sensor_path, id_name, |
2697 | iodev); |
2698 | |
2699 | if ( busname |
2700 | && (s = strrchr(busname, '/')) != NULL((void*)0) |
2701 | && *(s + 1) |
2702 | ) |
2703 | { |
2704 | config_map = g_new0(ConfigMap, 1)(ConfigMap *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s = sizeof (ConfigMap); gpointer __p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) && (__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s); __p ; })); |
2705 | config_map->current_name = g_strdup(id_name); |
2706 | config_map->i2c_name = g_strdup_printf("%s-%s/%s", |
2707 | name->prefix, s + 1, feature->name); |
2708 | config_map->hwmon_name = g_strdup_printf("%s-%s/%s", |
2709 | name->prefix, "hwmon0", feature->name); |
2710 | config_map_list = |
2711 | g_list_append(config_map_list, config_map); |
2712 | } |
2713 | } |
2714 | } |
2715 | } |
2716 | return ((n_sensors_added > 0) ? TRUE(!(0)) : FALSE(0)); |
2717 | } |
2718 | |
2719 | gboolean |
2720 | libsensors_get_value(char *sensor_path, int id, int iodev, float *value) |
2721 | { |
2722 | char *p; |
2723 | sensors_chip_name name; |
2724 | double val; |
2725 | int result; |
2726 | |
2727 | /* fill name */ |
2728 | p = strchr(sensor_path, ':')(__extension__ (__builtin_constant_p (':') && !__builtin_constant_p (sensor_path) && (':') == '\0' ? (char *) __rawmemchr (sensor_path, ':') : __builtin_strchr (sensor_path, ':'))); |
2729 | if (!p) |
2730 | { |
2731 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
2732 | g_debug("libsensors: error parsing sensor_path: %s\n", |
2733 | sensor_path); |
2734 | return FALSE(0); |
2735 | } |
2736 | *p = 0; /* We must undo this !! (or make a copy) */ |
2737 | name.prefix = sensor_path; |
2738 | name.addr = iodev >> 16; |
2739 | #if SENSORS_API_VERSION0x432 < 0x400 /* libsensor 3 code */ |
2740 | name.bus = (iodev << 16) >> 16; /* sign extend the low 16 bits */ |
2741 | name.busname = p + 1; |
2742 | if (!strcmp(name.busname, "NULL")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name.busname) && __builtin_constant_p ("NULL") && (__s1_len = strlen (name.busname), __s2_len = strlen ("NULL" ), (!((size_t)(const void *)((name.busname) + 1) - (size_t)(const void *)(name.busname) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)(("NULL") + 1) - (size_t)(const void * )("NULL") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name .busname, "NULL") : (__builtin_constant_p (name.busname) && ((size_t)(const void *)((name.busname) + 1) - (size_t)(const void *)(name.busname) == 1) && (__s1_len = strlen (name .busname), __s1_len < 4) ? (__builtin_constant_p ("NULL") && ((size_t)(const void *)(("NULL") + 1) - (size_t)(const void * )("NULL") == 1) ? __builtin_strcmp (name.busname, "NULL") : ( __extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("NULL"); int __result = (((const unsigned char *) (const char *) (name.busname))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name.busname))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name.busname))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name.busname))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("NULL") && ((size_t)( const void *)(("NULL") + 1) - (size_t)(const void *)("NULL") == 1) && (__s2_len = strlen ("NULL"), __s2_len < 4) ? (__builtin_constant_p (name.busname) && ((size_t)(const void *)((name.busname) + 1) - (size_t)(const void *)(name.busname ) == 1) ? __builtin_strcmp (name.busname, "NULL") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name.busname); int __result = (((const unsigned char *) (const char *) ("NULL"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("NULL"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("NULL"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("NULL"))[3] - __s2[3]); } } __result; })) )) : __builtin_strcmp (name.busname, "NULL")))); })) |
2743 | name.busname = NULL((void*)0); |
2744 | |
2745 | result = sensors_get_feature(name, id, &val) == 0; |
2746 | |
2747 | if (!result && (_GK.debug_level & DEBUG_SENSORS0x80)) |
2748 | { |
2749 | if (name.bus >= 0) |
2750 | g_debug( |
2751 | "libsensors: error getting value for: %s@%d:%x feature: %d\n", |
2752 | name.prefix, name.bus, name.addr, id); |
2753 | else |
2754 | g_debug("libsensors: error getting value for: %s@%x feature: %d\n", |
2755 | name.prefix, name.addr, id); |
2756 | } |
2757 | |
2758 | #else /* libsensors4 code */ |
2759 | name.bus.type = (iodev << 24) >> 24; /* sign extend the low 8 bits */ |
2760 | name.bus.nr = (iodev << 16) >> 24; /* sign extend the 2nd byte */ |
2761 | name.path = p + 1; |
2762 | if (!strcmp(name.path, "NULL")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name.path) && __builtin_constant_p ("NULL") && (__s1_len = strlen (name.path), __s2_len = strlen ("NULL"), ( !((size_t)(const void *)((name.path) + 1) - (size_t)(const void *)(name.path) == 1) || __s1_len >= 4) && (!((size_t )(const void *)(("NULL") + 1) - (size_t)(const void *)("NULL" ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (name.path, "NULL" ) : (__builtin_constant_p (name.path) && ((size_t)(const void *)((name.path) + 1) - (size_t)(const void *)(name.path) == 1) && (__s1_len = strlen (name.path), __s1_len < 4) ? (__builtin_constant_p ("NULL") && ((size_t)(const void *)(("NULL") + 1) - (size_t)(const void *)("NULL") == 1) ? __builtin_strcmp (name.path, "NULL") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("NULL"); int __result = (((const unsigned char *) (const char *) (name.path))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name.path))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name.path))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name.path))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("NULL") && ((size_t)(const void *)(("NULL") + 1) - ( size_t)(const void *)("NULL") == 1) && (__s2_len = strlen ("NULL"), __s2_len < 4) ? (__builtin_constant_p (name.path ) && ((size_t)(const void *)((name.path) + 1) - (size_t )(const void *)(name.path) == 1) ? __builtin_strcmp (name.path , "NULL") : (- (__extension__ ({ const unsigned char *__s2 = ( const unsigned char *) (const char *) (name.path); int __result = (((const unsigned char *) (const char *) ("NULL"))[0] - __s2 [0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("NULL"))[1] - __s2 [1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("NULL"))[2] - __s2 [2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("NULL"))[3] - __s2 [3]); } } __result; })))) : __builtin_strcmp (name.path, "NULL" )))); })) |
2763 | name.path = NULL((void*)0); |
2764 | |
2765 | result = sensors_get_value(&name, id, &val) == 0; |
2766 | |
2767 | if (!result && (_GK.debug_level & DEBUG_SENSORS0x80)) |
2768 | { |
2769 | switch (name.bus.type) |
2770 | { |
2771 | case SENSORS_BUS_TYPE_I2C0: |
2772 | case SENSORS_BUS_TYPE_SPI3: |
2773 | g_debug( |
2774 | "libsensors: error getting value for: %s@%d:%x feature: %d\n", |
2775 | name.prefix, (int)name.bus.nr, name.addr, id); |
2776 | break; |
2777 | default: |
2778 | g_debug("libsensors: error getting value for: %s@%x feature: %d\n", |
2779 | name.prefix, name.addr, id); |
2780 | } |
2781 | } |
2782 | #endif |
2783 | |
2784 | if (value) |
2785 | *value = val; |
2786 | |
2787 | *p = ':'; /* !!! */ |
2788 | return result; |
2789 | } |
2790 | |
2791 | #endif /* HAVE_LIBSENSORS */ |
2792 | |
2793 | typedef struct |
2794 | { |
2795 | gchar *name; |
2796 | gfloat factor; |
2797 | gfloat offset; |
2798 | gchar *vref; |
2799 | } |
2800 | VoltDefault; |
2801 | |
2802 | /* Tables of voltage correction factors and offsets derived from the |
2803 | | compute lines in sensors.conf. See the README file. |
2804 | */ |
2805 | /* "lm78-*" "lm78-j-*" "lm79-*" "w83781d-*" "sis5595-*" "as99127f-*" */ |
2806 | /* Values from LM78/LM79 data sheets */ |
2807 | static VoltDefault voltdefault0[] = |
2808 | { |
2809 | { "Vcor1", 1.0, 0, NULL((void*)0) }, |
2810 | { "Vcor2", 1.0, 0, NULL((void*)0) }, |
2811 | { "+3.3V", 1.0, 0, NULL((void*)0) }, |
2812 | { "+5V", 1.68, 0, NULL((void*)0) }, /* in3 ((6.8/10)+1)*@ */ |
2813 | { "+12V", 4.0, 0, NULL((void*)0) }, /* in4 ((30/10)+1)*@ */ |
2814 | { "-12V", -4.0, 0, NULL((void*)0) }, /* in5 -(240/60)*@ */ |
2815 | { "-5V", -1.667, 0, NULL((void*)0) } /* in6 -(100/60)*@ */ |
2816 | }; |
2817 | |
2818 | /* "w83782d-*" "w83783s-*" "w83627hf-*" */ |
2819 | static VoltDefault voltdefault1[] = |
2820 | { |
2821 | { "Vcor1", 1.0, 0, NULL((void*)0) }, |
2822 | { "Vcor2", 1.0, 0, NULL((void*)0) }, |
2823 | { "+3.3V", 1.0, 0, NULL((void*)0) }, |
2824 | { "+5V", 1.68, 0, NULL((void*)0) }, /* in3 ((6.8/10)+1)*@ */ |
2825 | { "+12V", 3.80, 0, NULL((void*)0) }, /* in4 ((28/10)+1)*@ */ |
2826 | { "-12V", 5.14 , -14.91, NULL((void*)0) }, /* in5 (5.14 * @) - 14.91 */ |
2827 | { "-5V", 3.14 , -7.71, NULL((void*)0) }, /* in6 (3.14 * @) - 7.71 */ |
2828 | { "V5SB", 1.68, 0, NULL((void*)0) }, /* in7 ((6.8/10)+1)*@ */ |
2829 | { "VBat", 1.0, 0, NULL((void*)0) } |
2830 | }; |
2831 | |
2832 | /* lm80-* */ |
2833 | static VoltDefault voltdefault2[] = |
2834 | { |
2835 | { "+5V", 2.633, 0, NULL((void*)0) }, /* in0 (24/14.7 + 1) * @ */ |
2836 | { "VTT", 1.0, 0, NULL((void*)0) }, |
2837 | { "+3.3V", 1.737, 0, NULL((void*)0) }, /* in2 (22.1/30 + 1) * @ */ |
2838 | { "Vcore", 1.474, 0, NULL((void*)0) }, /* in3 (2.8/1.9) * @ */ |
2839 | { "+12V", 6.316, 0, NULL((void*)0) }, /* in4 (160/30.1 + 1) * @ */ |
2840 | { "-12V", 5.482, -4.482, "in0" }, /* in5 (160/35.7)*(@ - in0) + @ */ |
2841 | { "-5V", 3.222, -2.222, "in0" } /* in6 (36/16.2)*(@ - in0) + @ */ |
2842 | }; |
2843 | |
2844 | /* gl518sm-* */ |
2845 | static VoltDefault voltdefault3[] = |
2846 | { |
2847 | { "+5V", 1.0, 0, NULL((void*)0) }, /* vdd */ |
2848 | { "+3.3V", 1.0, 0, NULL((void*)0) }, /* vin1 */ |
2849 | { "+12V", 4.192, 0, NULL((void*)0) }, /* vin2 (197/47)*@ */ |
2850 | { "Vcore", 1.0, 0, NULL((void*)0) } /* vin3 */ |
2851 | }; |
2852 | |
2853 | /* gl520sm-* */ |
2854 | static VoltDefault voltdefault4[] = |
2855 | { |
2856 | { "+5V", 1.0, 0, NULL((void*)0) }, /* vdd */ |
2857 | { "+3.3V", 1.0, 0, NULL((void*)0) }, /* vin1 */ |
2858 | { "+12V", 4.192, 0, NULL((void*)0) }, /* vin2 (197/47)*@ */ |
2859 | { "Vcore", 1.0, 0, NULL((void*)0) }, /* vin3 */ |
2860 | { "-12V", 5.0, -4.0, "vdd" } /* vin4 (5*@)-(4*vdd) */ |
2861 | }; |
2862 | |
2863 | /* via686a-* */ |
2864 | static VoltDefault voltdefault5[] = |
2865 | { |
2866 | { "Vcor", 1.02, 0, NULL((void*)0) }, /* in0 */ |
2867 | { "+2.5V", 1.0, 0, NULL((void*)0) }, /* in1 */ |
2868 | { "I/O", 1.02, 0, NULL((void*)0) }, /* in2 */ |
2869 | { "+5V", 1.009, 0, NULL((void*)0) }, /* in3 */ |
2870 | { "+12V", 1.04, 0, NULL((void*)0) } /* in4 */ |
2871 | }; |
2872 | |
2873 | /* mtp008-* */ |
2874 | static VoltDefault voltdefault6[] = |
2875 | { |
2876 | { "Vcor1", 1.0, 0, NULL((void*)0) }, /* in0 */ |
2877 | { "+3.3V", 1.0, 0, NULL((void*)0) }, /* in1 */ |
2878 | { "+12V", 3.8, 0, NULL((void*)0) }, /* in2 @ * 38 / 10*/ |
2879 | { "Vcor2", 1.0, 0, NULL((void*)0) }, /* in3 */ |
2880 | { "?", 1.0, 0, NULL((void*)0) }, /* in4 */ |
2881 | { "-12V", 5.143, -16.944, NULL((void*)0) }, /* in5 (@ * 36 - 118.61) / 7*/ |
2882 | { "Vtt", 1.0, 0, NULL((void*)0) } /* in6 */ |
2883 | }; |
2884 | |
2885 | /* adm1025-* adm9240-* lm87-* lm81-* ds1780-* */ |
2886 | static VoltDefault voltdefault7[] = |
2887 | { |
2888 | { "2.5V", 1.0, 0, NULL((void*)0) }, /* in0 */ |
2889 | { "Vccp", 1.0, 0, NULL((void*)0) }, /* in1 */ |
2890 | { "3.3V", 1.0, 0, NULL((void*)0) }, /* in2 */ |
2891 | { "5V", 1.0, 0, NULL((void*)0) }, /* in3 */ |
2892 | { "12V", 1.0, 0, NULL((void*)0) }, /* in4 */ |
2893 | { "Vcc", 1.0, 0, NULL((void*)0) } /* in5 */ |
2894 | }; |
2895 | |
2896 | /* it87-* it8705-* it8712 */ |
2897 | static VoltDefault voltdefault8[] = |
2898 | { |
2899 | { "Vcor1", 1.0, 0, NULL((void*)0) }, |
2900 | { "Vcor2", 1.0, 0, NULL((void*)0) }, |
2901 | { "+3.3V", 2.0, 0, NULL((void*)0) }, /* in2 (1 + 1)*@ */ |
2902 | { "+5V", 1.68, 0, NULL((void*)0) }, /* in3 ((6.8/10)+1)*@ */ |
2903 | { "+12V", 4.0, 0, NULL((void*)0) }, /* in4 ((30/10)+1)*@ */ |
2904 | { "-12V", 7.67, -27.36, NULL((void*)0) }, /* in5 (7.67 * @) - 27.36 */ |
2905 | { "-5V", 4.33, -13.64, NULL((void*)0) }, /* in6 (4.33 * @) - 13.64 */ |
2906 | { "Stby", 1.68, 0, NULL((void*)0) }, /* in7 ((6.8/10)+1)*@ */ |
2907 | { "Vbat", 1.0, 0, NULL((void*)0) } /* in8 */ |
2908 | }; |
2909 | |
2910 | /* fscpos */ |
2911 | static VoltDefault voltdefault9[] = |
2912 | { |
2913 | { "+12V", 1.0, 0, NULL((void*)0) }, |
2914 | { "+5V", 1.0, 0, NULL((void*)0) }, |
2915 | { "+3.3V", 1.0, 0, NULL((void*)0) } |
2916 | }; |
2917 | |
2918 | /* abituguru2 */ |
2919 | static VoltDefault voltdefault10[] = |
2920 | { |
2921 | { "Vcor", 1.0, 0, NULL((void*)0) }, |
2922 | { "DDR", 1.0, 0, NULL((void*)0) }, |
2923 | { "DDR VTT",1.0, 0, NULL((void*)0) }, |
2924 | { "CPU VTT",1.0, 0, NULL((void*)0) }, |
2925 | { "MCH 1.5",1.0, 0, NULL((void*)0) }, |
2926 | { "MCH 2.5",1.0, 0, NULL((void*)0) }, |
2927 | { "ICH", 1.0, 0, NULL((void*)0) }, |
2928 | { "+12V", 1.0, 0, NULL((void*)0) }, |
2929 | { "+12V 4P",1.0, 0, NULL((void*)0) }, |
2930 | { "+5V", 1.0, 0, NULL((void*)0) }, |
2931 | { "+3.3V", 1.0, 0, NULL((void*)0) }, |
2932 | { "5VSB", 1.0, 0, NULL((void*)0) } |
2933 | }; |
2934 | |
2935 | /* abituguru - Several variations at: |
2936 | | http://www.lm-sensors.org/wiki/Configurations/Abit |
2937 | */ |
2938 | static VoltDefault voltdefault11[] = |
2939 | { |
2940 | { "Vcor", 1.0, 0, NULL((void*)0) }, |
2941 | { "DDR", 1.0, 0, NULL((void*)0) }, |
2942 | { "DDR VTT",1.0, 0, NULL((void*)0) }, |
2943 | { "NB", 1.0, 0, NULL((void*)0) }, |
2944 | { "SB", 1.0, 0, NULL((void*)0) }, |
2945 | { "HTT", 1.0, 0, NULL((void*)0) }, |
2946 | { "AGP", 1.0, 0, NULL((void*)0) }, |
2947 | { "+5V", 1.788, 0, NULL((void*)0) }, /* in7 @*1.788 */ |
2948 | { "+3.3V", 1.248, 0, NULL((void*)0) }, /* in8 @*1.248 */ |
2949 | { "5VSB", 1.788, 0, NULL((void*)0) }, /* in9 @*1.788 */ |
2950 | { "3VDual", 1.248, 0, NULL((void*)0) } /* in10 @*1.248 */ |
2951 | }; |
2952 | |
2953 | /* "w83627thf-*" "w83637hf-*" */ |
2954 | static VoltDefault voltdefault12[] = |
2955 | { |
2956 | { "Vcore", 1.0, 0, NULL((void*)0) }, |
2957 | { "+12V", 3.80, 0, NULL((void*)0) }, /* in1 ((28/10)+1)*@ */ |
2958 | { "+3.3V", 1.0, 0, NULL((void*)0) }, |
2959 | { "+5V", 1.67, 0, NULL((void*)0) }, /* in3 ((34/51)+1)*@ */ |
2960 | { "-12V", 5.14 , -14.91, NULL((void*)0) }, /* in4 (5.14 * @) - 14.91 */ |
2961 | { "unused", 1.0, 0, NULL((void*)0) }, |
2962 | { "unused", 1.0, 0, NULL((void*)0) }, |
2963 | { "V5SB", 1.68, 0, NULL((void*)0) }, /* in7 ((6.8/10)+1)*@ */ |
2964 | { "VBat", 1.0, 0, NULL((void*)0) } /* in8 ((6.8/10)+1)*@ */ |
2965 | }; |
2966 | |
2967 | typedef struct |
2968 | { |
2969 | gchar *id; |
2970 | gfloat temp; |
2971 | } |
2972 | NvidiaSmi; |
2973 | |
2974 | GList *nvidia_smi_list; |
2975 | |
2976 | static NvidiaSmi * |
2977 | nvidia_smi_lookup(gchar *id) |
2978 | { |
2979 | GList *list; |
2980 | NvidiaSmi *smi; |
2981 | |
2982 | for (list = nvidia_smi_list; list; list = list->next) |
2983 | { |
2984 | smi = (NvidiaSmi *) list->data; |
2985 | if (!strcmp(smi->id, id)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (smi->id) && __builtin_constant_p (id) && (__s1_len = strlen (smi->id), __s2_len = strlen (id), (!( (size_t)(const void *)((smi->id) + 1) - (size_t)(const void *)(smi->id) == 1) || __s1_len >= 4) && (!((size_t )(const void *)((id) + 1) - (size_t)(const void *)(id) == 1) || __s2_len >= 4)) ? __builtin_strcmp (smi->id, id) : (__builtin_constant_p (smi->id) && ((size_t)(const void *)((smi->id) + 1) - (size_t)(const void *)(smi->id) == 1) && ( __s1_len = strlen (smi->id), __s1_len < 4) ? (__builtin_constant_p (id) && ((size_t)(const void *)((id) + 1) - (size_t) (const void *)(id) == 1) ? __builtin_strcmp (smi->id, id) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (id); int __result = (((const unsigned char *) (const char *) (smi->id))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (smi->id))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (smi->id))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (smi->id))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p (id) && ((size_t)(const void *)((id) + 1) - (size_t)(const void *)(id) == 1) && (__s2_len = strlen (id), __s2_len < 4) ? (__builtin_constant_p (smi->id) && ((size_t)(const void *)((smi->id) + 1) - (size_t)(const void *)(smi->id) == 1) ? __builtin_strcmp (smi->id, id) : (- (__extension__ ({ const unsigned char * __s2 = (const unsigned char *) (const char *) (smi->id); int __result = (((const unsigned char *) (const char *) (id))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (id))[1] - __s2[1 ]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (id))[2] - __s2[2]) ; if (__s2_len > 2 && __result == 0) __result = (( (const unsigned char *) (const char *) (id))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (smi->id, id)))); })) |
2986 | return smi; |
2987 | } |
2988 | return NULL((void*)0); |
2989 | } |
2990 | |
2991 | static void |
2992 | sensors_nvidia_smi_add(NvidiaSmi *smi) |
2993 | { |
2994 | gchar *sensor_path, *default_label; |
2995 | gchar id_name[128]; |
2996 | |
2997 | sensor_path = g_strdup_printf("%s", smi->id); |
2998 | snprintf(id_name, sizeof(id_name), "nvidia-smi GPU %s", smi->id); |
2999 | default_label = g_strdup_printf("GPU %s", smi->id); |
3000 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
3001 | sensor_path, id_name, |
3002 | 0, 0, NVIDIA_SMI_INTERFACE10, |
3003 | 1.0, 0.0, NULL((void*)0), default_label); |
3004 | g_free(default_label); |
3005 | g_free(sensor_path); |
3006 | } |
3007 | |
3008 | static gboolean |
3009 | sensors_nvidia_smi_read(gboolean setup) |
3010 | { |
3011 | gint n = 0; |
3012 | gchar *args[] = { "nvidia-smi", "-q", "-a", NULL((void*)0) }; |
3013 | gchar *str, *stmp, id[64]; |
3014 | gchar *output = NULL((void*)0); |
3015 | gchar *errout = NULL((void*)0); |
3016 | gboolean result; |
3017 | gfloat temp; |
3018 | NvidiaSmi *smi; |
3019 | GError *error = NULL((void*)0); |
3020 | |
3021 | result = g_spawn_sync(NULL((void*)0), args, NULL((void*)0), |
3022 | G_SPAWN_SEARCH_PATH, |
3023 | NULL((void*)0), NULL((void*)0), &output, &errout, NULL((void*)0), &error); |
3024 | |
3025 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
3026 | { |
3027 | printf("nvidia-smi: result=%d output=%s stderr=%s\n", |
3028 | (gint) result, |
3029 | output ? output : "(null)", |
3030 | errout ? errout : "(null)"); |
3031 | if (error) |
3032 | printf("\terror=%s\n", error->message); |
3033 | } |
3034 | if (result && output) |
3035 | { |
3036 | str = output; |
3037 | /* Look for GPU N: or GPU X:Y:Z sections, but avoid GPU : lines |
3038 | | Recent nvidia-smi output looks like (eg 270.41.06): |
3039 | | |
3040 | | GPU 0:3:0 |
3041 | | Product Name : GeForce GTX 460 |
3042 | | ... |
3043 | | Temperature |
3044 | | Gpu : 32 C |
3045 | | |
3046 | | Older nvidia-smi output was like (eg 260.19.29): |
3047 | | |
3048 | | GPU 0: |
3049 | | Product Name : GeForce GTX 285 |
3050 | | ... |
3051 | | Temperature : 65 C |
3052 | | Fan Speed : 100% |
3053 | | Utilization |
3054 | | GPU : 84% |
3055 | | ... |
3056 | */ |
3057 | while ((str = g_strstr_len(str, -1, "GPU ")) != NULL((void*)0)) |
3058 | { |
3059 | str += 3; |
3060 | if ( sscanf(str, " %63s", id) != 1 |
3061 | || !strcmp(id, ":")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (id) && __builtin_constant_p (":") && (__s1_len = strlen (id), __s2_len = strlen (":"), (!((size_t)(const void *)((id) + 1) - (size_t)(const void *)(id) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((":") + 1) - (size_t )(const void *)(":") == 1) || __s2_len >= 4)) ? __builtin_strcmp (id, ":") : (__builtin_constant_p (id) && ((size_t)( const void *)((id) + 1) - (size_t)(const void *)(id) == 1) && (__s1_len = strlen (id), __s1_len < 4) ? (__builtin_constant_p (":") && ((size_t)(const void *)((":") + 1) - (size_t )(const void *)(":") == 1) ? __builtin_strcmp (id, ":") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (":"); int __result = (((const unsigned char *) (const char *) (id))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( id))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (id ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (id))[3 ] - __s2[3]); } } __result; }))) : (__builtin_constant_p (":" ) && ((size_t)(const void *)((":") + 1) - (size_t)(const void *)(":") == 1) && (__s2_len = strlen (":"), __s2_len < 4) ? (__builtin_constant_p (id) && ((size_t)(const void *)((id) + 1) - (size_t)(const void *)(id) == 1) ? __builtin_strcmp (id, ":") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (id); int __result = ( ((const unsigned char *) (const char *) (":"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = ( ((const unsigned char *) (const char *) (":"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = ( ((const unsigned char *) (const char *) (":"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = ((( const unsigned char *) (const char *) (":"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (id, ":")))); }) |
3062 | ) |
3063 | continue; |
3064 | if ((str = g_strstr_len(str, -1, "Temperature")) != NULL((void*)0)) |
3065 | { |
3066 | str += 11; |
3067 | if (sscanf(str, " : %f", &temp) != 1) |
3068 | { |
3069 | stmp = str; |
3070 | str = g_strstr_len(str, -1, "Gpu"); |
3071 | if (!str) |
3072 | { |
3073 | str = stmp; |
3074 | continue; |
3075 | } |
3076 | str += 3; |
3077 | if (sscanf(str, " : %f", &temp) != 1) |
3078 | continue; |
3079 | } |
3080 | if (setup) |
3081 | { |
3082 | smi = g_new0(NvidiaSmi, 1)(NvidiaSmi *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s = sizeof (NvidiaSmi); gpointer __p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) && (__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s); __p ; })); |
3083 | smi->id = g_strdup(id); |
3084 | smi->temp = temp; |
3085 | nvidia_smi_list = g_list_append(nvidia_smi_list, smi); |
3086 | sensors_nvidia_smi_add(smi); |
3087 | ++n; |
3088 | } |
3089 | else if ((smi = nvidia_smi_lookup(id)) != NULL((void*)0)) |
3090 | smi->temp = temp; |
3091 | } |
3092 | } |
3093 | } |
3094 | if (output) |
3095 | g_free(output); |
3096 | if (errout) |
3097 | g_free(errout); |
3098 | if (error) |
3099 | g_error_free(error); |
3100 | |
3101 | if (setup && (_GK.debug_level & DEBUG_SENSORS0x80)) |
3102 | g_debug("nvidia-smi gpus = %d\n", n); |
3103 | return n; |
3104 | } |
3105 | |
3106 | gboolean |
3107 | gkrellm_sys_sensors_get_temperature(gchar *sensor_path, gint id, |
3108 | gint iodev, gint interface, gfloat *temp) |
3109 | { |
3110 | FILE *f; |
3111 | gchar buf[128], units[32]; |
3112 | gint n; |
3113 | gfloat T, t[5],ibm_acpi_temp[8]; |
3114 | gboolean result = FALSE(0); |
3115 | |
3116 | if ( interface == SYS_THERMAL_INTERFACE9) |
3117 | { |
3118 | f = fopen(sensor_path, "r"); |
3119 | if (f) |
3120 | { |
3121 | while (fgets(buf, sizeof(buf), f) != NULL((void*)0)) |
3122 | { |
3123 | if (need_locale_fix) |
3124 | locale_fix(buf); |
3125 | if ((n = sscanf(buf, "%f", &T)) > 0) |
3126 | { |
3127 | *temp = T / 1000.0; /* Units from file are millidegree */ |
3128 | result = TRUE(!(0)); |
3129 | } |
3130 | } |
3131 | fclose(f); |
3132 | } |
3133 | return result; |
3134 | } |
3135 | |
3136 | if ( interface == THERMAL_INTERFACE2 |
3137 | || interface == THERMAL_ZONE_INTERFACE3 |
3138 | ) |
3139 | { |
3140 | f = fopen(sensor_path, "r"); |
3141 | if (f) |
3142 | { |
3143 | while (fgets(buf, sizeof(buf), f) != NULL((void*)0)) |
3144 | { |
3145 | if (need_locale_fix) |
3146 | locale_fix(buf); |
3147 | if ((n = sscanf(buf, "temperature: %f %31s", &T, units)) > 0) |
3148 | { |
3149 | if (n == 2 && !strcmp(units, "dK")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (units) && __builtin_constant_p ("dK") && (__s1_len = strlen (units), __s2_len = strlen ("dK"), (!((size_t)(const void *)((units) + 1) - (size_t)(const void *)(units) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("dK" ) + 1) - (size_t)(const void *)("dK") == 1) || __s2_len >= 4)) ? __builtin_strcmp (units, "dK") : (__builtin_constant_p (units) && ((size_t)(const void *)((units) + 1) - (size_t )(const void *)(units) == 1) && (__s1_len = strlen (units ), __s1_len < 4) ? (__builtin_constant_p ("dK") && ((size_t)(const void *)(("dK") + 1) - (size_t)(const void *) ("dK") == 1) ? __builtin_strcmp (units, "dK") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("dK"); int __result = (((const unsigned char *) (const char *) (units))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (units))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (units))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (units))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("dK") && ((size_t)(const void *)(("dK") + 1) - (size_t )(const void *)("dK") == 1) && (__s2_len = strlen ("dK" ), __s2_len < 4) ? (__builtin_constant_p (units) && ((size_t)(const void *)((units) + 1) - (size_t)(const void * )(units) == 1) ? __builtin_strcmp (units, "dK") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (units); int __result = (((const unsigned char *) (const char *) ("dK"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("dK"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("dK"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("dK"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (units, "dK")))); })) |
3150 | T = T / 10.0 - 273.0; |
3151 | *temp = T; |
3152 | result = TRUE(!(0)); |
3153 | } |
3154 | } |
3155 | fclose(f); |
3156 | } |
3157 | return result; |
3158 | } |
3159 | |
3160 | if (interface == IBM_ACPI_INTERFACE6) |
3161 | { |
3162 | f = fopen(sensor_path, "r"); |
3163 | if (f) |
3164 | { |
3165 | fgets(buf, sizeof(buf), f); |
3166 | sscanf(buf, "temperatures: %f %f %f %f %f %f %f %f", |
3167 | &ibm_acpi_temp[IBM_ACPI_CPU_TEMP0], |
3168 | &ibm_acpi_temp[IBM_ACPI_PCI_TEMP1], |
3169 | &ibm_acpi_temp[IBM_ACPI_HDD_TEMP2], |
3170 | &ibm_acpi_temp[IBM_ACPI_GPU_TEMP3], |
3171 | &ibm_acpi_temp[IBM_ACPI_BAT1_TEMP4], |
3172 | &ibm_acpi_temp[IBM_ACPI_NA1_TEMP5], |
3173 | &ibm_acpi_temp[IBM_ACPI_BAT2_TEMP6], |
3174 | &ibm_acpi_temp[IBM_ACPI_NA2_TEMP7]); |
3175 | |
3176 | *temp = ibm_acpi_temp[iodev]; |
3177 | result = TRUE(!(0)); |
3178 | fclose(f); |
3179 | } |
3180 | return result; |
3181 | } |
3182 | |
3183 | if (interface == HDDTEMP_INTERFACE20) |
3184 | { |
3185 | gkrellm_sys_sensors_hddtemp_check(); |
3186 | return gkrellm_sys_sensors_hddtemp_get_value(sensor_path, temp); |
3187 | } |
3188 | |
3189 | if (interface == MBMON_INTERFACE21) |
3190 | { |
3191 | gkrellm_sys_sensors_mbmon_check(FALSE(0)); |
3192 | return gkrellm_sys_sensors_mbmon_get_value(sensor_path, temp); |
3193 | } |
3194 | |
3195 | if (interface == NVIDIA_SMI_INTERFACE10) |
3196 | { |
3197 | NvidiaSmi *smi; |
3198 | static gint check_time = -1; |
3199 | |
3200 | if (check_time < _GK.time_now) |
3201 | { |
3202 | sensors_nvidia_smi_read(FALSE(0)); |
3203 | check_time = _GK.time_now + 2; /* Interval < sensor update */ |
3204 | } |
3205 | smi = nvidia_smi_lookup(sensor_path); |
3206 | if (smi) |
3207 | { |
3208 | *temp = smi->temp; |
3209 | return TRUE(!(0)); |
3210 | } |
3211 | else |
3212 | return FALSE(0); |
3213 | } |
3214 | |
3215 | if (interface == NVIDIA_SETTINGS_INTERFACE4) |
3216 | { |
3217 | gchar *args[] = { "nvidia-settings", "-q", sensor_path, NULL((void*)0) }; |
3218 | gchar *output = NULL((void*)0); |
3219 | GError *error = NULL((void*)0); |
3220 | |
3221 | result = g_spawn_sync(NULL((void*)0), args, NULL((void*)0), |
3222 | G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL, |
3223 | NULL((void*)0), NULL((void*)0), &output, NULL((void*)0), NULL((void*)0), &error); |
3224 | |
3225 | if(result && output) |
3226 | { |
3227 | gfloat dummy; |
3228 | |
3229 | if(!temp) |
3230 | temp = &dummy; |
3231 | result = (sscanf((*output == '\n' ? output + 1 : output), |
3232 | " Attribute %*s %*s %f", temp) == 1); |
3233 | } |
3234 | if ((_GK.debug_level & DEBUG_SENSORS0x80) && (!result || !output)) |
3235 | { |
3236 | printf("nvidia-settings %s: result=%d output=%s\n", sensor_path, |
3237 | (gint) result, |
3238 | output ? output : "(null)"); |
3239 | if (error) |
3240 | printf("\terror=%s\n", error->message); |
3241 | } |
3242 | if (error) |
3243 | g_error_free(error); |
3244 | if (output) |
3245 | g_free(output); |
3246 | return result; |
3247 | } |
3248 | |
3249 | if (interface == NVCLOCK_INTERFACE5) |
3250 | { |
3251 | gchar *args[] = { "nvclock", "-T", "-c", sensor_path, NULL((void*)0) }; |
3252 | gchar *output = NULL((void*)0); |
3253 | gchar *s = NULL((void*)0); |
3254 | |
3255 | result = g_spawn_sync(NULL((void*)0), args, NULL((void*)0), |
3256 | G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL, |
3257 | NULL((void*)0), NULL((void*)0), &output, NULL((void*)0), NULL((void*)0), NULL((void*)0)); |
3258 | |
3259 | if(result && output) |
3260 | { |
3261 | gfloat dummy; |
3262 | |
3263 | if(!temp) |
3264 | temp = &dummy; |
3265 | s = strstr(output, "GPU"); |
3266 | if (s) |
3267 | result = (sscanf(s, "GPU temperature:%f", temp) == 1); |
3268 | else |
3269 | result = FALSE(0); |
3270 | } |
3271 | |
3272 | g_free(output); |
3273 | return result; |
3274 | } |
3275 | |
3276 | if (interface == UNINORTH_INTERFACE7 || interface == WINDFARM_INTERFACE8) |
3277 | { |
3278 | if ((f = fopen(sensor_path, "r"))) |
3279 | { |
3280 | fscanf(f, "%f", temp); |
3281 | fclose(f); |
3282 | return TRUE(!(0)); |
3283 | } |
3284 | return FALSE(0); |
3285 | } |
3286 | |
3287 | #ifdef HAVE_LIBSENSORS1 |
3288 | if (interface == LIBSENSORS_INTERFACE1) |
3289 | return libsensors_get_value(sensor_path, id, iodev, temp); |
3290 | #endif |
3291 | |
3292 | if ((f = fopen(sensor_path, "r")) == NULL((void*)0)) |
3293 | return FALSE(0); |
3294 | fgets(buf, sizeof(buf), f); |
3295 | fclose(f); |
3296 | |
3297 | if (!have_sysfs_sensors && need_locale_fix) |
3298 | locale_fix(buf); |
3299 | n = sscanf(buf, "%f %f %f %f %f", &t[0], &t[1], &t[2], &t[3], &t[4]); |
3300 | if (n < 1) |
3301 | return FALSE(0); |
3302 | T = t[n - 1]; |
3303 | |
3304 | if (have_sysfs_sensors) |
3305 | T /= 1000.0; |
3306 | else if (T > 254.0) /* Bogus read from BIOS if CHAR_MAX */ |
3307 | return FALSE(0); |
3308 | |
3309 | if (temp) |
3310 | *temp = T; |
3311 | return TRUE(!(0)); |
3312 | } |
3313 | |
3314 | gboolean |
3315 | gkrellm_sys_sensors_get_fan(gchar *sensor_path, gint id, |
3316 | gint iodev, gint interface, gfloat *fan) |
3317 | { |
3318 | FILE *f; |
3319 | gchar buf[64]; |
3320 | gint n; |
3321 | gfloat t[4], T; |
3322 | gboolean result = FALSE(0); |
3323 | |
3324 | if (interface == IBM_ACPI_INTERFACE6) |
3325 | { |
3326 | f = fopen(sensor_path, "r"); |
3327 | if (f) |
3328 | { |
3329 | fgets(buf, sizeof(buf), f); |
3330 | fgets(buf, sizeof(buf), f); |
3331 | sscanf(buf, "speed: %f", &T); |
3332 | fclose(f); |
3333 | *fan = T; |
3334 | result = TRUE(!(0)); |
3335 | } |
3336 | return result; |
3337 | } |
3338 | |
3339 | if (interface == MBMON_INTERFACE21) |
3340 | { |
3341 | gkrellm_sys_sensors_mbmon_check(FALSE(0)); |
3342 | return gkrellm_sys_sensors_mbmon_get_value(sensor_path, fan); |
3343 | } |
3344 | |
3345 | if (interface == WINDFARM_INTERFACE8) |
3346 | { |
3347 | f = fopen(sensor_path, "r"); |
3348 | if (f) |
3349 | { |
3350 | fscanf(f, "%d", &n); |
3351 | fclose(f); |
3352 | *fan = n; |
3353 | result = TRUE(!(0)); |
3354 | } |
3355 | return result; |
3356 | } |
3357 | |
3358 | #ifdef HAVE_LIBSENSORS1 |
3359 | if (interface == LIBSENSORS_INTERFACE1) |
3360 | return libsensors_get_value(sensor_path, id, iodev, fan); |
3361 | #endif |
3362 | |
3363 | if ((f = fopen(sensor_path, "r")) == NULL((void*)0)) |
3364 | return FALSE(0); |
3365 | fgets(buf, sizeof(buf), f); |
3366 | fclose(f); |
3367 | |
3368 | if (!have_sysfs_sensors && need_locale_fix) |
3369 | locale_fix(buf); |
3370 | n = sscanf(buf, "%f %f %f %f", &t[0], &t[1], &t[2], &t[3]); |
3371 | if (n < 1) |
3372 | return FALSE(0); |
3373 | |
3374 | if (fan) |
3375 | *fan = t[n - 1]; |
3376 | return TRUE(!(0)); |
3377 | } |
3378 | |
3379 | gboolean |
3380 | gkrellm_sys_sensors_get_voltage(gchar *sensor_path, gint id, |
3381 | gint iodev, gint interface, gfloat *volt) |
3382 | { |
3383 | FILE *f; |
3384 | gchar buf[64]; |
3385 | gfloat V, t[3]; |
3386 | gint n; |
3387 | gboolean result = FALSE(0); |
3388 | |
3389 | if (interface == MBMON_INTERFACE21) |
3390 | { |
3391 | gkrellm_sys_sensors_mbmon_check(FALSE(0)); |
3392 | return gkrellm_sys_sensors_mbmon_get_value(sensor_path, volt); |
3393 | } |
3394 | |
3395 | if (interface == WINDFARM_INTERFACE8) |
3396 | { |
3397 | f = fopen(sensor_path, "r"); |
3398 | if (f) |
3399 | { |
3400 | fscanf(f, "%f", volt); |
3401 | fclose(f); |
3402 | result = TRUE(!(0)); |
3403 | } |
3404 | return result; |
3405 | } |
3406 | |
3407 | #ifdef HAVE_LIBSENSORS1 |
3408 | if (interface == LIBSENSORS_INTERFACE1) |
3409 | return libsensors_get_value(sensor_path, id, iodev, volt); |
3410 | #endif |
3411 | |
3412 | if ((f = fopen(sensor_path, "r")) == NULL((void*)0)) |
3413 | return FALSE(0); |
3414 | fgets(buf, sizeof(buf), f); |
3415 | fclose(f); |
3416 | |
3417 | if (!have_sysfs_sensors && need_locale_fix) |
3418 | locale_fix(buf); |
3419 | n = sscanf(buf, "%f %f %f", &t[0], &t[1], &t[2]); |
3420 | if (n < 1) |
3421 | return FALSE(0); |
3422 | V = t[n - 1]; |
3423 | |
3424 | if (have_sysfs_sensors) |
3425 | V /= 1000.0; |
3426 | else if (V > 254.0) /* Bogus read from BIOS if CHAR_MAX */ |
3427 | return FALSE(0); |
3428 | |
3429 | if (volt) |
3430 | *volt = V; |
3431 | return TRUE(!(0)); |
3432 | } |
3433 | |
3434 | static void |
3435 | get_volt_default(gchar *chip_name, VoltDefault **vdf, gint *vdfsize) |
3436 | { |
3437 | if (!strncmp(chip_name, "it87", 4)(__extension__ (__builtin_constant_p (4) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (4) )) || (__builtin_constant_p ("it87") && strlen ("it87" ) < ((size_t) (4)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (chip_name) && __builtin_constant_p ("it87") && (__s1_len = strlen (chip_name), __s2_len = strlen ("it87"), (!((size_t)(const void *)((chip_name) + 1 ) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("it87") + 1) - (size_t )(const void *)("it87") == 1) || __s2_len >= 4)) ? __builtin_strcmp (chip_name, "it87") : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name ), __s1_len < 4) ? (__builtin_constant_p ("it87") && ((size_t)(const void *)(("it87") + 1) - (size_t)(const void * )("it87") == 1) ? __builtin_strcmp (chip_name, "it87") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("it87"); int __result = (((const unsigned char *) ( const char *) (chip_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (chip_name))[3] - __s2[3]); } } __result; } ))) : (__builtin_constant_p ("it87") && ((size_t)(const void *)(("it87") + 1) - (size_t)(const void *)("it87") == 1) && (__s2_len = strlen ("it87"), __s2_len < 4) ? ( __builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1 ) ? __builtin_strcmp (chip_name, "it87") : (- (__extension__ ( { const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name); int __result = (((const unsigned char *) (const char *) ("it87"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("it87"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("it87"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("it87"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (chip_name, "it87")))); }) : strncmp (chip_name, "it87", 4)) )) |
3438 | { |
3439 | *vdf = &voltdefault8[0]; |
3440 | *vdfsize = sizeof (voltdefault8) / sizeof (VoltDefault); |
3441 | } |
3442 | else if ( !strncmp(chip_name, "adm1025", 7)(__extension__ (__builtin_constant_p (7) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (7) )) || (__builtin_constant_p ("adm1025") && strlen ("adm1025" ) < ((size_t) (7)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (chip_name) && __builtin_constant_p ("adm1025") && (__s1_len = strlen (chip_name), __s2_len = strlen ("adm1025"), (!((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("adm1025") + 1) - ( size_t)(const void *)("adm1025") == 1) || __s2_len >= 4)) ? __builtin_strcmp (chip_name, "adm1025") : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name), __s1_len < 4) ? (__builtin_constant_p ("adm1025") && ((size_t)(const void *)(("adm1025") + 1) - (size_t)(const void *)("adm1025") == 1) ? __builtin_strcmp (chip_name, "adm1025") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("adm1025"); int __result = (((const unsigned char *) (const char *) (chip_name ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (chip_name ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (chip_name ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (chip_name ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "adm1025") && ((size_t)(const void *)(("adm1025") + 1 ) - (size_t)(const void *)("adm1025") == 1) && (__s2_len = strlen ("adm1025"), __s2_len < 4) ? (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) ? __builtin_strcmp (chip_name, "adm1025") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name ); int __result = (((const unsigned char *) (const char *) ("adm1025" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("adm1025" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("adm1025" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("adm1025" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (chip_name , "adm1025")))); }) : strncmp (chip_name, "adm1025", 7))) |
3443 | || !strncmp(chip_name, "adm9240", 7)(__extension__ (__builtin_constant_p (7) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (7) )) || (__builtin_constant_p ("adm9240") && strlen ("adm9240" ) < ((size_t) (7)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (chip_name) && __builtin_constant_p ("adm9240") && (__s1_len = strlen (chip_name), __s2_len = strlen ("adm9240"), (!((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("adm9240") + 1) - ( size_t)(const void *)("adm9240") == 1) || __s2_len >= 4)) ? __builtin_strcmp (chip_name, "adm9240") : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name), __s1_len < 4) ? (__builtin_constant_p ("adm9240") && ((size_t)(const void *)(("adm9240") + 1) - (size_t)(const void *)("adm9240") == 1) ? __builtin_strcmp (chip_name, "adm9240") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("adm9240"); int __result = (((const unsigned char *) (const char *) (chip_name ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (chip_name ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (chip_name ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (chip_name ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "adm9240") && ((size_t)(const void *)(("adm9240") + 1 ) - (size_t)(const void *)("adm9240") == 1) && (__s2_len = strlen ("adm9240"), __s2_len < 4) ? (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) ? __builtin_strcmp (chip_name, "adm9240") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name ); int __result = (((const unsigned char *) (const char *) ("adm9240" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("adm9240" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("adm9240" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("adm9240" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (chip_name , "adm9240")))); }) : strncmp (chip_name, "adm9240", 7))) |
3444 | || !strncmp(chip_name, "lm87", 4)(__extension__ (__builtin_constant_p (4) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (4) )) || (__builtin_constant_p ("lm87") && strlen ("lm87" ) < ((size_t) (4)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (chip_name) && __builtin_constant_p ("lm87") && (__s1_len = strlen (chip_name), __s2_len = strlen ("lm87"), (!((size_t)(const void *)((chip_name) + 1 ) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("lm87") + 1) - (size_t )(const void *)("lm87") == 1) || __s2_len >= 4)) ? __builtin_strcmp (chip_name, "lm87") : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name ), __s1_len < 4) ? (__builtin_constant_p ("lm87") && ((size_t)(const void *)(("lm87") + 1) - (size_t)(const void * )("lm87") == 1) ? __builtin_strcmp (chip_name, "lm87") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("lm87"); int __result = (((const unsigned char *) ( const char *) (chip_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (chip_name))[3] - __s2[3]); } } __result; } ))) : (__builtin_constant_p ("lm87") && ((size_t)(const void *)(("lm87") + 1) - (size_t)(const void *)("lm87") == 1) && (__s2_len = strlen ("lm87"), __s2_len < 4) ? ( __builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1 ) ? __builtin_strcmp (chip_name, "lm87") : (- (__extension__ ( { const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name); int __result = (((const unsigned char *) (const char *) ("lm87"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("lm87"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("lm87"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("lm87"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (chip_name, "lm87")))); }) : strncmp (chip_name, "lm87", 4)) ) |
3445 | || !strncmp(chip_name, "lm81", 4)(__extension__ (__builtin_constant_p (4) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (4) )) || (__builtin_constant_p ("lm81") && strlen ("lm81" ) < ((size_t) (4)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (chip_name) && __builtin_constant_p ("lm81") && (__s1_len = strlen (chip_name), __s2_len = strlen ("lm81"), (!((size_t)(const void *)((chip_name) + 1 ) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("lm81") + 1) - (size_t )(const void *)("lm81") == 1) || __s2_len >= 4)) ? __builtin_strcmp (chip_name, "lm81") : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name ), __s1_len < 4) ? (__builtin_constant_p ("lm81") && ((size_t)(const void *)(("lm81") + 1) - (size_t)(const void * )("lm81") == 1) ? __builtin_strcmp (chip_name, "lm81") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("lm81"); int __result = (((const unsigned char *) ( const char *) (chip_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (chip_name))[3] - __s2[3]); } } __result; } ))) : (__builtin_constant_p ("lm81") && ((size_t)(const void *)(("lm81") + 1) - (size_t)(const void *)("lm81") == 1) && (__s2_len = strlen ("lm81"), __s2_len < 4) ? ( __builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1 ) ? __builtin_strcmp (chip_name, "lm81") : (- (__extension__ ( { const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name); int __result = (((const unsigned char *) (const char *) ("lm81"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("lm81"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("lm81"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("lm81"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (chip_name, "lm81")))); }) : strncmp (chip_name, "lm81", 4)) ) |
3446 | || !strncmp(chip_name, "ds1780", 6)(__extension__ (__builtin_constant_p (6) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (6) )) || (__builtin_constant_p ("ds1780") && strlen ("ds1780" ) < ((size_t) (6)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (chip_name) && __builtin_constant_p ("ds1780") && (__s1_len = strlen (chip_name), __s2_len = strlen ("ds1780"), (!((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("ds1780") + 1) - (size_t )(const void *)("ds1780") == 1) || __s2_len >= 4)) ? __builtin_strcmp (chip_name, "ds1780") : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name ), __s1_len < 4) ? (__builtin_constant_p ("ds1780") && ((size_t)(const void *)(("ds1780") + 1) - (size_t)(const void *)("ds1780") == 1) ? __builtin_strcmp (chip_name, "ds1780") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("ds1780"); int __result = (((const unsigned char *) (const char *) (chip_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (chip_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("ds1780") && ((size_t )(const void *)(("ds1780") + 1) - (size_t)(const void *)("ds1780" ) == 1) && (__s2_len = strlen ("ds1780"), __s2_len < 4) ? (__builtin_constant_p (chip_name) && ((size_t)( const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name ) == 1) ? __builtin_strcmp (chip_name, "ds1780") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name); int __result = (((const unsigned char * ) (const char *) ("ds1780"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("ds1780"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("ds1780"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("ds1780"))[3] - __s2[3]); } } __result; } )))) : __builtin_strcmp (chip_name, "ds1780")))); }) : strncmp (chip_name, "ds1780", 6))) |
3447 | ) |
3448 | { |
3449 | *vdf = &voltdefault7[0]; |
3450 | *vdfsize = sizeof (voltdefault7) / sizeof (VoltDefault); |
3451 | } |
3452 | else if (!strncmp(chip_name, "mtp008", 6)(__extension__ (__builtin_constant_p (6) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (6) )) || (__builtin_constant_p ("mtp008") && strlen ("mtp008" ) < ((size_t) (6)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (chip_name) && __builtin_constant_p ("mtp008") && (__s1_len = strlen (chip_name), __s2_len = strlen ("mtp008"), (!((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("mtp008") + 1) - (size_t )(const void *)("mtp008") == 1) || __s2_len >= 4)) ? __builtin_strcmp (chip_name, "mtp008") : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name ), __s1_len < 4) ? (__builtin_constant_p ("mtp008") && ((size_t)(const void *)(("mtp008") + 1) - (size_t)(const void *)("mtp008") == 1) ? __builtin_strcmp (chip_name, "mtp008") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("mtp008"); int __result = (((const unsigned char *) (const char *) (chip_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (chip_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("mtp008") && ((size_t )(const void *)(("mtp008") + 1) - (size_t)(const void *)("mtp008" ) == 1) && (__s2_len = strlen ("mtp008"), __s2_len < 4) ? (__builtin_constant_p (chip_name) && ((size_t)( const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name ) == 1) ? __builtin_strcmp (chip_name, "mtp008") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name); int __result = (((const unsigned char * ) (const char *) ("mtp008"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("mtp008"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("mtp008"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("mtp008"))[3] - __s2[3]); } } __result; } )))) : __builtin_strcmp (chip_name, "mtp008")))); }) : strncmp (chip_name, "mtp008", 6)))) |
3453 | { |
3454 | *vdf = &voltdefault6[0]; |
3455 | *vdfsize = sizeof (voltdefault6) / sizeof (VoltDefault); |
3456 | } |
3457 | else if (!strncmp(chip_name, "via686", 6)(__extension__ (__builtin_constant_p (6) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (6) )) || (__builtin_constant_p ("via686") && strlen ("via686" ) < ((size_t) (6)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (chip_name) && __builtin_constant_p ("via686") && (__s1_len = strlen (chip_name), __s2_len = strlen ("via686"), (!((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("via686") + 1) - (size_t )(const void *)("via686") == 1) || __s2_len >= 4)) ? __builtin_strcmp (chip_name, "via686") : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name ), __s1_len < 4) ? (__builtin_constant_p ("via686") && ((size_t)(const void *)(("via686") + 1) - (size_t)(const void *)("via686") == 1) ? __builtin_strcmp (chip_name, "via686") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("via686"); int __result = (((const unsigned char *) (const char *) (chip_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (chip_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("via686") && ((size_t )(const void *)(("via686") + 1) - (size_t)(const void *)("via686" ) == 1) && (__s2_len = strlen ("via686"), __s2_len < 4) ? (__builtin_constant_p (chip_name) && ((size_t)( const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name ) == 1) ? __builtin_strcmp (chip_name, "via686") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name); int __result = (((const unsigned char * ) (const char *) ("via686"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("via686"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("via686"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("via686"))[3] - __s2[3]); } } __result; } )))) : __builtin_strcmp (chip_name, "via686")))); }) : strncmp (chip_name, "via686", 6)))) |
3458 | { |
3459 | *vdf = &voltdefault5[0]; |
3460 | *vdfsize = sizeof (voltdefault5) / sizeof (VoltDefault); |
3461 | } |
3462 | else if (!strncmp(chip_name, "gl520", 5)(__extension__ (__builtin_constant_p (5) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (5) )) || (__builtin_constant_p ("gl520") && strlen ("gl520" ) < ((size_t) (5)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (chip_name) && __builtin_constant_p ("gl520") && (__s1_len = strlen (chip_name), __s2_len = strlen ("gl520"), (!((size_t)(const void *)((chip_name) + 1 ) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("gl520") + 1) - (size_t )(const void *)("gl520") == 1) || __s2_len >= 4)) ? __builtin_strcmp (chip_name, "gl520") : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name ), __s1_len < 4) ? (__builtin_constant_p ("gl520") && ((size_t)(const void *)(("gl520") + 1) - (size_t)(const void *)("gl520") == 1) ? __builtin_strcmp (chip_name, "gl520") : ( __extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("gl520"); int __result = (((const unsigned char *) (const char *) (chip_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (chip_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("gl520") && ((size_t) (const void *)(("gl520") + 1) - (size_t)(const void *)("gl520" ) == 1) && (__s2_len = strlen ("gl520"), __s2_len < 4) ? (__builtin_constant_p (chip_name) && ((size_t)( const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name ) == 1) ? __builtin_strcmp (chip_name, "gl520") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name); int __result = (((const unsigned char * ) (const char *) ("gl520"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("gl520"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("gl520"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("gl520"))[3] - __s2[3]); } } __result; }) ))) : __builtin_strcmp (chip_name, "gl520")))); }) : strncmp ( chip_name, "gl520", 5)))) |
3463 | { |
3464 | *vdf = &voltdefault4[0]; |
3465 | *vdfsize = sizeof (voltdefault4) / sizeof (VoltDefault); |
3466 | } |
3467 | else if (!strncmp(chip_name, "gl518", 5)(__extension__ (__builtin_constant_p (5) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (5) )) || (__builtin_constant_p ("gl518") && strlen ("gl518" ) < ((size_t) (5)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (chip_name) && __builtin_constant_p ("gl518") && (__s1_len = strlen (chip_name), __s2_len = strlen ("gl518"), (!((size_t)(const void *)((chip_name) + 1 ) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("gl518") + 1) - (size_t )(const void *)("gl518") == 1) || __s2_len >= 4)) ? __builtin_strcmp (chip_name, "gl518") : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name ), __s1_len < 4) ? (__builtin_constant_p ("gl518") && ((size_t)(const void *)(("gl518") + 1) - (size_t)(const void *)("gl518") == 1) ? __builtin_strcmp (chip_name, "gl518") : ( __extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("gl518"); int __result = (((const unsigned char *) (const char *) (chip_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (chip_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("gl518") && ((size_t) (const void *)(("gl518") + 1) - (size_t)(const void *)("gl518" ) == 1) && (__s2_len = strlen ("gl518"), __s2_len < 4) ? (__builtin_constant_p (chip_name) && ((size_t)( const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name ) == 1) ? __builtin_strcmp (chip_name, "gl518") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name); int __result = (((const unsigned char * ) (const char *) ("gl518"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("gl518"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("gl518"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("gl518"))[3] - __s2[3]); } } __result; }) ))) : __builtin_strcmp (chip_name, "gl518")))); }) : strncmp ( chip_name, "gl518", 5)))) |
3468 | { |
3469 | *vdf = &voltdefault3[0]; |
3470 | *vdfsize = sizeof (voltdefault3) / sizeof (VoltDefault); |
3471 | } |
3472 | else if (!strncmp(chip_name, "lm80", 4)(__extension__ (__builtin_constant_p (4) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (4) )) || (__builtin_constant_p ("lm80") && strlen ("lm80" ) < ((size_t) (4)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (chip_name) && __builtin_constant_p ("lm80") && (__s1_len = strlen (chip_name), __s2_len = strlen ("lm80"), (!((size_t)(const void *)((chip_name) + 1 ) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("lm80") + 1) - (size_t )(const void *)("lm80") == 1) || __s2_len >= 4)) ? __builtin_strcmp (chip_name, "lm80") : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name ), __s1_len < 4) ? (__builtin_constant_p ("lm80") && ((size_t)(const void *)(("lm80") + 1) - (size_t)(const void * )("lm80") == 1) ? __builtin_strcmp (chip_name, "lm80") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("lm80"); int __result = (((const unsigned char *) ( const char *) (chip_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (chip_name))[3] - __s2[3]); } } __result; } ))) : (__builtin_constant_p ("lm80") && ((size_t)(const void *)(("lm80") + 1) - (size_t)(const void *)("lm80") == 1) && (__s2_len = strlen ("lm80"), __s2_len < 4) ? ( __builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1 ) ? __builtin_strcmp (chip_name, "lm80") : (- (__extension__ ( { const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name); int __result = (((const unsigned char *) (const char *) ("lm80"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("lm80"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("lm80"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("lm80"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (chip_name, "lm80")))); }) : strncmp (chip_name, "lm80", 4)) )) |
3473 | { |
3474 | *vdf = &voltdefault2[0]; |
3475 | *vdfsize = sizeof (voltdefault2) / sizeof (VoltDefault); |
3476 | } |
3477 | else if ( !strncmp(chip_name, "w83627thf", 9)(__extension__ (__builtin_constant_p (9) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (9) )) || (__builtin_constant_p ("w83627thf") && strlen ( "w83627thf") < ((size_t) (9)))) ? __extension__ ({ size_t __s1_len , __s2_len; (__builtin_constant_p (chip_name) && __builtin_constant_p ("w83627thf") && (__s1_len = strlen (chip_name), __s2_len = strlen ("w83627thf"), (!((size_t)(const void *)((chip_name ) + 1) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("w83627thf") + 1) - (size_t)(const void *)("w83627thf") == 1) || __s2_len >= 4 )) ? __builtin_strcmp (chip_name, "w83627thf") : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name), __s1_len < 4) ? (__builtin_constant_p ("w83627thf") && ((size_t)(const void *)(("w83627thf" ) + 1) - (size_t)(const void *)("w83627thf") == 1) ? __builtin_strcmp (chip_name, "w83627thf") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("w83627thf") ; int __result = (((const unsigned char *) (const char *) (chip_name ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (chip_name ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (chip_name ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (chip_name ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "w83627thf") && ((size_t)(const void *)(("w83627thf") + 1) - (size_t)(const void *)("w83627thf") == 1) && ( __s2_len = strlen ("w83627thf"), __s2_len < 4) ? (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) ? __builtin_strcmp (chip_name, "w83627thf") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name ); int __result = (((const unsigned char *) (const char *) ("w83627thf" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("w83627thf" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("w83627thf" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("w83627thf" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (chip_name , "w83627thf")))); }) : strncmp (chip_name, "w83627thf", 9))) |
3478 | || !strncmp(chip_name, "w83637hf", 8)(__extension__ (__builtin_constant_p (8) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (8) )) || (__builtin_constant_p ("w83637hf") && strlen ("w83637hf" ) < ((size_t) (8)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (chip_name) && __builtin_constant_p ("w83637hf") && (__s1_len = strlen (chip_name), __s2_len = strlen ("w83637hf"), (!((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("w83637hf") + 1) - ( size_t)(const void *)("w83637hf") == 1) || __s2_len >= 4)) ? __builtin_strcmp (chip_name, "w83637hf") : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name), __s1_len < 4) ? (__builtin_constant_p ("w83637hf") && ((size_t)(const void *)(("w83637hf") + 1) - (size_t)(const void *)("w83637hf") == 1) ? __builtin_strcmp (chip_name, "w83637hf") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("w83637hf"); int __result = (((const unsigned char *) (const char *) (chip_name ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (chip_name ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (chip_name ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (chip_name ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "w83637hf") && ((size_t)(const void *)(("w83637hf") + 1) - (size_t)(const void *)("w83637hf") == 1) && (__s2_len = strlen ("w83637hf"), __s2_len < 4) ? (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) ? __builtin_strcmp (chip_name, "w83637hf") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name ); int __result = (((const unsigned char *) (const char *) ("w83637hf" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("w83637hf" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("w83637hf" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("w83637hf" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (chip_name , "w83637hf")))); }) : strncmp (chip_name, "w83637hf", 8))) |
3479 | ) |
3480 | { |
3481 | *vdf = &voltdefault12[0]; |
3482 | *vdfsize = sizeof (voltdefault12) / sizeof (VoltDefault); |
3483 | } |
3484 | else if (!strncmp(chip_name, "w83", 3)(__extension__ (__builtin_constant_p (3) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (3) )) || (__builtin_constant_p ("w83") && strlen ("w83") < ((size_t) (3)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (chip_name) && __builtin_constant_p ("w83") && (__s1_len = strlen (chip_name), __s2_len = strlen ("w83"), (!((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("w83") + 1) - (size_t) (const void *)("w83") == 1) || __s2_len >= 4)) ? __builtin_strcmp (chip_name, "w83") : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name ), __s1_len < 4) ? (__builtin_constant_p ("w83") && ((size_t)(const void *)(("w83") + 1) - (size_t)(const void * )("w83") == 1) ? __builtin_strcmp (chip_name, "w83") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("w83"); int __result = (((const unsigned char *) (const char *) (chip_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (chip_name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("w83") && ((size_t)(const void *)(("w83") + 1) - (size_t )(const void *)("w83") == 1) && (__s2_len = strlen ("w83" ), __s2_len < 4) ? (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) ? __builtin_strcmp (chip_name, "w83") : ( - (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name); int __result = (((const unsigned char *) (const char *) ("w83"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("w83"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("w83"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char * ) (const char *) ("w83"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (chip_name, "w83")))); }) : strncmp (chip_name , "w83", 3))) && strncmp(chip_name, "w83781", 6)(__extension__ (__builtin_constant_p (6) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (6) )) || (__builtin_constant_p ("w83781") && strlen ("w83781" ) < ((size_t) (6)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (chip_name) && __builtin_constant_p ("w83781") && (__s1_len = strlen (chip_name), __s2_len = strlen ("w83781"), (!((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("w83781") + 1) - (size_t )(const void *)("w83781") == 1) || __s2_len >= 4)) ? __builtin_strcmp (chip_name, "w83781") : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name ), __s1_len < 4) ? (__builtin_constant_p ("w83781") && ((size_t)(const void *)(("w83781") + 1) - (size_t)(const void *)("w83781") == 1) ? __builtin_strcmp (chip_name, "w83781") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("w83781"); int __result = (((const unsigned char *) (const char *) (chip_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (chip_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("w83781") && ((size_t )(const void *)(("w83781") + 1) - (size_t)(const void *)("w83781" ) == 1) && (__s2_len = strlen ("w83781"), __s2_len < 4) ? (__builtin_constant_p (chip_name) && ((size_t)( const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name ) == 1) ? __builtin_strcmp (chip_name, "w83781") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name); int __result = (((const unsigned char * ) (const char *) ("w83781"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("w83781"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("w83781"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("w83781"))[3] - __s2[3]); } } __result; } )))) : __builtin_strcmp (chip_name, "w83781")))); }) : strncmp (chip_name, "w83781", 6)))) |
3485 | { |
3486 | *vdf = &voltdefault1[0]; |
3487 | *vdfsize = sizeof (voltdefault1) / sizeof (VoltDefault); |
3488 | } |
3489 | else if (!strncmp(chip_name, "fscpos", 6)(__extension__ (__builtin_constant_p (6) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (6) )) || (__builtin_constant_p ("fscpos") && strlen ("fscpos" ) < ((size_t) (6)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (chip_name) && __builtin_constant_p ("fscpos") && (__s1_len = strlen (chip_name), __s2_len = strlen ("fscpos"), (!((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("fscpos") + 1) - (size_t )(const void *)("fscpos") == 1) || __s2_len >= 4)) ? __builtin_strcmp (chip_name, "fscpos") : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name ), __s1_len < 4) ? (__builtin_constant_p ("fscpos") && ((size_t)(const void *)(("fscpos") + 1) - (size_t)(const void *)("fscpos") == 1) ? __builtin_strcmp (chip_name, "fscpos") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("fscpos"); int __result = (((const unsigned char *) (const char *) (chip_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (chip_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("fscpos") && ((size_t )(const void *)(("fscpos") + 1) - (size_t)(const void *)("fscpos" ) == 1) && (__s2_len = strlen ("fscpos"), __s2_len < 4) ? (__builtin_constant_p (chip_name) && ((size_t)( const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name ) == 1) ? __builtin_strcmp (chip_name, "fscpos") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name); int __result = (((const unsigned char * ) (const char *) ("fscpos"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("fscpos"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("fscpos"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("fscpos"))[3] - __s2[3]); } } __result; } )))) : __builtin_strcmp (chip_name, "fscpos")))); }) : strncmp (chip_name, "fscpos", 6)))) |
3490 | { |
3491 | *vdf = &voltdefault9[0]; |
3492 | *vdfsize = sizeof (voltdefault9) / sizeof (VoltDefault); |
3493 | } |
3494 | else if (!strncmp(chip_name, "abituguru2", 10)(__extension__ (__builtin_constant_p (10) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (10 ))) || (__builtin_constant_p ("abituguru2") && strlen ("abituguru2") < ((size_t) (10)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (chip_name) && __builtin_constant_p ("abituguru2") && (__s1_len = strlen (chip_name), __s2_len = strlen ("abituguru2"), (!((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("abituguru2") + 1) - (size_t)(const void *)("abituguru2" ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (chip_name, "abituguru2" ) : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name), __s1_len < 4) ? (__builtin_constant_p ("abituguru2") && ((size_t )(const void *)(("abituguru2") + 1) - (size_t)(const void *)( "abituguru2") == 1) ? __builtin_strcmp (chip_name, "abituguru2" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("abituguru2"); int __result = (((const unsigned char *) (const char *) (chip_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (chip_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (chip_name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("abituguru2") && ((size_t)(const void *)(("abituguru2") + 1) - (size_t)(const void *)("abituguru2") == 1) && (__s2_len = strlen ("abituguru2" ), __s2_len < 4) ? (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) ? __builtin_strcmp (chip_name, "abituguru2" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name); int __result = (((const unsigned char *) (const char *) ("abituguru2"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("abituguru2"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("abituguru2"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("abituguru2"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (chip_name, "abituguru2")))); }) : strncmp (chip_name, "abituguru2", 10)))) |
3495 | { |
3496 | *vdf = &voltdefault10[0]; |
3497 | *vdfsize = sizeof (voltdefault10) / sizeof (VoltDefault); |
3498 | } |
3499 | else if (!strncmp(chip_name, "abituguru", 9)(__extension__ (__builtin_constant_p (9) && ((__builtin_constant_p (chip_name) && strlen (chip_name) < ((size_t) (9) )) || (__builtin_constant_p ("abituguru") && strlen ( "abituguru") < ((size_t) (9)))) ? __extension__ ({ size_t __s1_len , __s2_len; (__builtin_constant_p (chip_name) && __builtin_constant_p ("abituguru") && (__s1_len = strlen (chip_name), __s2_len = strlen ("abituguru"), (!((size_t)(const void *)((chip_name ) + 1) - (size_t)(const void *)(chip_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("abituguru") + 1) - (size_t)(const void *)("abituguru") == 1) || __s2_len >= 4 )) ? __builtin_strcmp (chip_name, "abituguru") : (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) && (__s1_len = strlen (chip_name), __s1_len < 4) ? (__builtin_constant_p ("abituguru") && ((size_t)(const void *)(("abituguru" ) + 1) - (size_t)(const void *)("abituguru") == 1) ? __builtin_strcmp (chip_name, "abituguru") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("abituguru") ; int __result = (((const unsigned char *) (const char *) (chip_name ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (chip_name ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (chip_name ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (chip_name ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "abituguru") && ((size_t)(const void *)(("abituguru") + 1) - (size_t)(const void *)("abituguru") == 1) && ( __s2_len = strlen ("abituguru"), __s2_len < 4) ? (__builtin_constant_p (chip_name) && ((size_t)(const void *)((chip_name) + 1) - (size_t)(const void *)(chip_name) == 1) ? __builtin_strcmp (chip_name, "abituguru") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (chip_name ); int __result = (((const unsigned char *) (const char *) ("abituguru" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("abituguru" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("abituguru" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("abituguru" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (chip_name , "abituguru")))); }) : strncmp (chip_name, "abituguru", 9)))) |
3500 | { |
3501 | *vdf = &voltdefault11[0]; |
3502 | *vdfsize = sizeof (voltdefault11) / sizeof (VoltDefault); |
3503 | } |
3504 | else |
3505 | { |
3506 | *vdf = &voltdefault0[0]; |
3507 | *vdfsize = sizeof (voltdefault0) / sizeof (VoltDefault); |
3508 | } |
3509 | } |
3510 | |
3511 | |
3512 | static gchar * |
3513 | sysfs_get_chip_name(gchar *dir) |
3514 | { |
3515 | gchar *name, buf[256], *p, *chip; |
3516 | FILE *f; |
3517 | |
3518 | name = g_strdup_printf("%s/%s", dir, "name"); |
3519 | f = fopen(name, "r"); |
3520 | g_free(name); |
3521 | if (!f) |
3522 | return NULL((void*)0); |
3523 | |
3524 | buf[0] = '\0'; |
3525 | fscanf(f, "%255[^\n]", buf); |
3526 | fclose(f); |
3527 | if (buf[0] == '\0') |
3528 | return NULL((void*)0); |
3529 | |
3530 | if ((p = strchr(buf, ' ')(__extension__ (__builtin_constant_p (' ') && !__builtin_constant_p (buf) && (' ') == '\0' ? (char *) __rawmemchr (buf, ' ' ) : __builtin_strchr (buf, ' ')))) != NULL((void*)0)) /* Remove when 2.6.0 is out */ |
3531 | { /* "w83627hf chip" -> "w83627hf" */ |
3532 | *p++ = '\0'; |
3533 | if (strcmp(p, "chip")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (p) && __builtin_constant_p ("chip") && (__s1_len = strlen (p), __s2_len = strlen ("chip"), (!((size_t)(const void *)((p) + 1) - (size_t)(const void *)(p) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("chip") + 1) - (size_t )(const void *)("chip") == 1) || __s2_len >= 4)) ? __builtin_strcmp (p, "chip") : (__builtin_constant_p (p) && ((size_t) (const void *)((p) + 1) - (size_t)(const void *)(p) == 1) && (__s1_len = strlen (p), __s1_len < 4) ? (__builtin_constant_p ("chip") && ((size_t)(const void *)(("chip") + 1) - ( size_t)(const void *)("chip") == 1) ? __builtin_strcmp (p, "chip" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("chip"); int __result = (((const unsigned char *) (const char *) (p))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (p))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (p))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (p ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "chip") && ((size_t)(const void *)(("chip") + 1) - (size_t )(const void *)("chip") == 1) && (__s2_len = strlen ( "chip"), __s2_len < 4) ? (__builtin_constant_p (p) && ((size_t)(const void *)((p) + 1) - (size_t)(const void *)(p) == 1) ? __builtin_strcmp (p, "chip") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (p); int __result = (((const unsigned char *) (const char *) ("chip"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "chip"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "chip"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("chip" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (p, "chip" )))); }) && strcmp(p, "subclient")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (p) && __builtin_constant_p ("subclient") && (__s1_len = strlen (p), __s2_len = strlen ("subclient"), (!( (size_t)(const void *)((p) + 1) - (size_t)(const void *)(p) == 1) || __s1_len >= 4) && (!((size_t)(const void *) (("subclient") + 1) - (size_t)(const void *)("subclient") == 1 ) || __s2_len >= 4)) ? __builtin_strcmp (p, "subclient") : (__builtin_constant_p (p) && ((size_t)(const void *) ((p) + 1) - (size_t)(const void *)(p) == 1) && (__s1_len = strlen (p), __s1_len < 4) ? (__builtin_constant_p ("subclient" ) && ((size_t)(const void *)(("subclient") + 1) - (size_t )(const void *)("subclient") == 1) ? __builtin_strcmp (p, "subclient" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("subclient"); int __result = (((const unsigned char *) (const char *) (p))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (p))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (p))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (p))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("subclient") && ((size_t)(const void *)(("subclient" ) + 1) - (size_t)(const void *)("subclient") == 1) && (__s2_len = strlen ("subclient"), __s2_len < 4) ? (__builtin_constant_p (p) && ((size_t)(const void *)((p) + 1) - (size_t)(const void *)(p) == 1) ? __builtin_strcmp (p, "subclient") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (p); int __result = (((const unsigned char *) (const char *) ("subclient"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("subclient"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("subclient"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("subclient"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (p, "subclient")))); })) |
3534 | return NULL((void*)0); |
3535 | } |
3536 | |
3537 | chip = g_strdup(buf); |
3538 | for (p = chip; *p; p++) |
3539 | *p = tolower(*p)(__extension__ ({ int __res; if (sizeof (*p) > 1) { if (__builtin_constant_p (*p)) { int __c = (*p); __res = __c < -128 || __c > 255 ? __c : (*__ctype_tolower_loc ())[__c]; } else __res = tolower (*p); } else __res = (*__ctype_tolower_loc ())[(int) (*p)]; __res ; })); |
3540 | return chip; |
3541 | } |
3542 | |
3543 | static void |
3544 | sysfs_sensors_init(void) |
3545 | { |
3546 | GDir *dir, *chip_dir, *dirx; |
3547 | VoltDefault *voltdefault; |
3548 | gint id = 0; |
3549 | gint type, voltdefaultsize; |
3550 | gfloat factor, offset; |
3551 | gchar *name, *bus_name, *default_label, *vref, |
3552 | *id_name, *chip_name, *s, *d, *sensor_path; |
3553 | const gchar *old_bus_name; |
3554 | gchar *old_id_name, *old_path; |
3555 | gchar path[256], buf[256]; |
3556 | gboolean using_i2c_dir = FALSE(0); |
3557 | ConfigMap *config_map; |
3558 | |
3559 | if (!have_sysfs) |
3560 | return; |
3561 | |
3562 | if ((dir = g_dir_open(SYSFS_HWMON_DIR"/sys/class/hwmon", 0, NULL((void*)0))) == NULL((void*)0)) |
3563 | { |
3564 | /* try again with the sysfs i2c dir for older 2.6 kernels */ |
3565 | if ((dir = g_dir_open(SYSFS_I2C_DIR"/sys/bus/i2c/devices", 0, NULL((void*)0))) == NULL((void*)0)) |
3566 | return; |
3567 | using_i2c_dir = TRUE(!(0)); |
3568 | gkrellm_sensors_config_migrate_connect(sensors_config_migrate, |
3569 | SENSOR_NAMES_I2C0); |
3570 | } |
3571 | else |
3572 | gkrellm_sensors_config_migrate_connect(sensors_config_migrate, |
3573 | SENSOR_NAMES_HWMON1); |
3574 | |
3575 | while ((bus_name = (gchar *) g_dir_read_name(dir)) != NULL((void*)0)) |
3576 | { |
3577 | if (using_i2c_dir) |
3578 | snprintf(path, sizeof(path), "%s/%s", SYSFS_I2C_DIR"/sys/bus/i2c/devices", bus_name); |
3579 | else |
3580 | snprintf(path, sizeof(path), "%s/%s/device", |
3581 | SYSFS_HWMON_DIR"/sys/class/hwmon", bus_name); |
3582 | if ((chip_dir = g_dir_open(path, 0, NULL((void*)0))) == NULL((void*)0)) |
3583 | continue; |
3584 | if ((chip_name = sysfs_get_chip_name(path)) == NULL((void*)0)) |
3585 | { |
3586 | g_dir_close(chip_dir); |
3587 | if (using_i2c_dir) |
3588 | continue; |
3589 | /* Newer hwmon drivers keep their files directly in the hwmon dir |
3590 | and not in the device-subdir. */ |
3591 | snprintf(path, sizeof(path), "%s/%s", SYSFS_HWMON_DIR"/sys/class/hwmon", bus_name); |
3592 | if ((chip_dir = g_dir_open(path, 0, NULL((void*)0))) == NULL((void*)0)) |
3593 | continue; |
3594 | if ((chip_name = sysfs_get_chip_name(path)) == NULL((void*)0)) |
3595 | { |
3596 | g_dir_close(chip_dir); |
3597 | continue; |
3598 | } |
3599 | } |
3600 | have_sysfs_sensors = TRUE(!(0)); |
3601 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
3602 | g_debug("sysfs sensors dir: %s\n", path); |
3603 | |
3604 | get_volt_default(chip_name, &voltdefault, &voltdefaultsize); |
3605 | while ((name = (gchar *) g_dir_read_name(chip_dir)) != NULL((void*)0)) |
3606 | { |
3607 | snprintf(buf, sizeof(buf), "%s", name); |
3608 | if ((s = strstr(buf, "_input")) == NULL((void*)0) || s - buf > 6) |
3609 | continue; |
3610 | d = s + 6; /* Can have xxxN_input, xxx_inputN, or xxx_input */ |
3611 | while (isdigit(*d)((*__ctype_b_loc ())[(int) ((*d))] & (unsigned short int) _ISdigit)) |
3612 | *s++ = *d++; |
3613 | *s = '\0'; |
3614 | while (isdigit(*(s-1))((*__ctype_b_loc ())[(int) ((*(s-1)))] & (unsigned short int ) _ISdigit)) |
3615 | --s; |
3616 | id = atoi(s); |
3617 | |
3618 | if (!strncmp(buf, "temp", 4)(__extension__ (__builtin_constant_p (4) && ((__builtin_constant_p (buf) && strlen (buf) < ((size_t) (4))) || (__builtin_constant_p ("temp") && strlen ("temp") < ((size_t) (4)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (buf) && __builtin_constant_p ("temp") && (__s1_len = strlen ( buf), __s2_len = strlen ("temp"), (!((size_t)(const void *)(( buf) + 1) - (size_t)(const void *)(buf) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("temp") + 1) - (size_t )(const void *)("temp") == 1) || __s2_len >= 4)) ? __builtin_strcmp (buf, "temp") : (__builtin_constant_p (buf) && ((size_t )(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1 ) && (__s1_len = strlen (buf), __s1_len < 4) ? (__builtin_constant_p ("temp") && ((size_t)(const void *)(("temp") + 1) - ( size_t)(const void *)("temp") == 1) ? __builtin_strcmp (buf, "temp" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("temp"); int __result = (((const unsigned char *) (const char *) (buf))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("temp") && ((size_t)(const void *)(("temp") + 1) - ( size_t)(const void *)("temp") == 1) && (__s2_len = strlen ("temp"), __s2_len < 4) ? (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)( buf) == 1) ? __builtin_strcmp (buf, "temp") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("temp"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("temp"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("temp"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("temp"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (buf, "temp")))); }) : strncmp (buf, "temp", 4)))) |
3619 | type = SENSOR_TEMPERATURE0; |
3620 | else if (!strncmp(buf, "fan", 3)(__extension__ (__builtin_constant_p (3) && ((__builtin_constant_p (buf) && strlen (buf) < ((size_t) (3))) || (__builtin_constant_p ("fan") && strlen ("fan") < ((size_t) (3)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (buf) && __builtin_constant_p ("fan") && (__s1_len = strlen ( buf), __s2_len = strlen ("fan"), (!((size_t)(const void *)((buf ) + 1) - (size_t)(const void *)(buf) == 1) || __s1_len >= 4 ) && (!((size_t)(const void *)(("fan") + 1) - (size_t )(const void *)("fan") == 1) || __s2_len >= 4)) ? __builtin_strcmp (buf, "fan") : (__builtin_constant_p (buf) && ((size_t )(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1 ) && (__s1_len = strlen (buf), __s1_len < 4) ? (__builtin_constant_p ("fan") && ((size_t)(const void *)(("fan") + 1) - (size_t )(const void *)("fan") == 1) ? __builtin_strcmp (buf, "fan") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("fan"); int __result = (((const unsigned char *) (const char *) (buf))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("fan") && ((size_t)(const void *)(("fan") + 1) - (size_t )(const void *)("fan") == 1) && (__s2_len = strlen ("fan" ), __s2_len < 4) ? (__builtin_constant_p (buf) && ( (size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf ) == 1) ? __builtin_strcmp (buf, "fan") : (- (__extension__ ( { const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("fan"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "fan"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "fan"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("fan" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (buf , "fan")))); }) : strncmp (buf, "fan", 3)))) |
3621 | type = SENSOR_FAN1; |
3622 | else if (!strncmp(buf, "in", 2)(__extension__ (__builtin_constant_p (2) && ((__builtin_constant_p (buf) && strlen (buf) < ((size_t) (2))) || (__builtin_constant_p ("in") && strlen ("in") < ((size_t) (2)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (buf) && __builtin_constant_p ("in") && (__s1_len = strlen (buf ), __s2_len = strlen ("in"), (!((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("in") + 1) - (size_t)(const void * )("in") == 1) || __s2_len >= 4)) ? __builtin_strcmp (buf, "in" ) : (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1) && (__s1_len = strlen (buf), __s1_len < 4) ? (__builtin_constant_p ("in") && ((size_t)(const void *)(("in") + 1) - (size_t )(const void *)("in") == 1) ? __builtin_strcmp (buf, "in") : ( __extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("in"); int __result = (((const unsigned char *) (const char *) (buf))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("in") && ((size_t)(const void *)(("in") + 1) - (size_t )(const void *)("in") == 1) && (__s2_len = strlen ("in" ), __s2_len < 4) ? (__builtin_constant_p (buf) && ( (size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf ) == 1) ? __builtin_strcmp (buf, "in") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) ("in"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "in"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ( "in"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("in" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (buf , "in")))); }) : strncmp (buf, "in", 2)))) |
3623 | type = SENSOR_VOLTAGE2; |
3624 | else |
3625 | continue; |
3626 | |
3627 | factor = 1.0; |
3628 | offset = 0; |
3629 | default_label = vref = NULL((void*)0); |
3630 | |
3631 | if (type == SENSOR_VOLTAGE2) |
3632 | { |
3633 | if (id < voltdefaultsize) |
3634 | { |
3635 | default_label = voltdefault[id].name; |
3636 | factor = voltdefault[id].factor; |
3637 | offset = voltdefault[id].offset; |
3638 | vref = voltdefault[id].vref; |
3639 | } |
3640 | else |
3641 | default_label = buf; |
3642 | } |
3643 | id_name = g_strdup_printf("%s-%s/%s", chip_name, bus_name, buf); |
3644 | sensor_path = g_strdup_printf("%s/%s", path, name); |
3645 | gkrellm_sensors_add_sensor(type, sensor_path, id_name, |
3646 | id, 0, 0, |
3647 | factor, offset, vref, default_label); |
3648 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
3649 | g_debug("%s %s %d %d\n", |
3650 | sensor_path, id_name, id, type); |
3651 | |
3652 | if (!using_i2c_dir) |
3653 | { |
3654 | old_path = g_strdup_printf("%s/%s/device/bus/devices", |
3655 | SYSFS_HWMON_DIR"/sys/class/hwmon", bus_name); |
3656 | if ((dirx = g_dir_open(old_path, 0, NULL((void*)0))) != NULL((void*)0)) |
3657 | { |
3658 | while ((old_bus_name = g_dir_read_name(dirx)) != NULL((void*)0)) |
3659 | { |
3660 | config_map = g_new0(ConfigMap, 1)(ConfigMap *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s = sizeof (ConfigMap); gpointer __p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) && (__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s); __p ; })); |
3661 | config_map->current_name = g_strdup(id_name); |
3662 | old_id_name = g_strdup_printf("%s-%s/%s", |
3663 | chip_name, old_bus_name, buf); |
3664 | config_map->i2c_name = g_strdup(old_id_name); |
3665 | config_map_list = |
3666 | g_list_append(config_map_list, config_map); |
3667 | g_free(old_id_name); |
3668 | } |
3669 | g_dir_close(dirx); |
3670 | } |
3671 | g_free(old_path); |
3672 | } |
3673 | |
3674 | g_free(id_name); |
3675 | g_free(sensor_path); |
3676 | } |
3677 | g_free(chip_name); |
3678 | g_dir_close(chip_dir); |
3679 | } |
3680 | g_dir_close(dir); |
3681 | } |
3682 | |
3683 | static gint |
3684 | sensors_nvidia_settings_ngpus(void) |
3685 | { |
3686 | gint n = 0; |
3687 | gchar *args[] = { "nvidia-settings", "-q", "gpus", NULL((void*)0) }; |
3688 | gchar *output = NULL((void*)0); |
3689 | gchar *errout = NULL((void*)0); |
3690 | gboolean result; |
3691 | GError *error = NULL((void*)0); |
3692 | |
3693 | result = g_spawn_sync(NULL((void*)0), args, NULL((void*)0), |
3694 | G_SPAWN_SEARCH_PATH, |
3695 | NULL((void*)0), NULL((void*)0), &output, &errout, NULL((void*)0), &error); |
3696 | |
3697 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
3698 | { |
3699 | printf("nvidia-settings: result=%d output=%s stderr=%s\n", |
3700 | (gint) result, |
3701 | output ? output : "(null)", |
3702 | errout ? errout : "(null)"); |
3703 | if (error) |
3704 | printf("\terror=%s\n", error->message); |
3705 | } |
3706 | if(result && output) |
3707 | sscanf((*output == '\n' ? output + 1 : output), "%d", &n); |
3708 | |
3709 | if (output) |
3710 | g_free(output); |
3711 | if (errout) |
3712 | g_free(errout); |
3713 | if (error) |
3714 | g_error_free(error); |
3715 | |
3716 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
3717 | g_debug("nvidia-settings gpus = %d\n", n); |
3718 | return n; |
3719 | } |
3720 | |
3721 | static gint |
3722 | sensors_nvclock_ngpus(void) |
3723 | { |
3724 | gint n = 0; |
3725 | gchar *args[] = { "nvclock", "-s", NULL((void*)0) }; |
3726 | gchar *output = NULL((void*)0), *s; |
3727 | gboolean result; |
3728 | |
3729 | result = g_spawn_sync(NULL((void*)0), args, NULL((void*)0), |
3730 | G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL, |
3731 | NULL((void*)0), NULL((void*)0), &output, NULL((void*)0), NULL((void*)0), NULL((void*)0)); |
3732 | |
3733 | if(result && output) |
3734 | { |
3735 | s = g_strrstr(output, "Card number:"); |
3736 | if (s) |
3737 | sscanf(s, "Card number: %d", &n); |
3738 | } |
3739 | g_free(output); |
3740 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
3741 | g_debug("nvclock gpus = %d\n", n); |
3742 | return n; |
3743 | } |
3744 | |
3745 | static void |
3746 | sensors_nvclock_init(gboolean enable) |
3747 | { |
3748 | gint cnt, id; |
3749 | gchar *sensor_path, *default_label; |
3750 | gchar id_name[128]; |
3751 | |
3752 | if (!enable) |
3753 | return; |
3754 | cnt = sensors_nvclock_ngpus(); |
3755 | for (id = 1; id <= cnt; ++id) |
3756 | { |
3757 | sensor_path = g_strdup_printf("%d", id); |
3758 | if (gkrellm_sys_sensors_get_temperature(sensor_path, id, 0, |
3759 | NVCLOCK_INTERFACE5, NULL((void*)0))) |
3760 | { |
3761 | snprintf(id_name, sizeof(id_name), "nvclock GPU:%d Core", id); |
3762 | if (cnt == 1) |
3763 | default_label = g_strdup_printf("GPU C"); |
3764 | else |
3765 | default_label = g_strdup_printf("GPU:%d", id); |
3766 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
3767 | sensor_path, id_name, |
3768 | id, 0, NVCLOCK_INTERFACE5, |
3769 | 1.0, 0.0, NULL((void*)0), default_label); |
3770 | g_free(default_label); |
3771 | } |
3772 | g_free(sensor_path); |
3773 | } |
3774 | } |
3775 | |
3776 | /* Remove embedded "-i2c-" or "-isa-" from /proc lm_sensors chip names so |
3777 | | there can be a chance for config name /proc -> /sysfs compatibility. |
3778 | | /proc was used in older 2.4 kerneles. |
3779 | | Munge names like w83627hf-isa-0290 to w83627hf-0-0290 |
3780 | | or w83627hf-i2c-0-0290 to w83627hf-0-0290 |
3781 | | lm_sensor i2c bus address may not be 4 digits, eg: w83782d-i2c-0-2d |
3782 | | and for that we want: w83782d-0-002d |
3783 | */ |
3784 | void |
3785 | sensors_proc_name_fix(gchar *id_name) |
3786 | { |
3787 | gchar *s; |
3788 | gint len, bus = 0; |
3789 | guint addr = 0; |
3790 | |
3791 | len = strlen(id_name) + 1; |
3792 | if ((s = strstr(id_name, "-i2c-")) != NULL((void*)0)) |
3793 | { |
3794 | sscanf(s + 5, "%d-%x", &bus, &addr); |
3795 | snprintf(s, len - (s - id_name), "-%d-%04x", bus, addr); |
3796 | } |
3797 | else if ((s = strstr(id_name, "-isa-")) != NULL((void*)0)) |
3798 | { |
3799 | *(s + 1) = '0'; |
3800 | memmove(s + 2, s + 4, strlen(s + 4) + 1); |
3801 | } |
3802 | else if ((s = strstr(id_name, "-pci-")) != NULL((void*)0)) |
3803 | { |
3804 | *(s + 1) = '0'; |
3805 | memmove(s + 2, s + 4, strlen(s + 4) + 1); |
3806 | } |
3807 | } |
3808 | |
3809 | |
3810 | gboolean |
3811 | gkrellm_sys_sensors_init(void) |
3812 | { |
3813 | FILE *f; |
3814 | GDir *dir, *chip_dir; |
3815 | VoltDefault *voltdefault; |
3816 | gint id = 0; |
3817 | gint type, voltdefaultsize, cnt, ngpus_added; |
3818 | gfloat factor, offset; |
3819 | gchar *name, *chip_name, *fixed_chip_name, *path, *default_label; |
3820 | gchar *vref, *sensor_path, *sensor_name, id_name[128], pbuf[128]; |
3821 | struct lconv *lc; |
3822 | |
3823 | lc = localeconv(); |
3824 | locale_decimal_point = *lc->decimal_point; |
3825 | if (locale_decimal_point != '.') |
3826 | need_locale_fix = TRUE(!(0)); |
3827 | |
3828 | if ((dir = g_dir_open(THERMAL_ZONE_DIR"/proc/acpi/thermal_zone", 0, NULL((void*)0))) != NULL((void*)0)) |
3829 | { |
3830 | while ((name = (gchar *) g_dir_read_name(dir)) != NULL((void*)0)) |
3831 | { |
3832 | path = g_build_filename(THERMAL_ZONE_DIR"/proc/acpi/thermal_zone", name, |
3833 | "temperature", NULL((void*)0)); |
3834 | if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) |
3835 | { |
3836 | snprintf(id_name, sizeof(id_name), "thermal_zone/%s", name); |
3837 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
3838 | path, id_name, |
3839 | id, 0, THERMAL_ZONE_INTERFACE3, |
3840 | 1.0, 0.0, NULL((void*)0), name); |
3841 | } |
3842 | g_free(path); |
3843 | } |
3844 | g_dir_close(dir); |
3845 | } |
3846 | |
3847 | if ((dir = g_dir_open(THERMAL_DIR"/proc/acpi/thermal", 0, NULL((void*)0))) != NULL((void*)0)) |
3848 | { |
3849 | while ((name = (gchar *) g_dir_read_name(dir)) != NULL((void*)0)) |
3850 | { |
3851 | path = g_build_filename(THERMAL_DIR"/proc/acpi/thermal", name, "status", NULL((void*)0)); |
3852 | if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) |
3853 | { |
3854 | snprintf(id_name, sizeof(id_name), "thermal/%s", name); |
3855 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
3856 | path, id_name, |
3857 | id, 0, THERMAL_INTERFACE2, |
3858 | 1.0, 0.0, NULL((void*)0), name); |
3859 | } |
3860 | g_free(path); |
3861 | } |
3862 | g_dir_close(dir); |
3863 | } |
3864 | |
3865 | if ((dir = g_dir_open(SYS_THERMAL_DIR"/sys/class/thermal", 0, NULL((void*)0))) != NULL((void*)0)) |
3866 | { |
3867 | while ((name = (gchar *) g_dir_read_name(dir)) != NULL((void*)0)) |
3868 | { |
3869 | path = g_build_filename(SYS_THERMAL_DIR"/sys/class/thermal", name, "temp", NULL((void*)0)); |
3870 | if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) |
3871 | { |
3872 | snprintf(id_name, sizeof(id_name), "%s", name); |
3873 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
3874 | path, id_name, |
3875 | id, 0, SYS_THERMAL_INTERFACE9, |
3876 | 1.0, 0.0, NULL((void*)0), "temp"); |
3877 | } |
3878 | g_free(path); |
3879 | } |
3880 | g_dir_close(dir); |
3881 | } |
3882 | |
3883 | /* Do initial daemon reads to get sensors loaded into sensors.c |
3884 | */ |
3885 | gkrellm_sys_sensors_hddtemp_check(); |
3886 | gkrellm_sys_sensors_mbmon_check(TRUE(!(0))); |
3887 | |
3888 | /* |
3889 | * IBM ACPI Temperature Sensors |
3890 | */ |
3891 | if ((f = fopen(IBM_ACPI_THERMAL"/proc/acpi/ibm/thermal", "r")) != NULL((void*)0)) |
3892 | { |
3893 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
3894 | IBM_ACPI_THERMAL"/proc/acpi/ibm/thermal", "IBM ACPI CPU", |
3895 | id, IBM_ACPI_CPU_TEMP0, IBM_ACPI_INTERFACE6, |
3896 | 1.0, 0.0, NULL((void*)0), "CPU"); |
3897 | |
3898 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
3899 | IBM_ACPI_THERMAL"/proc/acpi/ibm/thermal", "IBM ACPI Mini PCI Module", |
3900 | id, IBM_ACPI_PCI_TEMP1, IBM_ACPI_INTERFACE6, |
3901 | 1.0, 0.0, NULL((void*)0), "PCI"); |
3902 | |
3903 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
3904 | IBM_ACPI_THERMAL"/proc/acpi/ibm/thermal", "IBM ACPI HDD", |
3905 | id, IBM_ACPI_HDD_TEMP2, IBM_ACPI_INTERFACE6, |
3906 | 1.0, 0.0, NULL((void*)0), "HDD"); |
3907 | |
3908 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
3909 | IBM_ACPI_THERMAL"/proc/acpi/ibm/thermal", "IBM ACPI GPU", |
3910 | id, IBM_ACPI_GPU_TEMP3, IBM_ACPI_INTERFACE6, |
3911 | 1.0, 0.0, NULL((void*)0), "GPU"); |
3912 | |
3913 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
3914 | IBM_ACPI_THERMAL"/proc/acpi/ibm/thermal", "IBM ACPI Battery 1", |
3915 | id, IBM_ACPI_BAT1_TEMP4, IBM_ACPI_INTERFACE6, |
3916 | 1.0, 0.0, NULL((void*)0), "BAT1"); |
3917 | |
3918 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
3919 | IBM_ACPI_THERMAL"/proc/acpi/ibm/thermal", "IBM ACPI Battery 2", |
3920 | id, IBM_ACPI_BAT2_TEMP6, IBM_ACPI_INTERFACE6, |
3921 | 1.0, 0.0, NULL((void*)0), "BAT2"); |
3922 | fclose(f); |
3923 | } |
3924 | |
3925 | /* IBM ACPI Cooling Fan Sensor |
3926 | */ |
3927 | if ((f = fopen(IBM_ACPI_FAN_FILE"/proc/acpi/ibm/fan", "r")) != NULL((void*)0)) |
3928 | { |
3929 | gkrellm_sensors_add_sensor(SENSOR_FAN1, |
3930 | IBM_ACPI_FAN_FILE"/proc/acpi/ibm/fan", "IBM ACPI Fan Sensor", |
3931 | id, IBM_ACPI_FAN8, IBM_ACPI_INTERFACE6, |
3932 | 1.0, 0.0, NULL((void*)0), "Fan"); |
3933 | fclose(f); |
3934 | } |
3935 | |
3936 | sensors_nvidia_smi_read(TRUE(!(0))); |
3937 | |
3938 | /* nvidia-settings GPU core & ambient temperatues |
3939 | */ |
3940 | cnt = sensors_nvidia_settings_ngpus(); |
3941 | ngpus_added = 0; |
3942 | if (cnt < 2) |
3943 | { |
3944 | if (gkrellm_sys_sensors_get_temperature("GPUCoreTemp", id, 0, |
3945 | NVIDIA_SETTINGS_INTERFACE4, NULL((void*)0))) |
3946 | { |
3947 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
3948 | "GPUCoreTemp", "nVidia GPU Core", |
3949 | id, 0, NVIDIA_SETTINGS_INTERFACE4, |
3950 | 1.0, 0.0, NULL((void*)0), "GPU C"); |
3951 | ++ngpus_added; |
3952 | } |
3953 | } |
3954 | else |
3955 | { |
3956 | for (id = 0; id < cnt; ++id) |
3957 | { |
3958 | sensor_path = g_strdup_printf("[gpu:%d]/GPUCoreTemp", id); |
3959 | if (gkrellm_sys_sensors_get_temperature(sensor_path, id, 0, |
3960 | NVIDIA_SETTINGS_INTERFACE4, NULL((void*)0))) |
3961 | { |
3962 | snprintf(id_name, sizeof(id_name), "nVidia GPU:%d Core", id); |
3963 | default_label = g_strdup_printf("GPU:%d", id); |
3964 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
3965 | sensor_path, id_name, |
3966 | id, 0, NVIDIA_SETTINGS_INTERFACE4, |
3967 | 1.0, 0.0, NULL((void*)0), default_label); |
3968 | g_free(default_label); |
3969 | ++ngpus_added; |
3970 | } |
3971 | g_free(sensor_path); |
3972 | } |
3973 | } |
3974 | |
3975 | /* nvclock can get temps for some cards where nvidia-settings fails. |
3976 | | nvclock card numbers start at 1. Make an option because nvclock |
3977 | | doesn't handle all nvidia chips (6150) where it will always reread |
3978 | | GPU bios which slows gkrellm startup to several seconds. |
3979 | */ |
3980 | if (ngpus_added == 0) |
3981 | gkrellm_sensors_sysdep_option("use_nvclock", |
3982 | _("Use nvclock for NVIDIA GPU temperatures")dcgettext ("gkrellm", "Use nvclock for NVIDIA GPU temperatures" , 5), |
3983 | sensors_nvclock_init); |
3984 | |
3985 | id = 0; |
3986 | /* Try for ambient only for gpu:0 for now */ |
3987 | if (gkrellm_sys_sensors_get_temperature("GPUAmbientTemp", id, 0, |
3988 | NVIDIA_SETTINGS_INTERFACE4, NULL((void*)0))) |
3989 | { |
3990 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
3991 | "GPUAmbientTemp", "nVidia GPU Ambient", |
3992 | id, 0, NVIDIA_SETTINGS_INTERFACE4, |
3993 | 1.0, 0.0, NULL((void*)0), "GPU A"); |
3994 | } |
3995 | |
3996 | |
3997 | /* UNINORTH sensors |
3998 | */ |
3999 | if ((dir = g_dir_open(UNINORTH_DIR"/sys/devices/temperatures", 0, NULL((void*)0))) != NULL((void*)0)) |
4000 | { |
4001 | while (( sensor_name = (gchar *) g_dir_read_name(dir)) != NULL((void*)0) ) |
4002 | { |
4003 | if (strncmp(sensor_name, "sensor", 6)(__extension__ (__builtin_constant_p (6) && ((__builtin_constant_p (sensor_name) && strlen (sensor_name) < ((size_t) (6))) || (__builtin_constant_p ("sensor") && strlen ( "sensor") < ((size_t) (6)))) ? __extension__ ({ size_t __s1_len , __s2_len; (__builtin_constant_p (sensor_name) && __builtin_constant_p ("sensor") && (__s1_len = strlen (sensor_name), __s2_len = strlen ("sensor"), (!((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("sensor") + 1 ) - (size_t)(const void *)("sensor") == 1) || __s2_len >= 4 )) ? __builtin_strcmp (sensor_name, "sensor") : (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name ) + 1) - (size_t)(const void *)(sensor_name) == 1) && (__s1_len = strlen (sensor_name), __s1_len < 4) ? (__builtin_constant_p ("sensor") && ((size_t)(const void *)(("sensor") + 1 ) - (size_t)(const void *)("sensor") == 1) ? __builtin_strcmp (sensor_name, "sensor") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("sensor"); int __result = (((const unsigned char *) (const char *) (sensor_name ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (sensor_name ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (sensor_name ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (sensor_name ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "sensor") && ((size_t)(const void *)(("sensor") + 1) - (size_t)(const void *)("sensor") == 1) && (__s2_len = strlen ("sensor"), __s2_len < 4) ? (__builtin_constant_p ( sensor_name) && ((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name) == 1) ? __builtin_strcmp (sensor_name, "sensor") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sensor_name ); int __result = (((const unsigned char *) (const char *) ("sensor" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("sensor" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("sensor" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("sensor" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (sensor_name , "sensor")))); }) : strncmp (sensor_name, "sensor", 6))) == 0) |
4004 | { |
4005 | sensor_path = g_build_filename(UNINORTH_DIR"/sys/devices/temperatures", sensor_name,NULL((void*)0)); |
4006 | if (strncmp(sensor_name + 8, "temperature", 11)(__extension__ (__builtin_constant_p (11) && ((__builtin_constant_p (sensor_name + 8) && strlen (sensor_name + 8) < ( (size_t) (11))) || (__builtin_constant_p ("temperature") && strlen ("temperature") < ((size_t) (11)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (sensor_name + 8) && __builtin_constant_p ("temperature") && (__s1_len = strlen (sensor_name + 8), __s2_len = strlen ("temperature" ), (!((size_t)(const void *)((sensor_name + 8) + 1) - (size_t )(const void *)(sensor_name + 8) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("temperature") + 1) - (size_t)(const void *)("temperature") == 1) || __s2_len >= 4)) ? __builtin_strcmp (sensor_name + 8, "temperature") : (__builtin_constant_p (sensor_name + 8) && ((size_t)(const void *)((sensor_name + 8) + 1 ) - (size_t)(const void *)(sensor_name + 8) == 1) && ( __s1_len = strlen (sensor_name + 8), __s1_len < 4) ? (__builtin_constant_p ("temperature") && ((size_t)(const void *)(("temperature" ) + 1) - (size_t)(const void *)("temperature") == 1) ? __builtin_strcmp (sensor_name + 8, "temperature") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("temperature" ); int __result = (((const unsigned char *) (const char *) (sensor_name + 8))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( sensor_name + 8))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (sensor_name + 8))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char * ) (const char *) (sensor_name + 8))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("temperature") && ((size_t )(const void *)(("temperature") + 1) - (size_t)(const void *) ("temperature") == 1) && (__s2_len = strlen ("temperature" ), __s2_len < 4) ? (__builtin_constant_p (sensor_name + 8) && ((size_t)(const void *)((sensor_name + 8) + 1) - ( size_t)(const void *)(sensor_name + 8) == 1) ? __builtin_strcmp (sensor_name + 8, "temperature") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sensor_name + 8); int __result = (((const unsigned char *) ( const char *) ("temperature"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("temperature"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("temperature"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("temperature"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (sensor_name + 8, "temperature"))) ); }) : strncmp (sensor_name + 8, "temperature", 11))) == 0) |
4007 | { |
4008 | // linux <= 2.6.12 had [cg]pu_temperature instead of |
4009 | // sensor[12]_temperature |
4010 | |
4011 | // TODO: read sensorN_location instead of fixed positions |
4012 | if ( sensor_name[6] == '1' |
4013 | || (strncmp(sensor_name, "cpu", 3)(__extension__ (__builtin_constant_p (3) && ((__builtin_constant_p (sensor_name) && strlen (sensor_name) < ((size_t) (3))) || (__builtin_constant_p ("cpu") && strlen ("cpu" ) < ((size_t) (3)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (sensor_name) && __builtin_constant_p ("cpu") && (__s1_len = strlen (sensor_name), __s2_len = strlen ("cpu"), (!((size_t)(const void *)((sensor_name) + 1 ) - (size_t)(const void *)(sensor_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("cpu") + 1) - (size_t )(const void *)("cpu") == 1) || __s2_len >= 4)) ? __builtin_strcmp (sensor_name, "cpu") : (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name) == 1) && (__s1_len = strlen (sensor_name ), __s1_len < 4) ? (__builtin_constant_p ("cpu") && ((size_t)(const void *)(("cpu") + 1) - (size_t)(const void * )("cpu") == 1) ? __builtin_strcmp (sensor_name, "cpu") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("cpu"); int __result = (((const unsigned char *) (const char *) (sensor_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (sensor_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (sensor_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (sensor_name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("cpu") && ((size_t)(const void *)(("cpu") + 1) - (size_t )(const void *)("cpu") == 1) && (__s2_len = strlen ("cpu" ), __s2_len < 4) ? (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name) == 1) ? __builtin_strcmp (sensor_name, "cpu" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sensor_name); int __result = (((const unsigned char *) (const char *) ("cpu"))[0] - __s2[0]); if ( __s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("cpu"))[1] - __s2[1]); if ( __s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("cpu"))[2] - __s2[2]); if ( __s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("cpu"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (sensor_name, "cpu")))); }) : strncmp (sensor_name, "cpu", 3)))) == 0 |
4014 | ) |
4015 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
4016 | sensor_path, "cpu topside", |
4017 | id, 0, UNINORTH_INTERFACE7, |
4018 | 1.0, 0.0, NULL((void*)0), "CPU"); |
4019 | else if ( sensor_name[6] == '2' |
4020 | || (strncmp(sensor_name, "gpu", 3)(__extension__ (__builtin_constant_p (3) && ((__builtin_constant_p (sensor_name) && strlen (sensor_name) < ((size_t) (3))) || (__builtin_constant_p ("gpu") && strlen ("gpu" ) < ((size_t) (3)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (sensor_name) && __builtin_constant_p ("gpu") && (__s1_len = strlen (sensor_name), __s2_len = strlen ("gpu"), (!((size_t)(const void *)((sensor_name) + 1 ) - (size_t)(const void *)(sensor_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("gpu") + 1) - (size_t )(const void *)("gpu") == 1) || __s2_len >= 4)) ? __builtin_strcmp (sensor_name, "gpu") : (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name) == 1) && (__s1_len = strlen (sensor_name ), __s1_len < 4) ? (__builtin_constant_p ("gpu") && ((size_t)(const void *)(("gpu") + 1) - (size_t)(const void * )("gpu") == 1) ? __builtin_strcmp (sensor_name, "gpu") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("gpu"); int __result = (((const unsigned char *) (const char *) (sensor_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (sensor_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (sensor_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (sensor_name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("gpu") && ((size_t)(const void *)(("gpu") + 1) - (size_t )(const void *)("gpu") == 1) && (__s2_len = strlen ("gpu" ), __s2_len < 4) ? (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name) == 1) ? __builtin_strcmp (sensor_name, "gpu" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sensor_name); int __result = (((const unsigned char *) (const char *) ("gpu"))[0] - __s2[0]); if ( __s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("gpu"))[1] - __s2[1]); if ( __s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("gpu"))[2] - __s2[2]); if ( __s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("gpu"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (sensor_name, "gpu")))); }) : strncmp (sensor_name, "gpu", 3)))) == 0 |
4021 | ) |
4022 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
4023 | sensor_path, "gpu on die", |
4024 | id, 0, UNINORTH_INTERFACE7, |
4025 | 1.0, 0.0, NULL((void*)0), "GPU"); |
4026 | } |
4027 | g_free(sensor_path); |
4028 | } |
4029 | } |
4030 | g_dir_close(dir); |
4031 | } |
4032 | |
4033 | /* Windfarm (PowerMac G5, others?)) */ |
4034 | cnt = 0; |
4035 | do |
4036 | { |
4037 | snprintf(pbuf, sizeof(pbuf), WINDFARM_DIR"/sys/devices/platform/windfarm.%d", cnt++); |
4038 | if ((dir = g_dir_open(pbuf, 0, NULL((void*)0))) != NULL((void*)0)) |
4039 | { |
4040 | while ((sensor_name = (gchar *) g_dir_read_name(dir)) != NULL((void*)0)) |
4041 | { |
4042 | sensor_path = g_build_filename(pbuf, sensor_name, NULL((void*)0)); |
4043 | if (strncmp(sensor_name, "cpu-temp-", 9)(__extension__ (__builtin_constant_p (9) && ((__builtin_constant_p (sensor_name) && strlen (sensor_name) < ((size_t) (9))) || (__builtin_constant_p ("cpu-temp-") && strlen ("cpu-temp-") < ((size_t) (9)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (sensor_name) && __builtin_constant_p ("cpu-temp-") && (__s1_len = strlen (sensor_name), __s2_len = strlen ("cpu-temp-"), (!((size_t)( const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("cpu-temp-") + 1) - (size_t)(const void *)("cpu-temp-") == 1) || __s2_len >= 4)) ? __builtin_strcmp (sensor_name, "cpu-temp-" ) : (__builtin_constant_p (sensor_name) && ((size_t)( const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name ) == 1) && (__s1_len = strlen (sensor_name), __s1_len < 4) ? (__builtin_constant_p ("cpu-temp-") && ((size_t )(const void *)(("cpu-temp-") + 1) - (size_t)(const void *)("cpu-temp-" ) == 1) ? __builtin_strcmp (sensor_name, "cpu-temp-") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("cpu-temp-"); int __result = (((const unsigned char *) (const char *) (sensor_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (sensor_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (sensor_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (sensor_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("cpu-temp-") && ((size_t )(const void *)(("cpu-temp-") + 1) - (size_t)(const void *)("cpu-temp-" ) == 1) && (__s2_len = strlen ("cpu-temp-"), __s2_len < 4) ? (__builtin_constant_p (sensor_name) && ((size_t )(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name ) == 1) ? __builtin_strcmp (sensor_name, "cpu-temp-") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sensor_name); int __result = (((const unsigned char *) (const char *) ("cpu-temp-"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("cpu-temp-"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("cpu-temp-"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("cpu-temp-"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (sensor_name, "cpu-temp-")))); }) : strncmp (sensor_name, "cpu-temp-", 9))) == 0) |
4044 | { |
4045 | sscanf(sensor_name + 9, "%d", &id); |
4046 | snprintf(id_name, sizeof(id_name), "CPU %d", id); |
4047 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
4048 | sensor_path, |
4049 | id_name, id, 0, |
4050 | WINDFARM_INTERFACE8, |
4051 | 1.0, 0.0, NULL((void*)0), id_name); |
4052 | } |
4053 | else if (strcmp(sensor_name, "backside-temp")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (sensor_name) && __builtin_constant_p ("backside-temp" ) && (__s1_len = strlen (sensor_name), __s2_len = strlen ("backside-temp"), (!((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("backside-temp") + 1 ) - (size_t)(const void *)("backside-temp") == 1) || __s2_len >= 4)) ? __builtin_strcmp (sensor_name, "backside-temp") : (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name ) == 1) && (__s1_len = strlen (sensor_name), __s1_len < 4) ? (__builtin_constant_p ("backside-temp") && ((size_t)(const void *)(("backside-temp") + 1) - (size_t)(const void *)("backside-temp") == 1) ? __builtin_strcmp (sensor_name , "backside-temp") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("backside-temp"); int __result = (((const unsigned char *) (const char *) (sensor_name ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (sensor_name ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (sensor_name ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (sensor_name ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "backside-temp") && ((size_t)(const void *)(("backside-temp" ) + 1) - (size_t)(const void *)("backside-temp") == 1) && (__s2_len = strlen ("backside-temp"), __s2_len < 4) ? (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name ) + 1) - (size_t)(const void *)(sensor_name) == 1) ? __builtin_strcmp (sensor_name, "backside-temp") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sensor_name ); int __result = (((const unsigned char *) (const char *) ("backside-temp" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("backside-temp" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("backside-temp" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("backside-temp" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (sensor_name , "backside-temp")))); }) == 0) |
4054 | { |
4055 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
4056 | sensor_path, |
4057 | "Backside", 0, 0, |
4058 | WINDFARM_INTERFACE8, |
4059 | 1.0, 0.0, NULL((void*)0), "Backside"); |
4060 | } |
4061 | else if (strcmp(sensor_name, "backside-fan")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (sensor_name) && __builtin_constant_p ("backside-fan" ) && (__s1_len = strlen (sensor_name), __s2_len = strlen ("backside-fan"), (!((size_t)(const void *)((sensor_name) + 1 ) - (size_t)(const void *)(sensor_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("backside-fan") + 1 ) - (size_t)(const void *)("backside-fan") == 1) || __s2_len >= 4)) ? __builtin_strcmp (sensor_name, "backside-fan") : (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name ) + 1) - (size_t)(const void *)(sensor_name) == 1) && (__s1_len = strlen (sensor_name), __s1_len < 4) ? (__builtin_constant_p ("backside-fan") && ((size_t)(const void *)(("backside-fan" ) + 1) - (size_t)(const void *)("backside-fan") == 1) ? __builtin_strcmp (sensor_name, "backside-fan") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("backside-fan" ); int __result = (((const unsigned char *) (const char *) (sensor_name ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (sensor_name ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (sensor_name ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (sensor_name ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "backside-fan") && ((size_t)(const void *)(("backside-fan" ) + 1) - (size_t)(const void *)("backside-fan") == 1) && (__s2_len = strlen ("backside-fan"), __s2_len < 4) ? (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name ) + 1) - (size_t)(const void *)(sensor_name) == 1) ? __builtin_strcmp (sensor_name, "backside-fan") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sensor_name ); int __result = (((const unsigned char *) (const char *) ("backside-fan" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("backside-fan" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("backside-fan" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("backside-fan" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (sensor_name , "backside-fan")))); }) == 0) |
4062 | { |
4063 | gkrellm_sensors_add_sensor(SENSOR_FAN1, |
4064 | sensor_path, |
4065 | "Backside", 0, 0, |
4066 | WINDFARM_INTERFACE8, |
4067 | 1.0, 0.0, NULL((void*)0), "Backside"); |
4068 | } |
4069 | else if (strncmp(sensor_name, "cpu-front-fan-", 14)(__extension__ (__builtin_constant_p (14) && ((__builtin_constant_p (sensor_name) && strlen (sensor_name) < ((size_t) (14))) || (__builtin_constant_p ("cpu-front-fan-") && strlen ("cpu-front-fan-") < ((size_t) (14)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (sensor_name ) && __builtin_constant_p ("cpu-front-fan-") && (__s1_len = strlen (sensor_name), __s2_len = strlen ("cpu-front-fan-" ), (!((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)(("cpu-front-fan-") + 1) - (size_t)(const void *)("cpu-front-fan-") == 1) || __s2_len >= 4)) ? __builtin_strcmp (sensor_name, "cpu-front-fan-") : (__builtin_constant_p (sensor_name ) && ((size_t)(const void *)((sensor_name) + 1) - (size_t )(const void *)(sensor_name) == 1) && (__s1_len = strlen (sensor_name), __s1_len < 4) ? (__builtin_constant_p ("cpu-front-fan-" ) && ((size_t)(const void *)(("cpu-front-fan-") + 1) - (size_t)(const void *)("cpu-front-fan-") == 1) ? __builtin_strcmp (sensor_name, "cpu-front-fan-") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("cpu-front-fan-" ); int __result = (((const unsigned char *) (const char *) (sensor_name ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (sensor_name ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (sensor_name ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (sensor_name ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "cpu-front-fan-") && ((size_t)(const void *)(("cpu-front-fan-" ) + 1) - (size_t)(const void *)("cpu-front-fan-") == 1) && (__s2_len = strlen ("cpu-front-fan-"), __s2_len < 4) ? (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name ) + 1) - (size_t)(const void *)(sensor_name) == 1) ? __builtin_strcmp (sensor_name, "cpu-front-fan-") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sensor_name); int __result = (((const unsigned char *) (const char *) ("cpu-front-fan-"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("cpu-front-fan-"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("cpu-front-fan-"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("cpu-front-fan-"))[3] - __s2 [3]); } } __result; })))) : __builtin_strcmp (sensor_name, "cpu-front-fan-" )))); }) : strncmp (sensor_name, "cpu-front-fan-", 14))) == 0) |
4070 | { |
4071 | sscanf(sensor_name + 14, "%d", &id); |
4072 | snprintf(id_name, sizeof(id_name), "CPU Front %d", id); |
4073 | gkrellm_sensors_add_sensor(SENSOR_FAN1, |
4074 | sensor_path, |
4075 | id_name, id, 0, |
4076 | WINDFARM_INTERFACE8, |
4077 | 1.0, 0.0, NULL((void*)0), id_name); |
4078 | } |
4079 | else if (strncmp(sensor_name, "cpu-rear-fan-", 13)(__extension__ (__builtin_constant_p (13) && ((__builtin_constant_p (sensor_name) && strlen (sensor_name) < ((size_t) (13))) || (__builtin_constant_p ("cpu-rear-fan-") && strlen ("cpu-rear-fan-") < ((size_t) (13)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (sensor_name ) && __builtin_constant_p ("cpu-rear-fan-") && (__s1_len = strlen (sensor_name), __s2_len = strlen ("cpu-rear-fan-" ), (!((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)(("cpu-rear-fan-") + 1) - (size_t)(const void *)("cpu-rear-fan-") == 1) || __s2_len >= 4)) ? __builtin_strcmp (sensor_name, "cpu-rear-fan-") : (__builtin_constant_p (sensor_name ) && ((size_t)(const void *)((sensor_name) + 1) - (size_t )(const void *)(sensor_name) == 1) && (__s1_len = strlen (sensor_name), __s1_len < 4) ? (__builtin_constant_p ("cpu-rear-fan-" ) && ((size_t)(const void *)(("cpu-rear-fan-") + 1) - (size_t)(const void *)("cpu-rear-fan-") == 1) ? __builtin_strcmp (sensor_name, "cpu-rear-fan-") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("cpu-rear-fan-" ); int __result = (((const unsigned char *) (const char *) (sensor_name ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (sensor_name ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (sensor_name ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (sensor_name ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "cpu-rear-fan-") && ((size_t)(const void *)(("cpu-rear-fan-" ) + 1) - (size_t)(const void *)("cpu-rear-fan-") == 1) && (__s2_len = strlen ("cpu-rear-fan-"), __s2_len < 4) ? (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name ) + 1) - (size_t)(const void *)(sensor_name) == 1) ? __builtin_strcmp (sensor_name, "cpu-rear-fan-") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sensor_name ); int __result = (((const unsigned char *) (const char *) ("cpu-rear-fan-" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("cpu-rear-fan-" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("cpu-rear-fan-" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("cpu-rear-fan-" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (sensor_name , "cpu-rear-fan-")))); }) : strncmp (sensor_name, "cpu-rear-fan-" , 13))) == 0) |
4080 | { |
4081 | sscanf(sensor_name + 13, "%d", &id); |
4082 | snprintf(id_name, sizeof(id_name), "CPU Rear %d", id); |
4083 | gkrellm_sensors_add_sensor(SENSOR_FAN1, |
4084 | sensor_path, |
4085 | id_name, id, 0, |
4086 | WINDFARM_INTERFACE8, |
4087 | 1.0, 0.0, NULL((void*)0), id_name); |
4088 | } |
4089 | else if (strncmp(sensor_name, "cpu-pump-", 9)(__extension__ (__builtin_constant_p (9) && ((__builtin_constant_p (sensor_name) && strlen (sensor_name) < ((size_t) (9))) || (__builtin_constant_p ("cpu-pump-") && strlen ("cpu-pump-") < ((size_t) (9)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (sensor_name) && __builtin_constant_p ("cpu-pump-") && (__s1_len = strlen (sensor_name), __s2_len = strlen ("cpu-pump-"), (!((size_t)( const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("cpu-pump-") + 1) - (size_t)(const void *)("cpu-pump-") == 1) || __s2_len >= 4)) ? __builtin_strcmp (sensor_name, "cpu-pump-" ) : (__builtin_constant_p (sensor_name) && ((size_t)( const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name ) == 1) && (__s1_len = strlen (sensor_name), __s1_len < 4) ? (__builtin_constant_p ("cpu-pump-") && ((size_t )(const void *)(("cpu-pump-") + 1) - (size_t)(const void *)("cpu-pump-" ) == 1) ? __builtin_strcmp (sensor_name, "cpu-pump-") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("cpu-pump-"); int __result = (((const unsigned char *) (const char *) (sensor_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (sensor_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (sensor_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (sensor_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("cpu-pump-") && ((size_t )(const void *)(("cpu-pump-") + 1) - (size_t)(const void *)("cpu-pump-" ) == 1) && (__s2_len = strlen ("cpu-pump-"), __s2_len < 4) ? (__builtin_constant_p (sensor_name) && ((size_t )(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name ) == 1) ? __builtin_strcmp (sensor_name, "cpu-pump-") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sensor_name); int __result = (((const unsigned char *) (const char *) ("cpu-pump-"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("cpu-pump-"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("cpu-pump-"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("cpu-pump-"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (sensor_name, "cpu-pump-")))); }) : strncmp (sensor_name, "cpu-pump-", 9))) == 0) |
4090 | { |
4091 | /* <johill> well, a fan is just an airpump too, right ;) */ |
4092 | sscanf(sensor_name + 9, "%d", &id); |
4093 | snprintf(id_name, sizeof(id_name), "CPU Pump %d", id); |
4094 | gkrellm_sensors_add_sensor(SENSOR_FAN1, |
4095 | sensor_path, |
4096 | id_name, id, 0, |
4097 | WINDFARM_INTERFACE8, |
4098 | 1.0, 0.0, NULL((void*)0), id_name); |
4099 | } |
4100 | else if (strcmp(sensor_name, "hd-temp")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (sensor_name) && __builtin_constant_p ("hd-temp") && (__s1_len = strlen (sensor_name), __s2_len = strlen ("hd-temp" ), (!((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)(("hd-temp") + 1) - (size_t)(const void *)("hd-temp") == 1) || __s2_len >= 4)) ? __builtin_strcmp (sensor_name, "hd-temp") : (__builtin_constant_p (sensor_name ) && ((size_t)(const void *)((sensor_name) + 1) - (size_t )(const void *)(sensor_name) == 1) && (__s1_len = strlen (sensor_name), __s1_len < 4) ? (__builtin_constant_p ("hd-temp" ) && ((size_t)(const void *)(("hd-temp") + 1) - (size_t )(const void *)("hd-temp") == 1) ? __builtin_strcmp (sensor_name , "hd-temp") : (__extension__ ({ const unsigned char *__s2 = ( const unsigned char *) (const char *) ("hd-temp"); int __result = (((const unsigned char *) (const char *) (sensor_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (sensor_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (sensor_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (sensor_name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("hd-temp" ) && ((size_t)(const void *)(("hd-temp") + 1) - (size_t )(const void *)("hd-temp") == 1) && (__s2_len = strlen ("hd-temp"), __s2_len < 4) ? (__builtin_constant_p (sensor_name ) && ((size_t)(const void *)((sensor_name) + 1) - (size_t )(const void *)(sensor_name) == 1) ? __builtin_strcmp (sensor_name , "hd-temp") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sensor_name); int __result = (((const unsigned char *) (const char *) ("hd-temp"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("hd-temp"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("hd-temp"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("hd-temp"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (sensor_name , "hd-temp")))); }) == 0) |
4101 | { |
4102 | gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE0, |
4103 | sensor_path, |
4104 | "Harddisk", 0, 0, |
4105 | WINDFARM_INTERFACE8, |
4106 | 1.0, 0.0, NULL((void*)0), "Harddisk"); |
4107 | } |
4108 | else if (strcmp(sensor_name, "slots-fan")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (sensor_name) && __builtin_constant_p ("slots-fan") && (__s1_len = strlen (sensor_name), __s2_len = strlen ("slots-fan" ), (!((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)(("slots-fan") + 1) - (size_t)(const void *)("slots-fan") == 1) || __s2_len >= 4)) ? __builtin_strcmp (sensor_name, "slots-fan") : (__builtin_constant_p (sensor_name ) && ((size_t)(const void *)((sensor_name) + 1) - (size_t )(const void *)(sensor_name) == 1) && (__s1_len = strlen (sensor_name), __s1_len < 4) ? (__builtin_constant_p ("slots-fan" ) && ((size_t)(const void *)(("slots-fan") + 1) - (size_t )(const void *)("slots-fan") == 1) ? __builtin_strcmp (sensor_name , "slots-fan") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("slots-fan"); int __result = (((const unsigned char *) (const char *) (sensor_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (sensor_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (sensor_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (sensor_name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("slots-fan" ) && ((size_t)(const void *)(("slots-fan") + 1) - (size_t )(const void *)("slots-fan") == 1) && (__s2_len = strlen ("slots-fan"), __s2_len < 4) ? (__builtin_constant_p (sensor_name ) && ((size_t)(const void *)((sensor_name) + 1) - (size_t )(const void *)(sensor_name) == 1) ? __builtin_strcmp (sensor_name , "slots-fan") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sensor_name); int __result = (((const unsigned char *) (const char *) ("slots-fan"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("slots-fan"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("slots-fan"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("slots-fan"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (sensor_name , "slots-fan")))); }) == 0) |
4109 | { |
4110 | gkrellm_sensors_add_sensor(SENSOR_FAN1, |
4111 | sensor_path, |
4112 | "Slots", 0, 0, |
4113 | WINDFARM_INTERFACE8, |
4114 | 1.0, 0.0, NULL((void*)0), "Slots"); |
4115 | } |
4116 | else if (strcmp(sensor_name, "drive-bay-fan")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (sensor_name) && __builtin_constant_p ("drive-bay-fan" ) && (__s1_len = strlen (sensor_name), __s2_len = strlen ("drive-bay-fan"), (!((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("drive-bay-fan") + 1 ) - (size_t)(const void *)("drive-bay-fan") == 1) || __s2_len >= 4)) ? __builtin_strcmp (sensor_name, "drive-bay-fan") : (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name ) == 1) && (__s1_len = strlen (sensor_name), __s1_len < 4) ? (__builtin_constant_p ("drive-bay-fan") && ((size_t)(const void *)(("drive-bay-fan") + 1) - (size_t)(const void *)("drive-bay-fan") == 1) ? __builtin_strcmp (sensor_name , "drive-bay-fan") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("drive-bay-fan"); int __result = (((const unsigned char *) (const char *) (sensor_name ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (sensor_name ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (sensor_name ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (sensor_name ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "drive-bay-fan") && ((size_t)(const void *)(("drive-bay-fan" ) + 1) - (size_t)(const void *)("drive-bay-fan") == 1) && (__s2_len = strlen ("drive-bay-fan"), __s2_len < 4) ? (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name ) + 1) - (size_t)(const void *)(sensor_name) == 1) ? __builtin_strcmp (sensor_name, "drive-bay-fan") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sensor_name ); int __result = (((const unsigned char *) (const char *) ("drive-bay-fan" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("drive-bay-fan" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("drive-bay-fan" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("drive-bay-fan" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (sensor_name , "drive-bay-fan")))); }) == 0) |
4117 | { |
4118 | gkrellm_sensors_add_sensor(SENSOR_FAN1, |
4119 | sensor_path, |
4120 | "Drive Bay", 0, 0, |
4121 | WINDFARM_INTERFACE8, |
4122 | 1.0, 0.0, NULL((void*)0), "Drive Bay"); |
4123 | } |
4124 | else if (strncmp(sensor_name, "cpu-voltage-", 12)(__extension__ (__builtin_constant_p (12) && ((__builtin_constant_p (sensor_name) && strlen (sensor_name) < ((size_t) (12))) || (__builtin_constant_p ("cpu-voltage-") && strlen ("cpu-voltage-") < ((size_t) (12)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (sensor_name) && __builtin_constant_p ("cpu-voltage-") && (__s1_len = strlen (sensor_name), __s2_len = strlen ("cpu-voltage-"), (! ((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name) == 1) || __s1_len >= 4) && (!((size_t )(const void *)(("cpu-voltage-") + 1) - (size_t)(const void * )("cpu-voltage-") == 1) || __s2_len >= 4)) ? __builtin_strcmp (sensor_name, "cpu-voltage-") : (__builtin_constant_p (sensor_name ) && ((size_t)(const void *)((sensor_name) + 1) - (size_t )(const void *)(sensor_name) == 1) && (__s1_len = strlen (sensor_name), __s1_len < 4) ? (__builtin_constant_p ("cpu-voltage-" ) && ((size_t)(const void *)(("cpu-voltage-") + 1) - ( size_t)(const void *)("cpu-voltage-") == 1) ? __builtin_strcmp (sensor_name, "cpu-voltage-") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("cpu-voltage-" ); int __result = (((const unsigned char *) (const char *) (sensor_name ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (sensor_name ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (sensor_name ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (sensor_name ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "cpu-voltage-") && ((size_t)(const void *)(("cpu-voltage-" ) + 1) - (size_t)(const void *)("cpu-voltage-") == 1) && (__s2_len = strlen ("cpu-voltage-"), __s2_len < 4) ? (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name ) + 1) - (size_t)(const void *)(sensor_name) == 1) ? __builtin_strcmp (sensor_name, "cpu-voltage-") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sensor_name ); int __result = (((const unsigned char *) (const char *) ("cpu-voltage-" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("cpu-voltage-" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("cpu-voltage-" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("cpu-voltage-" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (sensor_name , "cpu-voltage-")))); }) : strncmp (sensor_name, "cpu-voltage-" , 12))) == 0) |
4125 | { |
4126 | sscanf(sensor_name + 12, "%d", &id); |
4127 | snprintf(id_name, sizeof(id_name), "CPU %d", id); |
4128 | gkrellm_sensors_add_sensor(SENSOR_VOLTAGE2, |
4129 | sensor_path, |
4130 | id_name, id, 0, |
4131 | WINDFARM_INTERFACE8, |
4132 | 1.0, 0.0, NULL((void*)0), id_name); |
4133 | } |
4134 | g_free(sensor_path); |
4135 | } |
4136 | g_dir_close(dir); |
4137 | } |
4138 | } |
4139 | while (dir != NULL((void*)0)); |
4140 | |
4141 | #ifdef HAVE_LIBSENSORS1 |
4142 | if (!_GK.without_libsensors && libsensors_init()) |
4143 | { |
4144 | gkrellm_sensors_config_migrate_connect(sensors_config_migrate, |
4145 | SENSOR_NAMES_LIBSENSORS2); |
4146 | return TRUE(!(0)); |
4147 | } |
4148 | #else |
4149 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
4150 | g_debug("libsensors support is not compiled in.\n"); |
4151 | |
4152 | #endif |
4153 | |
4154 | if ((dir = g_dir_open(SENSORS_DIR"/proc/sys/dev/sensors", 0, NULL((void*)0))) == NULL((void*)0)) |
4155 | { |
4156 | sysfs_sensors_init(); |
4157 | return TRUE(!(0)); |
4158 | } |
4159 | while ((chip_name = (gchar *) g_dir_read_name(dir)) != NULL((void*)0)) |
4160 | { |
4161 | fixed_chip_name = g_strdup(chip_name); |
4162 | sensors_proc_name_fix(fixed_chip_name); |
4163 | |
4164 | path = g_build_filename(SENSORS_DIR"/proc/sys/dev/sensors", chip_name, NULL((void*)0)); |
4165 | chip_dir = g_dir_open(path, 0, NULL((void*)0)); |
4166 | if (!chip_dir) |
4167 | { |
4168 | g_free(path); |
4169 | continue; |
4170 | } |
4171 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
4172 | g_debug("lm_sensors dir: %s\n", path); |
4173 | |
4174 | get_volt_default(chip_name, &voltdefault, &voltdefaultsize); |
4175 | while ((sensor_name = (gchar *) g_dir_read_name(chip_dir)) != NULL((void*)0)) |
4176 | { |
4177 | if (!strncmp(sensor_name, "temp", 4)(__extension__ (__builtin_constant_p (4) && ((__builtin_constant_p (sensor_name) && strlen (sensor_name) < ((size_t) (4))) || (__builtin_constant_p ("temp") && strlen ("temp" ) < ((size_t) (4)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (sensor_name) && __builtin_constant_p ("temp") && (__s1_len = strlen (sensor_name), __s2_len = strlen ("temp"), (!((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("temp") + 1) - (size_t )(const void *)("temp") == 1) || __s2_len >= 4)) ? __builtin_strcmp (sensor_name, "temp") : (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name) == 1) && (__s1_len = strlen (sensor_name ), __s1_len < 4) ? (__builtin_constant_p ("temp") && ((size_t)(const void *)(("temp") + 1) - (size_t)(const void * )("temp") == 1) ? __builtin_strcmp (sensor_name, "temp") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("temp"); int __result = (((const unsigned char *) ( const char *) (sensor_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (sensor_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (sensor_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (sensor_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("temp") && ((size_t)( const void *)(("temp") + 1) - (size_t)(const void *)("temp") == 1) && (__s2_len = strlen ("temp"), __s2_len < 4) ? (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name ) == 1) ? __builtin_strcmp (sensor_name, "temp") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sensor_name); int __result = (((const unsigned char *) (const char *) ("temp"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("temp"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("temp"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("temp"))[3] - __s2[3]); } } __result; })) )) : __builtin_strcmp (sensor_name, "temp")))); }) : strncmp ( sensor_name, "temp", 4)))) |
4178 | type = SENSOR_TEMPERATURE0; |
4179 | else if ( !strncmp(sensor_name, "fan", 3)(__extension__ (__builtin_constant_p (3) && ((__builtin_constant_p (sensor_name) && strlen (sensor_name) < ((size_t) (3))) || (__builtin_constant_p ("fan") && strlen ("fan" ) < ((size_t) (3)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (sensor_name) && __builtin_constant_p ("fan") && (__s1_len = strlen (sensor_name), __s2_len = strlen ("fan"), (!((size_t)(const void *)((sensor_name) + 1 ) - (size_t)(const void *)(sensor_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("fan") + 1) - (size_t )(const void *)("fan") == 1) || __s2_len >= 4)) ? __builtin_strcmp (sensor_name, "fan") : (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name) == 1) && (__s1_len = strlen (sensor_name ), __s1_len < 4) ? (__builtin_constant_p ("fan") && ((size_t)(const void *)(("fan") + 1) - (size_t)(const void * )("fan") == 1) ? __builtin_strcmp (sensor_name, "fan") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("fan"); int __result = (((const unsigned char *) (const char *) (sensor_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (sensor_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (sensor_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (sensor_name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("fan") && ((size_t)(const void *)(("fan") + 1) - (size_t )(const void *)("fan") == 1) && (__s2_len = strlen ("fan" ), __s2_len < 4) ? (__builtin_constant_p (sensor_name) && ((size_t)(const void *)((sensor_name) + 1) - (size_t)(const void *)(sensor_name) == 1) ? __builtin_strcmp (sensor_name, "fan" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sensor_name); int __result = (((const unsigned char *) (const char *) ("fan"))[0] - __s2[0]); if ( __s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("fan"))[1] - __s2[1]); if ( __s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("fan"))[2] - __s2[2]); if ( __s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("fan"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (sensor_name, "fan")))); }) : strncmp (sensor_name, "fan", 3))) |
4180 | && ( !sensor_name[3] |
4181 | || (isdigit(sensor_name[3])((*__ctype_b_loc ())[(int) ((sensor_name[3]))] & (unsigned short int) _ISdigit) && !sensor_name[4]) |
4182 | ) |
4183 | ) |
4184 | type = SENSOR_FAN1; |
4185 | else if (check_voltage_name(sensor_name, &id)) |
4186 | type = SENSOR_VOLTAGE2; |
4187 | else |
4188 | continue; |
4189 | |
4190 | factor = 1.0; |
4191 | offset = 0; |
4192 | default_label = vref = NULL((void*)0); |
4193 | |
4194 | if (type == SENSOR_VOLTAGE2) |
4195 | { |
4196 | if (id < voltdefaultsize) |
4197 | { |
4198 | default_label = voltdefault[id].name; |
4199 | factor = voltdefault[id].factor; |
4200 | offset = voltdefault[id].offset; |
4201 | vref = voltdefault[id].vref; |
4202 | } |
4203 | else |
4204 | default_label = sensor_name; |
4205 | } |
4206 | sensor_path = g_strdup_printf("%s/%s", path, sensor_name); |
4207 | snprintf(id_name, sizeof(id_name), "%s/%s", |
4208 | fixed_chip_name, sensor_name); |
4209 | gkrellm_sensors_add_sensor(type, sensor_path, id_name, |
4210 | id, 0, 0, |
4211 | factor, offset, vref, default_label); |
4212 | |
4213 | if (_GK.debug_level & DEBUG_SENSORS0x80) |
4214 | g_debug("%s %s %d %d\n", |
4215 | sensor_path, id_name, id, type); |
4216 | g_free(sensor_path); |
4217 | } |
4218 | g_dir_close(chip_dir); |
4219 | g_free(path); |
4220 | g_free(fixed_chip_name); |
4221 | } |
4222 | g_dir_close(dir); |
4223 | return TRUE(!(0)); |
4224 | } |