[PATCH] Linux: Deprecate <sys/sysctl.h> and sysctl

Florian Weimer fweimer@redhat.com
Wed Jun 12 12:32:00 GMT 2019


* Adhemerval Zanella:

> On 07/06/2019 13:01, Florian Weimer wrote:
>> * Adhemerval Zanella:
>> 
>>> On 07/06/2019 09:01, Florian Weimer wrote:
>>>> Now that there are no internal users of __sysctl left, it is possible
>>>> to add an unconditional deprecation warning to <sys/sysctl.h>.
>>>>
>>>> To avoid a test failure due this warning in check-install-headers,
>>>> skip the test for sys/sysctl.h.
>>>
>>> LGTM.  As a side note, if I recall correctly one usage of sysctl that might
>>> be useful and not really available depending of the kernel version is to
>>> get some random bits from /proc/sys/kernel/random/uuid without opening
>>> /proc.
>> 
>> Right, I saw this quite a lot in existing code (although some people use
>> the FreeBSD MIB on Linux, which will always fail and never provide a UUID).
>> 
>>>> +#warning "The <sys/sysctl.h> header is deprecated and will be removed."
>>>> +#warning "Directly access the /proc file system instead."
>> 
>> Should I add this as well?
>> 
>> #warning "On current kernels, getentropy provides random bits without /proc."
>
> Not sure, I think a note on NEWS might be better fort this specific
> usage.

Okay, I will remove the second #warning and add this to NEWS:

* The Linux-specific <sys/sysctl.h> header and the sysctl function have been
  deprecated and will be removed from a future version of glibc.
  Application should directly access /proc instead.  For obtaining random
  bits, the getentropy function can be used.

>>> What about a link warning stating this interface is deprecated and it would be
>>> removed? My idea is to warn when people are static linking as well.
>> 
>> They already get two warnings (from the header and the call site).  Do
>> we need a third warning?  It's only helpful if you don't use the header,
>> I think, but even with Go's cgo, you'll see the GCC warnings.
>
> Fair enough.
>
> Patch LGTM, thanks.
>
> Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

Thanks!

Florian



More information about the Libc-alpha mailing list