* Show all sysctls under a specific OID * Compare to sysctl_all from sbin/sysctl/sysctl.c */
| 2810 | * Compare to sysctl_all from sbin/sysctl/sysctl.c |
| 2811 | */ |
| 2812 | static int |
| 2813 | db_show_sysctl_all(int *oid, size_t len, int flags) |
| 2814 | { |
| 2815 | struct sysctl_oid *oidp; |
| 2816 | int name1[CTL_MAXNAME + 2], name2[CTL_MAXNAME + 2]; |
| 2817 | size_t l1, l2; |
| 2818 | |
| 2819 | name1[0] = CTL_SYSCTL; |
| 2820 | name1[1] = CTL_SYSCTL_NEXT; |
| 2821 | l1 = 2; |
| 2822 | if (len) { |
| 2823 | memcpy(name1 + 2, oid, len * sizeof(int)); |
| 2824 | l1 += len; |
| 2825 | } else { |
| 2826 | name1[2] = CTL_KERN; |
| 2827 | l1++; |
| 2828 | } |
| 2829 | for (;;) { |
| 2830 | int i, error; |
| 2831 | |
| 2832 | l2 = sizeof(name2); |
| 2833 | error = kernel_sysctl(kdb_thread, name1, l1, |
| 2834 | name2, &l2, NULL, 0, &l2, 0); |
| 2835 | if (error != 0) { |
| 2836 | if (error == ENOENT) |
| 2837 | return (0); |
| 2838 | else |
| 2839 | db_error("sysctl(next)"); |
| 2840 | } |
| 2841 | |
| 2842 | l2 /= sizeof(int); |
| 2843 | |
| 2844 | if (l2 < (unsigned int)len) |
| 2845 | return (0); |
| 2846 | |
| 2847 | for (i = 0; i < len; i++) |
| 2848 | if (name2[i] != oid[i]) |
| 2849 | return (0); |
| 2850 | |
| 2851 | /* Find the OID in question */ |
| 2852 | error = sysctl_find_oid(name2, l2, &oidp, NULL, NULL); |
| 2853 | if (error) |
| 2854 | return (error); |
| 2855 | |
| 2856 | i = db_show_oid(oidp, name2, l2, flags | DB_SYSCTL_SAFE_ONLY); |
| 2857 | |
| 2858 | if (db_pager_quit) |
| 2859 | return (0); |
| 2860 | |
| 2861 | memcpy(name1+2, name2, l2 * sizeof(int)); |
| 2862 | l1 = 2 + l2; |
| 2863 | } |
| 2864 | } |
| 2865 | |
| 2866 | /* |
| 2867 | * Show a sysctl by its user facing string |
no test coverage detected