From owner-freebsd-hackers@freebsd.org Sun Jun 28 06:26:07 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E9BF198F5A1 for ; Sun, 28 Jun 2015 06:26:07 +0000 (UTC) (envelope-from pkelsey@gmail.com) Received: from mail-yk0-x230.google.com (mail-yk0-x230.google.com [IPv6:2607:f8b0:4002:c07::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AB9DF114D; Sun, 28 Jun 2015 06:26:07 +0000 (UTC) (envelope-from pkelsey@gmail.com) Received: by ykdt186 with SMTP id t186so91030321ykd.0; Sat, 27 Jun 2015 23:26:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=T1BIPLHrz0Zhmj19fyXMCv02eju6erKkvv6XppMvfwg=; b=gsen7DcZats59P+d+P5vwZsuxuC0nDvAXHHB6xSV/o95//kp45QJmDzZgCQYFqB0YD pVMCOQj4IlMWb0exQhdJ4Ebfm1pYfwsyqzUFZfbgo18tZw9cC+oabIOpaNt4D0bqHriu JPTlHgX/6fvcACYYzjFrr/EmvfTud4CwxWw9rZacYNqc8g8jpUNySHQzCytp+yCflROl jT/LD8DDmNq6k8+Enwq2Cp5H8LJOyRlDEdmdBRYI1bcTYGtYRIdF5EvkYa9KD5Njl8Fk gWSqQqIkZKEjB69UDtBvYMd7bvkl25pbNbS19vyUTX/zpm8VivMZOuBqb+30Z6ZtGqo8 KcBw== MIME-Version: 1.0 X-Received: by 10.129.36.14 with SMTP id k14mr11188334ywk.64.1435472766635; Sat, 27 Jun 2015 23:26:06 -0700 (PDT) Sender: pkelsey@gmail.com Received: by 10.13.219.136 with HTTP; Sat, 27 Jun 2015 23:26:06 -0700 (PDT) In-Reply-To: <558F1D88.8010407@ignoranthack.me> References: <558F1D88.8010407@ignoranthack.me> Date: Sun, 28 Jun 2015 02:26:06 -0400 X-Google-Sender-Auth: On8h7LyISaIceOXVgeh4-A10Y5o Message-ID: Subject: Re: sysctl(3) man page examples From: Patrick Kelsey To: sbruno@freebsd.org Cc: "freebsd-hackers@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Jun 2015 06:26:08 -0000 On Sat, Jun 27, 2015 at 6:02 PM, Sean Bruno wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA512 > > sysctl(3) specifies three easy to understand examples. > > The first appears to depend on a FreeBSD libc() function or library that > is missing, "printkproc()". Is this a deprecated/deleted function from > the past? > This example was committed in r71409, which was between the 4.2 and 4.3 releases. Today, and at that time, the result of fetching a particular kern.proc.pid is a struct kinfo_proc, not struct kinfo_kproc (which did and does not exist). There appears to never have been a printkproc() function (nor print_kproc(), nor printproc(), nor print_proc()) - this seems to be a function that is assumed to exist elsewhere in the unseen parts of the example program. > > The second example works just fine. > > The third accesss user.cs_path which seems to be empty across all > platforms. I'm not sure if we should replace this example with > something more meaningful(that is to say that its proper for > user.cs_path to be empty) or if there is a bug causing user.cs_path to > be empty. > > This appears to be a bug that was introduced almost three years ago in r240176. sysctl() in lib/libc/gen/sysctl.c has special handling for USER_CS_PATH that returns the value of _PATH_STDPATH, which is "/usr/bin:/bin:/usr/sbin:/sbin". However, this special handling for USER_CS_PATH was short circuited by r240176, which introduced the requirement that __sysctl() return ENOENT in order to reach the special USER_CS_PATH handling. However, __sysctl() doesn't return ENOENT for USER_CS_PATH because there is a sysctl entry for it (containing an empty string) that is created in sys/kern/kern_mib.c, apparently so that user.cs_path exists when enumerating the names in the sysctl tree. -Patrick