1 /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
2 * vim: ts=4 sw=4 noet ai cindent syntax=c
4 * Conky, a system monitor, based on torsmo
6 * Any original torsmo code is licensed under the BSD license
8 * All code written since the fork of torsmo is licensed under the GPL
10 * Please see COPYING for details
12 * Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
14 * All rights reserved.
16 * This program is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 #include <sys/ioctl.h>
31 #include <sys/dkstat.h>
32 #include <sys/param.h>
33 #include <sys/resource.h>
34 #include <sys/socket.h>
36 #include <sys/sysctl.h>
38 #include <sys/types.h>
42 #include <net/if_mib.h>
43 #include <net/if_media.h>
44 #include <net/if_var.h>
51 #include <dev/wi/if_wavelan_ieee.h>
52 #include <dev/acpica/acpiio.h>
61 #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
62 #define KELVTOC(x) ((x - 2732) / 10.0)
63 #define MAXSHOWDEVS 16
69 __attribute__((gnu_inline)) inline void
70 proc_find_top(struct process **cpu, struct process **mem, struct process **time);
72 static short cpu_setup = 0;
74 static int getsysctl(const char *name, void *ptr, size_t len)
78 if (sysctlbyname(name, ptr, &nlen, NULL, 0) == -1) {
82 if (nlen != len && errno == ENOMEM) {
89 struct ifmibdata *data = NULL;
92 static int swapmode(unsigned long *retavail, unsigned long *retfree)
95 unsigned long pagesize = getpagesize();
96 struct kvm_swap swapary[1];
101 #define CONVERT(v) ((quad_t)(v) * (pagesize / 1024))
103 n = kvm_getswapinfo(kd, swapary, 1, 0);
104 if (n < 0 || swapary[0].ksw_total == 0) {
108 *retavail = CONVERT(swapary[0].ksw_total);
109 *retfree = CONVERT(swapary[0].ksw_total - swapary[0].ksw_used);
111 n = (int) ((double) swapary[0].ksw_used * 100.0 /
112 (double) swapary[0].ksw_total);
117 void prepare_update(void)
121 int update_uptime(void)
123 int mib[2] = { CTL_KERN, KERN_BOOTTIME };
124 struct timeval boottime;
126 size_t size = sizeof(boottime);
128 if ((sysctl(mib, 2, &boottime, &size, NULL, 0) != -1)
129 && (boottime.tv_sec != 0)) {
131 info.uptime = now - boottime.tv_sec;
133 fprintf(stderr, "Could not get uptime\n");
140 int check_mount(char *s)
142 struct statfs *mntbuf;
145 mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
146 for (i = mntsize - 1; i >= 0; i--) {
147 if (strcmp(mntbuf[i].f_mntonname, s) == 0) {
155 int update_meminfo(void)
157 u_int total_pages, inactive_pages, free_pages;
158 unsigned long swap_avail, swap_free;
160 int pagesize = getpagesize();
162 if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages)) {
163 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_page_count\"\n");
166 if (GETSYSCTL("vm.stats.vm.v_free_count", free_pages)) {
167 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_free_count\"\n");
170 if (GETSYSCTL("vm.stats.vm.v_inactive_count", inactive_pages)) {
171 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_inactive_count\"\n");
174 info.memmax = total_pages * (pagesize >> 10);
175 info.mem = (total_pages - free_pages - inactive_pages) * (pagesize >> 10);
176 info.memeasyfree = info.memfree = info.memmax - info.mem;
178 if ((swapmode(&swap_avail, &swap_free)) >= 0) {
179 info.swapmax = swap_avail;
180 info.swap = (swap_avail - swap_free);
181 info.swapfree = swap_free;
191 int update_net_stats(void)
195 long long r, t, last_recv, last_trans;
196 struct ifaddrs *ifap, *ifa;
200 delta = current_update_time - last_update_time;
201 if (delta <= 0.0001) {
205 if (getifaddrs(&ifap) < 0) {
209 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
210 ns = get_net_stat((const char *) ifa->ifa_name, NULL, NULL);
212 if (ifa->ifa_flags & IFF_UP) {
213 struct ifaddrs *iftmp;
216 last_recv = ns->recv;
217 last_trans = ns->trans;
219 if (ifa->ifa_addr->sa_family != AF_LINK) {
223 for (iftmp = ifa->ifa_next;
224 iftmp != NULL && strcmp(ifa->ifa_name, iftmp->ifa_name) == 0;
225 iftmp = iftmp->ifa_next) {
226 if (iftmp->ifa_addr->sa_family == AF_INET) {
227 memcpy(&(ns->addr), iftmp->ifa_addr,
228 iftmp->ifa_addr->sa_len);
232 ifd = (struct if_data *) ifa->ifa_data;
236 if (r < ns->last_read_recv) {
237 ns->recv += ((long long) 4294967295U - ns->last_read_recv) + r;
239 ns->recv += (r - ns->last_read_recv);
242 ns->last_read_recv = r;
244 if (t < ns->last_read_trans) {
245 ns->trans += ((long long) 4294967295U -
246 ns->last_read_trans) + t;
248 ns->trans += (t - ns->last_read_trans);
251 ns->last_read_trans = t;
253 /* calculate speeds */
254 ns->recv_speed = (ns->recv - last_recv) / delta;
255 ns->trans_speed = (ns->trans - last_trans) / delta;
265 int update_total_processes(void)
269 pthread_mutex_lock(&kvm_proc_mutex);
270 kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
271 pthread_mutex_unlock(&kvm_proc_mutex);
273 info.procs = n_processes;
277 int update_running_processes(void)
279 struct kinfo_proc *p;
283 pthread_mutex_lock(&kvm_proc_mutex);
284 p = kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
285 for (i = 0; i < n_processes; i++) {
286 #if (__FreeBSD__ < 5) && (__FreeBSD_kernel__ < 5)
287 if (p[i].kp_proc.p_stat == SRUN) {
289 if (p[i].ki_stat == SRUN) {
294 pthread_mutex_unlock(&kvm_proc_mutex);
296 info.run_procs = cnt;
300 void get_cpu_count(void)
303 size_t cpu_count_len = sizeof(cpu_count);
305 if (GETSYSCTL("hw.ncpu", cpu_count) == 0) {
306 info.cpu_count = cpu_count;
308 fprintf(stderr, "Cannot get hw.ncpu\n");
312 info.cpu_usage = malloc((info.cpu_count + 1) * sizeof(float));
313 if (info.cpu_usage == NULL) {
314 CRIT_ERR(NULL, NULL, "malloc");
323 int update_cpu_usage(void)
327 long *cp_time = NULL;
329 static struct cpu_info *cpu = NULL;
330 unsigned int malloc_cpu_size = 0;
331 extern void* global_cpu;
333 /* add check for !info.cpu_usage since that mem is freed on a SIGUSR1 */
334 if ((cpu_setup == 0) || (!info.cpu_usage)) {
340 malloc_cpu_size = (info.cpu_count + 1) * sizeof(struct cpu_info);
341 cpu = malloc(malloc_cpu_size);
342 memset(cpu, 0, malloc_cpu_size);
346 /* cpu[0] is overall stats, get it from separate sysctl */
347 cp_len = CPUSTATES * sizeof(long);
348 cp_time = malloc(cp_len);
350 if (sysctlbyname("kern.cp_time", cp_time, &cp_len, NULL, 0) < 0) {
351 fprintf(stderr, "Cannot get kern.cp_time\n");
355 for (j = 0; j < CPUSTATES; j++)
358 used = total - cp_time[CP_IDLE];
360 if ((total - cpu[0].oldtotal) != 0) {
361 info.cpu_usage[0] = ((double) (used - cpu[0].oldused)) /
362 (double) (total - cpu[0].oldtotal);
364 info.cpu_usage[0] = 0;
367 cpu[0].oldused = used;
368 cpu[0].oldtotal = total;
373 cp_len = CPUSTATES * sizeof(long) * info.cpu_count;
374 cp_time = malloc(cp_len);
376 /* on e.g. i386 SMP we may have more values than actual cpus; this will just drop extra values */
377 if (sysctlbyname("kern.cp_times", cp_time, &cp_len, NULL, 0) < 0 && errno != ENOMEM) {
378 fprintf(stderr, "Cannot get kern.cp_times\n");
381 for (i = 0; i < info.cpu_count; i++)
384 for (j = 0; j < CPUSTATES; j++)
385 total += cp_time[i*CPUSTATES + j];
387 used = total - cp_time[i*CPUSTATES + CP_IDLE];
389 if ((total - cpu[i+1].oldtotal) != 0) {
390 info.cpu_usage[i+1] = ((double) (used - cpu[i+1].oldused)) /
391 (double) (total - cpu[i+1].oldtotal);
393 info.cpu_usage[i+1] = 0;
396 cpu[i+1].oldused = used;
397 cpu[i+1].oldtotal = total;
404 int update_load_average(void)
410 info.loadavg[0] = (double) v[0];
411 info.loadavg[1] = (double) v[1];
412 info.loadavg[2] = (double) v[2];
417 double get_acpi_temperature(int fd)
422 if (GETSYSCTL("hw.acpi.thermal.tz0.temperature", temp)) {
424 "Cannot read sysctl \"hw.acpi.thermal.tz0.temperature\"\n");
428 return KELVTOC(temp);
431 static void get_battery_stats(int *battime, int *batcapacity, int *batstate, int *ac) {
432 if (battime && GETSYSCTL("hw.acpi.battery.time", *battime)) {
433 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.time\"\n");
435 if (batcapacity && GETSYSCTL("hw.acpi.battery.life", *batcapacity)) {
436 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.life\"\n");
438 if (batstate && GETSYSCTL("hw.acpi.battery.state", *batstate)) {
439 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.state\"\n");
441 if (ac && GETSYSCTL("hw.acpi.acline", *ac)) {
442 fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n");
446 void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
448 int battime, batcapacity, batstate, ac;
451 get_battery_stats(&battime, &batcapacity, &batstate, &ac);
453 if (batstate != 1 && batstate != 2 && batstate != 0 && batstate != 7)
454 fprintf(stderr, "Unknown battery state %d!\n", batstate);
455 else if (batstate != 1 && ac == 0)
456 fprintf(stderr, "Battery charging while not on AC!\n");
457 else if (batstate == 1 && ac == 1)
458 fprintf(stderr, "Battery discharing while on AC!\n");
462 if (batstate == 1 && battime != -1)
463 snprintf(buf, n, "%d:%2.2d", battime / 60, battime % 60);
466 if (batstate == 1) // Discharging
467 snprintf(buf, n, "remaining %d%%", batcapacity);
469 snprintf(buf, n, batstate == 2 ? "charging (%d%%)" :
470 (batstate == 7 ? "absent/on AC" : "charged (%d%%)"),
474 fprintf(stderr, "Unknown requested battery stat %d\n", item);
478 static int check_bat(const char *bat)
480 int batnum, numbatts;
482 if (GETSYSCTL("hw.acpi.battery.units", numbatts)) {
483 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.units\"\n");
487 fprintf(stderr, "No battery unit detected\n");
490 if (!bat || (batnum = strtol(bat, &endptr, 10)) < 0 ||
491 bat == endptr || batnum > numbatts) {
492 fprintf(stderr, "Wrong battery unit %s requested\n", bat ? bat : "");
498 int get_battery_perct(const char *bat)
500 union acpi_battery_ioctl_arg battio;
502 int designcap, lastfulcap, batperct;
504 if ((battio.unit = batnum = check_bat(bat)) < 0)
506 if ((acpifd = open("/dev/acpi", O_RDONLY)) < 0) {
507 fprintf(stderr, "Can't open ACPI device\n");
510 if (ioctl(acpifd, ACPIIO_BATT_GET_BIF, &battio) == -1) {
511 fprintf(stderr, "Unable to get info for battery unit %d\n", batnum);
515 designcap = battio.bif.dcap;
516 lastfulcap = battio.bif.lfcap;
517 batperct = (designcap > 0 && lastfulcap > 0) ?
518 (int) (((float) lastfulcap / designcap) * 100) : 0;
519 return batperct > 100 ? 100 : batperct;
522 int get_battery_perct_bar(const char *bar)
524 int batperct = get_battery_perct(bar);
525 return (int)(batperct * 2.56 - 1);
528 int open_acpi_temperature(const char *name)
531 /* Not applicable for FreeBSD. */
535 void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size, const char *adapter)
539 (void) adapter; // only linux uses this
541 if (!p_client_buffer || client_buffer_size <= 0) {
545 if (GETSYSCTL("hw.acpi.acline", state)) {
546 fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n");
551 strncpy(p_client_buffer, "Running on AC Power", client_buffer_size);
553 strncpy(p_client_buffer, "Running on battery", client_buffer_size);
557 void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
559 /* not implemented */
560 if (p_client_buffer && client_buffer_size > 0) {
561 memset(p_client_buffer, 0, client_buffer_size);
566 char get_freq(char *p_client_buffer, size_t client_buffer_size, const char *p_format,
567 int divisor, unsigned int cpu)
572 freq_sysctl = (char *) calloc(16, sizeof(char));
573 if (freq_sysctl == NULL) {
577 snprintf(freq_sysctl, 16, "dev.cpu.%d.freq", (cpu - 1));
579 if (!p_client_buffer || client_buffer_size <= 0 || !p_format
584 if (GETSYSCTL(freq_sysctl, freq) == 0) {
585 snprintf(p_client_buffer, client_buffer_size, p_format,
586 (float) freq / divisor);
588 snprintf(p_client_buffer, client_buffer_size, p_format, 0.0f);
597 proc_find_top(info.cpu, info.memu, info.time);
602 void update_wifi_stats(void)
604 struct ifreq ifr; /* interface stats */
607 struct ifaddrs *ifap, *ifa;
608 struct ifmediareq ifmr;
611 /* Get iface table */
612 if (getifaddrs(&ifap) < 0) {
616 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
617 ns = get_net_stat((const char *) ifa->ifa_name, NULL, NULL);
619 s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
622 bzero(&ifmr, sizeof(ifmr));
623 strlcpy(ifmr.ifm_name, ifa->ifa_name, IFNAMSIZ);
624 if (ioctl(s, SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) {
629 /* We can monitor only wireless interfaces
630 * which are not in hostap mode */
631 if ((ifmr.ifm_active & IFM_IEEE80211)
632 && !(ifmr.ifm_active & IFM_IEEE80211_HOSTAP)) {
634 bzero(&ifr, sizeof(ifr));
635 strlcpy(ifr.ifr_name, ifa->ifa_name, IFNAMSIZ);
636 wireq.wi_type = WI_RID_COMMS_QUALITY;
637 wireq.wi_len = WI_MAX_DATALEN;
638 ifr.ifr_data = (void *) &wireq;
640 if (ioctl(s, SIOCGWAVELAN, (caddr_t) &ifr) < 0) {
641 perror("ioctl (getting wi status)");
645 /* wi_val[0] = quality
647 * wi_val[2] = noise */
648 ns->linkstatus = (int) wireq.wi_val[1];
656 int update_diskio(void)
658 int devs_count, num_selected, num_selections, dn;
659 struct device_selection *dev_select = NULL;
660 long select_generation;
661 static struct statinfo statinfo_cur;
662 char device_name[text_buffer_size];
663 struct diskio_stat *cur;
664 unsigned int reads, writes;
665 unsigned int total_reads = 0, total_writes = 0;
668 memset(&statinfo_cur, 0, sizeof(statinfo_cur));
669 statinfo_cur.dinfo = (struct devinfo *)calloc(1, sizeof(struct devinfo));
670 stats.current = stats.current_read = stats.current_write = 0;
672 if (devstat_getdevs(NULL, &statinfo_cur) < 0) {
673 free(statinfo_cur.dinfo);
677 devs_count = statinfo_cur.dinfo->numdevs;
678 if (devstat_selectdevs(&dev_select, &num_selected, &num_selections,
679 &select_generation, statinfo_cur.dinfo->generation,
680 statinfo_cur.dinfo->devices, devs_count, NULL, 0, NULL, 0,
681 DS_SELECT_ONLY, MAXSHOWDEVS, 1) >= 0) {
682 for (dn = 0; dn < devs_count; dn++) {
686 di = dev_select[dn].position;
687 dev = &statinfo_cur.dinfo->devices[di];
688 snprintf(device_name, text_buffer_size, "%s%d",
689 dev_select[dn].device_name, dev_select[dn].unit_number);
691 total_reads += (reads = dev->bytes[DEVSTAT_READ] / 512);
692 total_writes += (writes = dev->bytes[DEVSTAT_WRITE] / 512);
693 for (cur = stats.next; cur; cur = cur->next) {
694 if (cur->dev && !strcmp(device_name, cur->dev)) {
695 update_diskio_values(cur, reads, writes);
700 update_diskio_values(&stats, total_reads, total_writes);
705 free(statinfo_cur.dinfo);
709 /* While topless is obviously better, top is also not bad. */
711 int comparecpu(const void *a, const void *b)
713 if (((const struct process *)a)->amount > ((const struct process *)b)->amount) {
715 } else if (((const struct process *)a)->amount < ((const struct process *)b)->amount) {
722 int comparemem(const void *a, const void *b)
724 if (((const struct process *)a)->rss > ((const struct process *)b)->rss) {
726 } else if (((const struct process *)a)->rss < ((const struct process *)b)->rss) {
733 int comparetime(const void *va, const void *vb)
735 struct process *a = (struct process *)va, *b = (struct process *)vb;
737 return b->total_cpu_time - a->total_cpu_time;
740 __attribute__((gnu_inline)) inline void
741 proc_find_top(struct process **cpu, struct process **mem, struct process **time)
743 struct kinfo_proc *p;
746 struct process *processes;
750 /* we get total pages count again to be sure it is up to date */
751 if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages) != 0) {
752 CRIT_ERR(NULL, NULL, "Cannot read sysctl \"vm.stats.vm.v_page_count\"");
755 pthread_mutex_lock(&kvm_proc_mutex);
756 p = kvm_getprocs(kd, KERN_PROC_PROC, 0, &n_processes);
757 processes = malloc(n_processes * sizeof(struct process));
759 for (i = 0; i < n_processes; i++) {
760 if (!((p[i].ki_flag & P_SYSTEM)) && p[i].ki_comm != NULL) {
761 processes[j].pid = p[i].ki_pid;
762 processes[j].name = strndup(p[i].ki_comm, text_buffer_size);
763 processes[j].amount = 100.0 * p[i].ki_pctcpu / FSCALE;
764 processes[j].vsize = p[i].ki_size;
765 processes[j].rss = (p[i].ki_rssize * getpagesize());
766 /* ki_runtime is in microseconds, total_cpu_time in centiseconds.
767 * Therefore we divide by 10000. */
768 processes[j].total_cpu_time = p[i].ki_runtime / 10000;
772 pthread_mutex_unlock(&kvm_proc_mutex);
774 qsort(processes, j - 1, sizeof(struct process), comparemem);
775 for (i = 0; i < 10 && i < n_processes; i++) {
776 struct process *tmp, *ttmp;
778 tmp = malloc(sizeof(struct process));
779 memcpy(tmp, &processes[i], sizeof(struct process));
780 tmp->name = strndup(processes[i].name, text_buffer_size);
790 qsort(processes, j - 1, sizeof(struct process), comparecpu);
791 for (i = 0; i < 10 && i < n_processes; i++) {
792 struct process *tmp, *ttmp;
794 tmp = malloc(sizeof(struct process));
795 memcpy(tmp, &processes[i], sizeof(struct process));
796 tmp->name = strndup(processes[i].name, text_buffer_size);
806 qsort(processes, j - 1, sizeof(struct process), comparetime);
807 for (i = 0; i < 10 && i < n_processes; i++) {
808 struct process *tmp, *ttmp;
810 tmp = malloc(sizeof(struct process));
811 memcpy(tmp, &processes[i], sizeof(struct process));
812 tmp->name = strndup(processes[i].name, text_buffer_size);
822 #if defined(FREEBSD_DEBUG)
823 printf("=====\nmem\n");
824 for (i = 0; i < 10; i++) {
825 printf("%d: %s(%d) %ld %ld\n", i, mem[i]->name,
826 mem[i]->pid, mem[i]->vsize, mem[i]->rss);
830 for (i = 0; i < j; i++) {
831 free(processes[i].name);
836 #if defined(i386) || defined(__i386__)
837 #define APMDEV "/dev/apm"
838 #define APM_UNKNOWN 255
840 int apm_getinfo(int fd, apm_info_t aip)
842 if (ioctl(fd, APMIO_GETINFO, aip) == -1) {
849 char *get_apm_adapter(void)
852 struct apm_info a_info;
855 out = (char *) calloc(16, sizeof(char));
857 fd = open(APMDEV, O_RDONLY);
859 strncpy(out, "ERR", 16);
863 if (apm_getinfo(fd, &a_info) != 0) {
865 strncpy(out, "ERR", 16);
870 switch (a_info.ai_acline) {
872 strncpy(out, "off-line", 16);
876 if (a_info.ai_batt_stat == 3) {
877 strncpy(out, "charging", 16);
880 strncpy(out, "on-line", 16);
885 strncpy(out, "unknown", 16);
891 char *get_apm_battery_life(void)
895 struct apm_info a_info;
898 out = (char *) calloc(16, sizeof(char));
900 fd = open(APMDEV, O_RDONLY);
902 strncpy(out, "ERR", 16);
906 if (apm_getinfo(fd, &a_info) != 0) {
908 strncpy(out, "ERR", 16);
913 batt_life = a_info.ai_batt_life;
914 if (batt_life == APM_UNKNOWN) {
915 strncpy(out, "unknown", 16);
916 } else if (batt_life <= 100) {
917 snprintf(out, 16, "%d%%", batt_life);
920 strncpy(out, "ERR", 16);
926 char *get_apm_battery_time(void)
931 struct apm_info a_info;
934 out = (char *) calloc(16, sizeof(char));
936 fd = open(APMDEV, O_RDONLY);
938 strncpy(out, "ERR", 16);
942 if (apm_getinfo(fd, &a_info) != 0) {
944 strncpy(out, "ERR", 16);
949 batt_time = a_info.ai_batt_time;
951 if (batt_time == -1) {
952 strncpy(out, "unknown", 16);
959 snprintf(out, 16, "%2d:%02d:%02d", h, m, s);
967 void get_battery_short_status(char *buffer, unsigned int n, const char *bat)
969 get_battery_stuff(buffer, n, bat, BATTERY_STATUS);
970 if (0 == strncmp("charging", buffer, 8)) {
972 memmove(buffer + 1, buffer + 8, n - 8);
973 } else if (0 == strncmp("discharging", buffer, 11)) {
975 memmove(buffer + 1, buffer + 11, n - 11);
976 } else if (0 == strncmp("absent/on AC", buffer, 12)) {
978 memmove(buffer + 1, buffer + 12, n - 12);
982 int get_entropy_avail(unsigned int *val)
984 /* Not applicable for FreeBSD as it uses the yarrow prng. */
989 int get_entropy_poolsize(unsigned int *val)
991 /* Not applicable for FreeBSD as it uses the yarrow prng. */