linux/kernel/params.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Helpers for initial module or kernel cmdline parsing
 * Copyright (C) 2001 Rusty Russell.
 */
#include <linux/ctype.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/kstrtox.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/overflow.h>
#include <linux/security.h>
#include <linux/slab.h>
#include <linux/string.h>

#ifdef CONFIG_SYSFS
/* Protects all built-in parameters, modules use their own param_lock */
static DEFINE_MUTEX(param_lock);

/* Use the module's mutex, or if built-in use the built-in mutex */
#ifdef CONFIG_MODULES
#define KPARAM_MUTEX(mod)
#else
#define KPARAM_MUTEX
#endif

static inline void check_kparam_locked(struct module *mod)
{}
#else
static inline void check_kparam_locked(struct module *mod)
{
}
#endif /* !CONFIG_SYSFS */

/* This just allows us to keep track of which parameters are kmalloced. */
struct kmalloced_param {};
static LIST_HEAD(kmalloced_params);
static DEFINE_SPINLOCK(kmalloced_params_lock);

static void *kmalloc_parameter(unsigned int size)
{}

/* Does nothing if parameter wasn't kmalloced above. */
static void maybe_kfree_parameter(void *param)
{}

static char dash2underscore(char c)
{}

bool parameqn(const char *a, const char *b, size_t n)
{}

bool parameq(const char *a, const char *b)
{}

static bool param_check_unsafe(const struct kernel_param *kp)
{}

static int parse_one(char *param,
		     char *val,
		     const char *doing,
		     const struct kernel_param *params,
		     unsigned num_params,
		     s16 min_level,
		     s16 max_level,
		     void *arg, parse_unknown_fn handle_unknown)
{}

/* Args looks like "foo=bar,bar2 baz=fuz wiz". */
char *parse_args(const char *doing,
		 char *args,
		 const struct kernel_param *params,
		 unsigned num,
		 s16 min_level,
		 s16 max_level,
		 void *arg, parse_unknown_fn unknown)
{}

/* Lazy bastard, eh? */
#define STANDARD_PARAM_DEF(name, type, format, strtolfn)


STANDARD_PARAM_DEF();
STANDARD_PARAM_DEF();
STANDARD_PARAM_DEF();
STANDARD_PARAM_DEF();
STANDARD_PARAM_DEF();
STANDARD_PARAM_DEF();
STANDARD_PARAM_DEF();
STANDARD_PARAM_DEF();
STANDARD_PARAM_DEF();

int param_set_uint_minmax(const char *val, const struct kernel_param *kp,
		unsigned int min, unsigned int max)
{}
EXPORT_SYMBOL_GPL();

int param_set_charp(const char *val, const struct kernel_param *kp)
{}
EXPORT_SYMBOL();

int param_get_charp(char *buffer, const struct kernel_param *kp)
{}
EXPORT_SYMBOL();

void param_free_charp(void *arg)
{}
EXPORT_SYMBOL();

const struct kernel_param_ops param_ops_charp =;
EXPORT_SYMBOL();

/* Actually could be a bool or an int, for historical reasons. */
int param_set_bool(const char *val, const struct kernel_param *kp)
{}
EXPORT_SYMBOL();

int param_get_bool(char *buffer, const struct kernel_param *kp)
{}
EXPORT_SYMBOL();

const struct kernel_param_ops param_ops_bool =;
EXPORT_SYMBOL();

int param_set_bool_enable_only(const char *val, const struct kernel_param *kp)
{}
EXPORT_SYMBOL_GPL();

const struct kernel_param_ops param_ops_bool_enable_only =;
EXPORT_SYMBOL_GPL();

/* This one must be bool. */
int param_set_invbool(const char *val, const struct kernel_param *kp)
{}
EXPORT_SYMBOL();

int param_get_invbool(char *buffer, const struct kernel_param *kp)
{}
EXPORT_SYMBOL();

const struct kernel_param_ops param_ops_invbool =;
EXPORT_SYMBOL();

int param_set_bint(const char *val, const struct kernel_param *kp)
{}
EXPORT_SYMBOL();

const struct kernel_param_ops param_ops_bint =;
EXPORT_SYMBOL();

/* We break the rule and mangle the string. */
static int param_array(struct module *mod,
		       const char *name,
		       const char *val,
		       unsigned int min, unsigned int max,
		       void *elem, int elemsize,
		       int (*set)(const char *, const struct kernel_param *kp),
		       s16 level,
		       unsigned int *num)
{}

static int param_array_set(const char *val, const struct kernel_param *kp)
{}

static int param_array_get(char *buffer, const struct kernel_param *kp)
{}

static void param_array_free(void *arg)
{}

const struct kernel_param_ops param_array_ops =;
EXPORT_SYMBOL();

