MCPcopy Create free account
hub / github.com/F-Stack/f-stack / db_show_oid

Function db_show_oid

freebsd/kern/kern_sysctl.c:2759–2806  ·  view source on GitHub ↗

* Show a sysctl at a specific OID * Compare to the input handling in show_var from sbin/sysctl/sysctl.c */

Source from the content-addressed store, hash-verified

2757 * Compare to the input handling in show_var from sbin/sysctl/sysctl.c
2758 */
2759static int
2760db_show_oid(struct sysctl_oid *oidp, int *oid, size_t nlen, int flags)
2761{
2762 int error, xflag, oflag, Nflag, nflag;
2763 size_t len;
2764
2765 xflag = flags & DB_SYSCTL_HEX;
2766 oflag = flags & DB_SYSCTL_OPAQUE;
2767 nflag = flags & DB_SYSCTL_VALUE_ONLY;
2768 Nflag = flags & DB_SYSCTL_NAME_ONLY;
2769
2770 if ((oidp->oid_kind & CTLTYPE) == CTLTYPE_OPAQUE &&
2771 (!xflag && !oflag))
2772 return (0);
2773
2774 if (Nflag) {
2775 db_show_oid_name(oid, nlen);
2776 error = 0;
2777 goto out;
2778 }
2779
2780 if (!nflag) {
2781 db_show_oid_name(oid, nlen);
2782 db_printf(": ");
2783 }
2784
2785 if ((flags & DB_SYSCTL_SAFE_ONLY) && !db_oid_safe(oidp)) {
2786 db_printf("Skipping, unsafe to print while recursing.");
2787 error = 0;
2788 goto out;
2789 }
2790
2791 /* Try once, and ask about the size */
2792 len = 0;
2793 error = db_sysctl(oidp, oid, nlen,
2794 NULL, NULL, &len, flags);
2795 if (error)
2796 goto out;
2797
2798 if (!g_ddb_sysctl_printed)
2799 /* Lie about the size */
2800 error = db_sysctl(oidp, oid, nlen,
2801 (void *) 1, &len, NULL, flags);
2802
2803out:
2804 db_printf("\n");
2805 return (error);
2806}
2807
2808/*
2809 * Show all sysctls under a specific OID

Callers 2

db_show_sysctl_allFunction · 0.85
db_sysctlbynameFunction · 0.85

Calls 4

db_show_oid_nameFunction · 0.85
db_printfFunction · 0.85
db_oid_safeFunction · 0.85
db_sysctlFunction · 0.85

Tested by

no test coverage detected