| 663 | } |
| 664 | |
| 665 | static int |
| 666 | fetch_stats_internal(const char *sysctlname, u_long off, void *stats, |
| 667 | size_t len, kreadfn_t kreadfn, int zero) |
| 668 | { |
| 669 | int error; |
| 670 | |
| 671 | if (live) { |
| 672 | memset(stats, 0, len); |
| 673 | if (zero) |
| 674 | error = sysctlbyname(sysctlname, NULL, NULL, stats, |
| 675 | len); |
| 676 | else |
| 677 | error = sysctlbyname(sysctlname, stats, &len, NULL, 0); |
| 678 | if (error == -1 && errno != ENOENT) |
| 679 | xo_warn("sysctl %s", sysctlname); |
| 680 | } else { |
| 681 | if (off == 0) |
| 682 | return (1); |
| 683 | error = kreadfn(off, stats, len); |
| 684 | } |
| 685 | return (error); |
| 686 | } |
| 687 | |
| 688 | int |
| 689 | fetch_stats(const char *sysctlname, u_long off, void *stats, |
no test coverage detected