From owner-freebsd-hackers@freebsd.org Mon Jun 29 16:56:19 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 A52AB9902F4 for ; Mon, 29 Jun 2015 16:56:19 +0000 (UTC) (envelope-from pkelsey@gmail.com) Received: from mail-yk0-x22c.google.com (mail-yk0-x22c.google.com [IPv6:2607:f8b0:4002:c07::22c]) (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 6F8402F96; Mon, 29 Jun 2015 16:56:19 +0000 (UTC) (envelope-from pkelsey@gmail.com) Received: by ykdy1 with SMTP id y1so120136885ykd.2; Mon, 29 Jun 2015 09:56:18 -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=6xZxgWfsr/WweNzZyTCBToHgkaL1l6AoOFNEJKkxHCA=; b=q3vrggvAdjaZ2Okl6gOA0i+YgY7t1lIqkkLqIK31B8C3NevE+sxKQhu8wO78Vl5qkk lML6Zv3CX32/GQBwuYv0WQbrLZuMMUBvJPgkvy3X9ymGJe4A0UhAuyckE6VVTV92GQ1m 7lihqb4B05/J/NVgk0HJTw9uCLKNhBYWpA1Cq5P6XS0BryVIq29TQeTzNbLW6A3wG5wB QRpLjzhDYjbhCpGTg8rcAPMktkIhClHwc0eKdCy18jPkPiOObyq4x2kMvS16KV3RUTXh NuKTEModuYSjYROOcB/hRWkuxO5gqCWDjUtbLuwpgqyDzwVsxXYqR+AhLyFBJ7wSO9ny ua5Q== MIME-Version: 1.0 X-Received: by 10.129.36.14 with SMTP id k14mr18893572ywk.64.1435596978360; Mon, 29 Jun 2015 09:56:18 -0700 (PDT) Sender: pkelsey@gmail.com Received: by 10.13.219.136 with HTTP; Mon, 29 Jun 2015 09:56:18 -0700 (PDT) In-Reply-To: References: <558F1D88.8010407@ignoranthack.me> Date: Mon, 29 Jun 2015 12:56:18 -0400 X-Google-Sender-Auth: YZmPHcHl9iwOzegp26eEwqDVtPE 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: Mon, 29 Jun 2015 16:56:19 -0000 On Sun, Jun 28, 2015 at 2:26 AM, Patrick Kelsey wrote: > > > > 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. > A patch for this is posted for review at https://reviews.freebsd.org/D2945. -Patrick