mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-24 23:52:40 +00:00
kernel/params.c: generalize bool_enable_only
This takes out the bool_enable_only implementation from the module loading code and generalizes it so that others can make use of it. Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Jani Nikula <jani.nikula@intel.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Kees Cook <keescook@chromium.org> Cc: Tejun Heo <tj@kernel.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: linux-kernel@vger.kernel.org Cc: cocci@systeme.lip6.fr Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
05f408dddb
commit
d19f05d8a8
3 changed files with 36 additions and 31 deletions
|
@ -335,6 +335,36 @@ const struct kernel_param_ops param_ops_bool = {
|
|||
};
|
||||
EXPORT_SYMBOL(param_ops_bool);
|
||||
|
||||
int param_set_bool_enable_only(const char *val, const struct kernel_param *kp)
|
||||
{
|
||||
int err = 0;
|
||||
bool new_value;
|
||||
bool orig_value = *(bool *)kp->arg;
|
||||
struct kernel_param dummy_kp = *kp;
|
||||
|
||||
dummy_kp.arg = &new_value;
|
||||
|
||||
err = param_set_bool(val, &dummy_kp);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* Don't let them unset it once it's set! */
|
||||
if (!new_value && orig_value)
|
||||
return -EROFS;
|
||||
|
||||
if (new_value)
|
||||
err = param_set_bool(val, kp);
|
||||
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(param_set_bool_enable_only);
|
||||
|
||||
const struct kernel_param_ops param_ops_bool_enable_only = {
|
||||
.flags = KERNEL_PARAM_OPS_FL_NOARG,
|
||||
.set = param_set_bool_enable_only,
|
||||
.get = param_get_bool,
|
||||
};
|
||||
|
||||
/* This one must be bool. */
|
||||
int param_set_invbool(const char *val, const struct kernel_param *kp)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue