[PATCH 11/11] proc_sysctl: deprecate register_sysctl_paths()

From: Luis Chamberlain
Date: Thu Mar 02 2023 - 15:29:23 EST


Now that all users are removed, drop the export for register_sysctl_paths()

Signed-off-by: Luis Chamberlain <mcgrof@xxxxxxxxxx>
---
fs/proc/proc_sysctl.c | 30 +++++++++---------------------
include/linux/sysctl.h | 11 -----------
2 files changed, 9 insertions(+), 32 deletions(-)

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 15d5e02f1ec0..ff06434f7be1 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -1486,6 +1486,7 @@ static int count_subheaders(struct ctl_table *table)
return nr_subheaders + has_files;
}

+/* Note: this can recurse and call itself when dealing with subdirectories */
static int register_leaf_sysctl_tables(const char *path, char *pos,
struct ctl_table_header ***subheader, struct ctl_table_set *set,
struct ctl_table *table)
@@ -1571,9 +1572,10 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
* Register a sysctl table hierarchy. @table should be a filled in ctl_table
* array. A completely 0 filled entry terminates the table.
*
- * See __register_sysctl_table for more details.
+ * See __register_sysctl_table for more details. This routine can
+ * recurse by having register_leaf_sysctl_tables() call itself.
*/
-struct ctl_table_header *__register_sysctl_paths(
+static struct ctl_table_header *__register_sysctl_paths(
struct ctl_table_set *set,
const struct ctl_path *path, struct ctl_table *table)
{
@@ -1613,6 +1615,7 @@ struct ctl_table_header *__register_sysctl_paths(
subheader = subheaders;
header->ctl_table_arg = ctl_table_arg;

+ /* this can recurse */
if (register_leaf_sysctl_tables(new_path, pos, &subheader,
set, table))
goto err_register_leaves;
@@ -1635,37 +1638,22 @@ struct ctl_table_header *__register_sysctl_paths(
}

/**
- * register_sysctl_paths - register a sysctl table hierarchy
- * @path: The path to the directory the sysctl table is in.
+ * register_sysctl_table - register a sysctl table hierarchy
* @table: the top-level table structure
*
* Register a sysctl table hierarchy. @table should be a filled in ctl_table
* array. A completely 0 filled entry terminates the table.
*
* See __register_sysctl_paths for more details.
- */
-struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
- struct ctl_table *table)
-{
- return __register_sysctl_paths(&sysctl_table_root.default_set,
- path, table);
-}
-EXPORT_SYMBOL(register_sysctl_paths);
-
-/**
- * register_sysctl_table - register a sysctl table hierarchy
- * @table: the top-level table structure
- *
- * Register a sysctl table hierarchy. @table should be a filled in ctl_table
- * array. A completely 0 filled entry terminates the table.
*
- * See register_sysctl_paths for more details.
+ * This is a deprecated compatibility wrapper. You should avoid adding new
+ * users of this into the kernel.
*/
struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
{
static const struct ctl_path null_path[] = { {} };

- return register_sysctl_paths(null_path, table);
+ return __register_sysctl_paths(&sysctl_table_root.default_set, null_path, table);
}
EXPORT_SYMBOL(register_sysctl_table);

diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 780690dc08cd..e8459fc56b50 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -221,13 +221,8 @@ extern void retire_sysctl_set(struct ctl_table_set *set);
struct ctl_table_header *__register_sysctl_table(
struct ctl_table_set *set,
const char *path, struct ctl_table *table);
-struct ctl_table_header *__register_sysctl_paths(
- struct ctl_table_set *set,
- const struct ctl_path *path, struct ctl_table *table);
struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table);
struct ctl_table_header *register_sysctl_table(struct ctl_table * table);
-struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
- struct ctl_table *table);

void unregister_sysctl_table(struct ctl_table_header * table);

@@ -277,12 +272,6 @@ static inline struct ctl_table_header *register_sysctl_mount_point(const char *p
return NULL;
}

-static inline struct ctl_table_header *register_sysctl_paths(
- const struct ctl_path *path, struct ctl_table *table)
-{
- return NULL;
-}
-
static inline struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table)
{
return NULL;
--
2.39.1