Skip to content

Commit 6036dc0

Browse files
committed
sysctl: Add CONFIG_PROC_SYSCTL guards for converter macros
Wrap sysctl converter macros with CONFIG_PROC_SYSCTL conditional compilation. When CONFIG_PROC_SYSCTL is disabled, provide stub implementations that return -ENOSYS to prevent link errors while maintaining API compatibility. This ensures converter macros are only compiled when procfs sysctl support is enabled in the kernel configuration. Signed-off-by: Joel Granados <joel.granados@kernel.org>
1 parent ac3d6a4 commit 6036dc0

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

include/linux/sysctl.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ extern const int sysctl_vals[];
7373
#define SYSCTL_USER_TO_KERN(dir) (!!(dir))
7474
#define SYSCTL_KERN_TO_USER(dir) (!dir)
7575

76+
#ifdef CONFIG_PROC_SYSCTL
7677
#define SYSCTL_USER_TO_KERN_INT_CONV(name, u_ptr_op) \
7778
int sysctl_user_to_kern_int_conv##name(const bool *negp, \
7879
const unsigned long *u_ptr,\
@@ -173,6 +174,48 @@ int do_proc_uint_conv##name(unsigned long *u_ptr, unsigned int *k_ptr, \
173174
return 0; \
174175
}
175176

177+
#else // CONFIG_PROC_SYSCTL
178+
#define SYSCTL_USER_TO_KERN_INT_CONV(name, u_ptr_op) \
179+
int sysctl_user_to_kern_int_conv##name(const bool *negp, \
180+
const unsigned long *u_ptr,\
181+
int *k_ptr) \
182+
{ \
183+
return -ENOSYS; \
184+
}
185+
186+
#define SYSCTL_KERN_TO_USER_INT_CONV(name, k_ptr_op) \
187+
int sysctl_kern_to_user_int_conv##name(bool *negp, \
188+
unsigned long *u_ptr, \
189+
const int *k_ptr) \
190+
{ \
191+
return -ENOSYS; \
192+
}
193+
194+
#define SYSCTL_INT_CONV_CUSTOM(name, user_to_kern, kern_to_user, \
195+
k_ptr_range_check) \
196+
int do_proc_int_conv##name(bool *negp, unsigned long *u_ptr, int *k_ptr,\
197+
int dir, const struct ctl_table *tbl) \
198+
{ \
199+
return -ENOSYS; \
200+
}
201+
202+
#define SYSCTL_USER_TO_KERN_UINT_CONV(name, u_ptr_op) \
203+
int sysctl_user_to_kern_uint_conv##name(const unsigned long *u_ptr,\
204+
unsigned int *k_ptr) \
205+
{ \
206+
return -ENOSYS; \
207+
}
208+
209+
#define SYSCTL_UINT_CONV_CUSTOM(name, user_to_kern, kern_to_user, \
210+
k_ptr_range_check) \
211+
int do_proc_uint_conv##name(unsigned long *u_ptr, unsigned int *k_ptr, \
212+
int dir, const struct ctl_table *tbl) \
213+
{ \
214+
return -ENOSYS; \
215+
}
216+
217+
#endif // CONFIG_PROC_SYSCTL
218+
176219

177220
extern const unsigned long sysctl_long_vals[];
178221

0 commit comments

Comments
 (0)