Skip to content

Commit 1dc8689

Browse files
committed
proc_sysctl: enhance documentation
Expand documentation to clarify: o that paths don't need to exist for the new API callers o clarify that we *require* callers to keep the memory of the table around during the lifetime of the sysctls o annotate routines we are trying to deprecate and later remove Cc: stable@vger.kernel.org # v5.17 Cc: Christian Brauner <brauner@kernel.org> Cc: Kefeng Wang <wangkefeng.wang@huawei.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
1 parent 9f17a75 commit 1dc8689

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

fs/proc/proc_sysctl.c

+20-5
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,10 @@ static struct ctl_dir *sysctl_mkdir_p(struct ctl_dir *dir, const char *path)
13161316
* __register_sysctl_table - register a leaf sysctl table
13171317
* @set: Sysctl tree to register on
13181318
* @path: The path to the directory the sysctl table is in.
1319-
* @table: the top-level table structure without any child
1319+
* @table: the top-level table structure without any child. This table
1320+
* should not be free'd after registration. So it should not be
1321+
* used on stack. It can either be a global or dynamically allocated
1322+
* by the caller and free'd later after sysctl unregistration.
13201323
*
13211324
* Register a sysctl table hierarchy. @table should be a filled in ctl_table
13221325
* array. A completely 0 filled entry terminates the table.
@@ -1410,8 +1413,15 @@ struct ctl_table_header *__register_sysctl_table(
14101413

14111414
/**
14121415
* register_sysctl - register a sysctl table
1413-
* @path: The path to the directory the sysctl table is in.
1414-
* @table: the table structure
1416+
* @path: The path to the directory the sysctl table is in. If the path
1417+
* doesn't exist we will create it for you.
1418+
* @table: the table structure. The calller must ensure the life of the @table
1419+
* will be kept during the lifetime use of the syctl. It must not be freed
1420+
* until unregister_sysctl_table() is called with the given returned table
1421+
* with this registration. If your code is non modular then you don't need
1422+
* to call unregister_sysctl_table() and can instead use something like
1423+
* register_sysctl_init() which does not care for the result of the syctl
1424+
* registration.
14151425
*
14161426
* Register a sysctl table. @table should be a filled in ctl_table
14171427
* array. A completely 0 filled entry terminates the table.
@@ -1427,8 +1437,11 @@ EXPORT_SYMBOL(register_sysctl);
14271437

14281438
/**
14291439
* __register_sysctl_init() - register sysctl table to path
1430-
* @path: path name for sysctl base
1431-
* @table: This is the sysctl table that needs to be registered to the path
1440+
* @path: path name for sysctl base. If that path doesn't exist we will create
1441+
* it for you.
1442+
* @table: This is the sysctl table that needs to be registered to the path.
1443+
* The caller must ensure the life of the @table will be kept during the
1444+
* lifetime use of the sysctl.
14321445
* @table_name: The name of sysctl table, only used for log printing when
14331446
* registration fails
14341447
*
@@ -1570,6 +1583,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
15701583
*
15711584
* Register a sysctl table hierarchy. @table should be a filled in ctl_table
15721585
* array. A completely 0 filled entry terminates the table.
1586+
* We are slowly deprecating this call so avoid its use.
15731587
*
15741588
* See __register_sysctl_table for more details.
15751589
*/
@@ -1641,6 +1655,7 @@ struct ctl_table_header *__register_sysctl_paths(
16411655
*
16421656
* Register a sysctl table hierarchy. @table should be a filled in ctl_table
16431657
* array. A completely 0 filled entry terminates the table.
1658+
* We are slowly deprecating this caller so avoid future uses of it.
16441659
*
16451660
* See __register_sysctl_paths for more details.
16461661
*/

0 commit comments

Comments
 (0)