svn commit: r288984 - head/sbin/sysctl

Bryan Drewery bdrewery at FreeBSD.org
Wed Oct 7 22:45:15 UTC 2015


On 10/7/2015 3:41 PM, NGie Cooper wrote:
> On Wed, Oct 7, 2015 at 3:35 PM, Baptiste Daroussin <bapt at freebsd.org> wrote:
> ...
>> I do not think it is, but I couldn't find a way to reproduce another case than
>> ENOENT, so I thought maybe the best would be to keep the current behaviour for
>> other cases :)
> 

Here's the relevant code:

sys/kern/kern_sysctl.c:SYSCTL_PROC(_sysctl, 3, name2oid
...

static SYSCTL_NODE(_sysctl, 2, next, CTLFLAG_RD | CTLFLAG_MPSAFE |
CTLFLAG_CAPRD,
    sysctl_sysctl_next, "");

static int
name2oid(char *name, int *oid, int *len, struct sysctl_oid **oidpp)
{
        struct sysctl_oid *oidp;
        struct sysctl_oid_list *lsp = &sysctl__children;
        char *p;

        SYSCTL_ASSERT_LOCKED();

        for (*len = 0; *len < CTL_MAXNAME;) {
                p = strsep(&name, ".");

                oidp = SLIST_FIRST(lsp);
                for (;; oidp = SLIST_NEXT(oidp, oid_link)) {
                        if (oidp == NULL)
                                return (ENOENT);
                        if (strcmp(p, oidp->oid_name) == 0)
                                break;
                }
                *oid++ = oidp->oid_number;
                (*len)++;

                if (name == NULL || *name == '\0') {
                        if (oidpp)
                                *oidpp = oidp;
                        return (0);
                }

                if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE)
                        break;

                if (oidp->oid_handler)
                        break;

                lsp = SYSCTL_CHILDREN(oidp);
        }
        return (ENOENT);
}



It can only return 0 or ENOENT.

-- 
Regards,
Bryan Drewery

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20151007/2390a7f5/attachment.bin>


More information about the svn-src-head mailing list