Linux 6.5: Use register_sysctl()

The linux 6.5 commit:
    "sysctl: Remove register_sysctl_table" (b8cbc0855a)
removed the Linux function register_sysctl_table().  The replacement
function is register_sysctl(), which offers a simpler interface.

Add an autoconf test for the Linux function register_sysctl and add a
call to register_sysctl when available.

Notes:
The Linux function register_sysctl was added in Linux 3.3 with the
commit:
    'sysctl: Add register_sysctl for normal sysctl users' (fea478d410)
with a note that it is a simpler interface.

The function register_sysctl_table was marked as deprecated with the
Linux 6.3 commit:
    'proc_sysctl: enhance documentation' (1dc8689e4c)

Reviewed-on: https://gerrit.openafs.org/15500
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit fb31d299e6caa015f6288ba9186da6277d3d6a8d)

Change-Id: I60f68f1dd95c32bada7179e98250fd44d7c2ddf3
Reviewed-on: https://gerrit.openafs.org/15522
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
This commit is contained in:
Cheyenne Wills 2023-07-13 10:54:22 -06:00 committed by Stephan Wiesand
parent d15c7ab50c
commit 63801cfd1f
3 changed files with 16 additions and 4 deletions

View File

@ -79,7 +79,7 @@ static struct ctl_table afs_sysctl_table[] = {
.procname = 0
}
};
# if !defined(HAVE_LINUX_REGISTER_SYSCTL)
static struct ctl_table fs_sysctl_table[] = {
{
AFS_SYSCTL_NAME(1)
@ -91,11 +91,13 @@ static struct ctl_table fs_sysctl_table[] = {
.procname = 0
}
};
# endif
int
osi_sysctl_init(void)
{
# if defined(REGISTER_SYSCTL_TABLE_NOFLAG)
# if defined(HAVE_LINUX_REGISTER_SYSCTL)
afs_sysctl = register_sysctl("afs", afs_sysctl_table);
# elif defined(REGISTER_SYSCTL_TABLE_NOFLAG)
afs_sysctl = register_sysctl_table(fs_sysctl_table);
# else
afs_sysctl = register_sysctl_table(fs_sysctl_table, 0);

View File

@ -39,7 +39,9 @@ LINUX_LINUX_KEYRING_SUPPORT
LINUX_KEY_ALLOC_NEEDS_STRUCT_TASK
LINUX_KEY_ALLOC_NEEDS_CRED
LINUX_INIT_WORK_HAS_DATA
LINUX_REGISTER_SYSCTL_TABLE_NOFLAG
dnl Don't bother checking register_sysctl_table if using register_sysctl
AS_IF([test "x$ac_cv_linux_func_register_sysctl" != "xyes"],
[LINUX_REGISTER_SYSCTL_TABLE_NOFLAG])
LINUX_HAVE_DCACHE_LOCK
LINUX_D_COUNT_IS_INT
LINUX_IOP_GETATTR_TAKES_PATH_STRUCT

View File

@ -217,6 +217,14 @@ AC_CHECK_LINUX_FUNC([block_dirty_folio],
#include <linux/buffer_head.h>],
[block_dirty_folio(NULL, NULL);])
dnl Linux 6.5 removed the Linux function register_sysctl_table(), which
dnl was deprecated in Linux 6.3 in favor of register_sysctl() which was
dnl introduced in Linux 3.3
AC_CHECK_LINUX_FUNC([register_sysctl],
[#include <linux/kernel.h>
#include <linux/sysctl.h>],
[(void)register_sysctl(NULL, NULL);])
dnl Consequences - things which get set as a result of the
dnl above tests
AS_IF([test "x$ac_cv_linux_func_d_alloc_anon" = "xno"],