int param_set_copystring(const char *val, const struct kernel_param *kp)
{}
EXPORT_SYMBOL();

int param_get_string(char *buffer, const struct kernel_param *kp)
{}
EXPORT_SYMBOL();

const struct kernel_param_ops param_ops_string =;
EXPORT_SYMBOL();

/* sysfs output in /sys/modules/XYZ/parameters/ */
#define to_module_attr(n)
#define to_module_kobject(n)

struct param_attribute
{};

struct module_param_attrs
{};

#ifdef CONFIG_SYSFS
#define to_param_attr(n)

static ssize_t param_attr_show(struct module_attribute *mattr,
			       struct module_kobject *mk, char *buf)
{}

/* sysfs always hands a nul-terminated string in buf.  We rely on that. */
static ssize_t param_attr_store(struct module_attribute *mattr,
				struct module_kobject *mk,
				const char *buf, size_t len)
{}
#endif

#ifdef CONFIG_MODULES
#define __modinit
#else
#define __modinit
#endif

#ifdef CONFIG_SYSFS
void kernel_param_lock(struct module *mod)
{}

void kernel_param_unlock(struct module *mod)
{}

EXPORT_SYMBOL();
EXPORT_SYMBOL();

/*
 * add_sysfs_param - add a parameter to sysfs
 * @mk: struct module_kobject
 * @kp: the actual parameter definition to add to sysfs
 * @name: name of parameter
 *
 * Create a kobject if for a (per-module) parameter if mp NULL, and
 * create file in sysfs.  Returns an error on out of memory.  Always cleans up
 * if there's an error.
 */
static __modinit int add_sysfs_param(struct module_kobject *mk,
				     const struct kernel_param *kp,
				     const char *name)
{}

#ifdef CONFIG_MODULES
static void free_module_param_attrs(struct module_kobject *mk)
{}

/*
 * module_param_sysfs_setup - setup sysfs support for one module
 * @mod: module
 * @kparam: module parameters (array)
 * @num_params: number of module parameters
 *
 * Adds sysfs entries for module parameters under
 * /sys/module/[mod->name]/parameters/
 */
int module_param_sysfs_setup(struct module *mod,
			     const struct kernel_param *kparam,
			     unsigned int num_params)
{}

/*
 * module_param_sysfs_remove - remove sysfs support for one module
 * @mod: module
 *
 * Remove sysfs entries for module parameters and the corresponding
 * kobject.
 */
void module_param_sysfs_remove(struct module *mod)
{}
#endif

void destroy_params(const struct kernel_param *params, unsigned num)
{}

static struct module_kobject * __init locate_module_kobject(const char *name)
{}

static void __init kernel_add_sysfs_param(const char *name,
					  const struct kernel_param *kparam,
					  unsigned int name_skip)
{}

/*
 * param_sysfs_builtin - add sysfs parameters for built-in modules
 *
 * Add module_parameters to sysfs for "modules" built into the kernel.
 *
 * The "module" name (KBUILD_MODNAME) is stored before a dot, the
 * "parameter" name is stored behind a dot in kernel_param->name. So,
 * extract the "module" name for all built-in kernel_param-eters,
 * and for all who have the same, call kernel_add_sysfs_param.
 */
static void __init param_sysfs_builtin(void)
{}

ssize_t __modver_version_show(struct module_attribute *mattr,
			      struct module_kobject *mk, char *buf)
{}

extern const struct module_version_attribute __start___modver[];
extern const struct module_version_attribute __stop___modver[];

static void __init version_sysfs_builtin(void)
{}

/* module-related sysfs stuff */

static ssize_t module_attr_show(struct kobject *kobj,
				struct attribute *attr,
				char *buf)
{}

static ssize_t module_attr_store(struct kobject *kobj,
				struct attribute *attr,
				const char *buf, size_t len)
{}

static const struct sysfs_ops module_sysfs_ops =;

static int uevent_filter(const struct kobject *kobj)
{}

static const struct kset_uevent_ops module_uevent_ops =;

struct kset *module_kset;

static void module_kobj_release(struct kobject *kobj)
{}

const struct kobj_type module_ktype =;

/*
 * param_sysfs_init - create "module" kset
 *
 * This must be done before the initramfs is unpacked and
 * request_module() thus becomes possible, because otherwise the
 * module load would fail in mod_sysfs_init.
 */
static int __init param_sysfs_init(void)
{}
subsys_initcall(param_sysfs_init);

/*
 * param_sysfs_builtin_init - add sysfs version and parameter
 * attributes for built-in modules
 */
static int __init param_sysfs_builtin_init(void)
{}
late_initcall(param_sysfs_builtin_init);

#endif /* CONFIG_SYSFS */