[PATCH RFC 2/9] sysctl: Add flags to struct ctl_table
From: Joel Granados
Date: Thu Nov 26 2026 - 06:48:45 EST
Add a u8 flags member. It takes one byte of the two-byte hole after
mode, so struct ctl_table stays the same size. Even though we are adding
it to house the overlay flags for the ctl_table_tmpl template, it can be
used as a general way to modify the registration and read/write
operation of the ctl path.
Signed-off-by: Joel Granados <joel.granados@xxxxxxxxxx>
---
fs/proc/proc_sysctl.c | 1 +
include/linux/sysctl.h | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 6c0859c6656356f39010e9d47debc0487b751a32..1c5ccb29707d83bacad06198c0dcab39c8b7b347 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -1343,6 +1343,7 @@ static struct ctl_dir *sysctl_mkdir_p(struct ctl_dir *dir, const char *path)
* data - a pointer to data for use by proc_handler
* maxlen - the maximum size in bytes of the data
* mode - the file permissions for the /proc/sys file
+ * flags - Used in registration and write/read ops
* type - Defines the target type (described in struct definition)
* proc_handler - the text handler routine (described below)
*
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 4faa3bc189e7afbc270f4ba14b04b32a3f2d1413..3654fd31e3cc4f9217ae61b0bb4d6f4c677ea237 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -22,6 +22,7 @@
#ifndef _LINUX_SYSCTL_H
#define _LINUX_SYSCTL_H
+#include <linux/bits.h>
#include <linux/build_bug.h>
#include <linux/list.h>
#include <linux/rcupdate.h>
@@ -219,12 +220,19 @@ static inline void *proc_sys_poll_event(struct ctl_table_poll *poll)
#define DEFINE_CTL_TABLE_POLL(name) \
struct ctl_table_poll name = __CTL_TABLE_POLL_INITIALIZER(name)
+/* Overlay types. Describes what is overlain when registering a template */
+#define SYSCTL_OVERLAY_DATA BIT(0)
+#define SYSCTL_OVERLAY_EXTRA1 BIT(1)
+#define SYSCTL_OVERLAY_EXTRA2 BIT(2)
+#define SYSCTL_OVERLAY_MODE BIT(3)
+
/* A sysctl table is an array of struct ctl_table: */
struct ctl_table {
const char *procname; /* Text ID for /proc/sys */
void *data;
int maxlen;
umode_t mode;
+ u8 flags; /* Used in registration and write/read ops */
proc_handler *proc_handler; /* Callback for text formatting */
struct ctl_table_poll *poll;
void *extra1;
--
2.50.1