This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Linux: Deprecate <sys/sysctl.h> and sysctl
* 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."
>> diff --git a/sysdeps/unix/sysv/linux/sysctl.c b/sysdeps/unix/sysv/linux/sysctl.c
>> index 33afdd918b..0f18c69abe 100644
>> --- a/sysdeps/unix/sysv/linux/sysctl.c
>> +++ b/sysdeps/unix/sysv/linux/sysctl.c
>> @@ -17,8 +17,7 @@
>> <http://www.gnu.org/licenses/>. */
>>
>> #include <errno.h>
>> -#include <string.h> /* For the real memset prototype. */
>> -#include <sys/sysctl.h>
>> +#include <linux/sysctl.h>
>>
>> #include <sysdep.h>
>> #include <sys/syscall.h>
>> @@ -39,5 +38,4 @@ __sysctl (int *name, int nlen, void *oldval, size_t *oldlenp,
>>
>> return INLINE_SYSCALL (_sysctl, 1, &args);
>> }
>> -libc_hidden_def (__sysctl)
>> weak_alias (__sysctl, sysctl)
>>
>
> 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.
Thanks,
Florian