History

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.

Luis R. Rodriguez committed 11 years ago

Commit d19f05d1 parent 05f408d3 files · +36 −31Browse files

Showing the changes to kernel/module.c (1 of 3 files). Show all

Unified · Split

kernel/module.c+0−31
@@ -298,37 +298,6 @@ static bool sig_enforce = true; · 297 unmodified lines
298#else298#else
299static bool sig_enforce = false;299static bool sig_enforce = false;
300 300
301static int param_set_bool_enable_only(const char *val,
302 const struct kernel_param *kp)
303{
304 int err = 0;
305 bool new_value;
306 bool orig_value = *(bool *)kp->arg;
307 struct kernel_param dummy_kp = *kp;
308
309 dummy_kp.arg = &new_value;
310
311 err = param_set_bool(val, &dummy_kp);
312 if (err)
313 return err;
314
315 /* Don't let them unset it once it's set! */
316 if (!new_value && orig_value)
317 return -EROFS;
318
319 if (new_value)
320 err = param_set_bool(val, kp);
321
322 return err;
323}
324
325static const struct kernel_param_ops param_ops_bool_enable_only = {
326 .flags = KERNEL_PARAM_OPS_FL_NOARG,
327 .set = param_set_bool_enable_only,
328 .get = param_get_bool,
329};
330#define param_check_bool_enable_only param_check_bool
331
332module_param(sig_enforce, bool_enable_only, 0644);301module_param(sig_enforce, bool_enable_only, 0644);
333#endif /* !CONFIG_MODULE_SIG_FORCE */302#endif /* !CONFIG_MODULE_SIG_FORCE */
334#endif /* CONFIG_MODULE_SIG */303#endif /* CONFIG_MODULE_SIG */