Changes in 5.15.82
arm64: mte: Avoid setting PG_mte_tagged if no tags cleared or restored
drm/i915: Create a dummy object for gen6 ppgtt
drm/i915/gt: Use i915_vm_put on ppgtt_create error paths
erofs: fix order >= MAX_ORDER warning due to crafted negative i_size
btrfs: sink iterator parameter to btrfs_ioctl_logical_to_ino
btrfs: free btrfs_path before copying inodes to userspace
spi: spi-imx: Fix spi_bus_clk if requested clock is higher than input clock
btrfs: move QUOTA_ENABLED check to rescan_should_stop from btrfs_qgroup_rescan_worker
btrfs: qgroup: fix sleep from invalid context bug in btrfs_qgroup_inherit()
drm/display/dp_mst: Fix drm_dp_mst_add_affected_dsc_crtcs() return code
drm/amdgpu: update drm_display_info correctly when the edid is read
drm/amdgpu: Partially revert "drm/amdgpu: update drm_display_info correctly when the edid is read"
iio: health: afe4403: Fix oob read in afe4403_read_raw
iio: health: afe4404: Fix oob read in afe4404_[read|write]_raw
iio: light: rpr0521: add missing Kconfig dependencies
bpf, perf: Use subprog name when reporting subprog ksymbol
scripts/faddr2line: Fix regression in name resolution on ppc64le
ARM: at91: rm9200: fix usb device clock id
libbpf: Handle size overflow for ringbuf mmap
hwmon: (ltc2947) fix temperature scaling
hwmon: (ina3221) Fix shunt sum critical calculation
hwmon: (i5500_temp) fix missing pci_disable_device()
hwmon: (ibmpex) Fix possible UAF when ibmpex_register_bmc() fails
bpf: Do not copy spin lock field from user in bpf_selem_alloc
nvmem: rmem: Fix return value check in rmem_read()
of: property: decrement node refcount in of_fwnode_get_reference_args()
ixgbevf: Fix resource leak in ixgbevf_init_module()
i40e: Fix error handling in i40e_init_module()
fm10k: Fix error handling in fm10k_init_module()
iavf: remove redundant ret variable
iavf: Fix error handling in iavf_init_module()
e100: Fix possible use after free in e100_xmit_prepare
net/mlx5: DR, Rename list field in matcher struct to list_node
net/mlx5: DR, Fix uninitialized var warning
net/mlx5: Fix uninitialized variable bug in outlen_write()
net/mlx5e: Fix use-after-free when reverting termination table
can: sja1000_isa: sja1000_isa_probe(): add missing free_sja1000dev()
can: cc770: cc770_isa_probe(): add missing free_cc770dev()
can: etas_es58x: es58x_init_netdev(): free netdev when register_candev()
can: m_can: pci: add missing m_can_class_free_dev() in probe/remove methods
can: m_can: Add check for devm_clk_get
qlcnic: fix sleep-in-atomic-context bugs caused by msleep
aquantia: Do not purge addresses when setting the number of rings
wifi: cfg80211: fix buffer overflow in elem comparison
wifi: cfg80211: don't allow multi-BSSID in S1G
wifi: mac8021: fix possible oob access in ieee80211_get_rate_duration
net: phy: fix null-ptr-deref while probe() failed
net: ethernet: ti: am65-cpsw: fix error handling in am65_cpsw_nuss_probe()
net: net_netdev: Fix error handling in ntb_netdev_init_module()
net/9p: Fix a potential socket leak in p9_socket_open
net: ethernet: nixge: fix NULL dereference
net: wwan: iosm: fix kernel test robot reported error
net: wwan: iosm: fix dma_alloc_coherent incompatible pointer type
dsa: lan9303: Correct stat name
tipc: re-fetch skb cb after tipc_msg_validate
net: hsr: Fix potential use-after-free
net: mdiobus: fix unbalanced node reference count
afs: Fix fileserver probe RTT handling
net: tun: Fix use-after-free in tun_detach()
packet: do not set TP_STATUS_CSUM_VALID on CHECKSUM_COMPLETE
sctp: fix memory leak in sctp_stream_outq_migrate()
net: ethernet: renesas: ravb: Fix promiscuous mode after system resumed
hwmon: (coretemp) Check for null before removing sysfs attrs
hwmon: (coretemp) fix pci device refcount leak in nv1a_ram_new()
riscv: vdso: fix section overlapping under some conditions
riscv: mm: Proper page permissions after initmem free
ALSA: dice: fix regression for Lexicon I-ONIX FW810S
error-injection: Add prompt for function error injection
tools/vm/slabinfo-gnuplot: use "grep -E" instead of "egrep"
nilfs2: fix NULL pointer dereference in nilfs_palloc_commit_free_entry()
x86/bugs: Make sure MSR_SPEC_CTRL is updated properly upon resume from S3
pinctrl: intel: Save and restore pins in "direct IRQ" mode
v4l2: don't fall back to follow_pfn() if pin_user_pages_fast() fails
net: stmmac: Set MAC's flow control register to reflect current settings
mmc: mmc_test: Fix removal of debugfs file
mmc: core: Fix ambiguous TRIM and DISCARD arg
mmc: sdhci-esdhc-imx: correct CQHCI exit halt state check
mmc: sdhci-sprd: Fix no reset data and command after voltage switch
mmc: sdhci: Fix voltage switch delay
drm/amdgpu: temporarily disable broken Clang builds due to blown stack-frame
drm/amdgpu: enable Vangogh VCN indirect sram mode
drm/i915: Fix negative value passed as remaining time
drm/i915: Never return 0 if not all requests retired
tracing/osnoise: Fix duration type
tracing: Fix race where histograms can be called before the event
tracing: Free buffers when a used dynamic event is removed
io_uring: update res mask in io_poll_check_events
io_uring: fix tw losing poll events
io_uring: cmpxchg for poll arm refs release
io_uring: make poll refs more robust
io_uring/poll: fix poll_refs race with cancelation
KVM: x86/mmu: Fix race condition in direct_page_fault
ASoC: ops: Fix bounds check for _sx controls
pinctrl: single: Fix potential division by zero
riscv: Sync efi page table's kernel mappings before switching
riscv: fix race when vmap stack overflow
riscv: kexec: Fixup irq controller broken in kexec crash path
nvme: fix SRCU protection of nvme_ns_head list
iommu/vt-d: Fix PCI device refcount leak in has_external_pci()
iommu/vt-d: Fix PCI device refcount leak in dmar_dev_scope_init()
mm: __isolate_lru_page_prepare() in isolate_migratepages_block()
mm: migrate: fix THP's mapcount on isolation
parisc: Increase FRAME_WARN to 2048 bytes on parisc
Kconfig.debug: provide a little extra FRAME_WARN leeway when KASAN is enabled
selftests: net: add delete nexthop route warning test
selftests: net: fix nexthop warning cleanup double ip typo
ipv4: Handle attempt to delete multipath route when fib_info contains an nh reference
ipv4: Fix route deletion when nexthop info is not specified
serial: stm32: Factor out GPIO RTS toggling into separate function
serial: stm32: Use TC interrupt to deassert GPIO RTS in RS485 mode
serial: stm32: Deassert Transmit Enable on ->rs485_config()
i2c: npcm7xx: Fix error handling in npcm_i2c_init()
i2c: imx: Only DMA messages with I2C_M_DMA_SAFE flag set
ACPI: HMAT: remove unnecessary variable initialization
ACPI: HMAT: Fix initiator registration for single-initiator systems
Revert "clocksource/drivers/riscv: Events are stopped during CPU suspend"
char: tpm: Protect tpm_pm_suspend with locks
Input: raydium_ts_i2c - fix memory leak in raydium_i2c_send()
ipc/sem: Fix dangling sem_array access in semtimedop race
proc: avoid integer type confusion in get_proc_long
proc: proc_skip_spaces() shouldn't think it is working on C strings
Linux 5.15.82
Change-Id: I4ce52cb5917c9036339810c816ab005a4e9489fb
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
489 lines
13 KiB
C
489 lines
13 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Generic dynamic event control interface
|
|
*
|
|
* Copyright (C) 2018 Masami Hiramatsu <mhiramat@kernel.org>
|
|
*/
|
|
|
|
#include <linux/debugfs.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/list.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/tracefs.h>
|
|
|
|
#include "trace.h"
|
|
#include "trace_output.h" /* for trace_event_sem */
|
|
#include "trace_dynevent.h"
|
|
|
|
static DEFINE_MUTEX(dyn_event_ops_mutex);
|
|
static LIST_HEAD(dyn_event_ops_list);
|
|
|
|
bool trace_event_dyn_try_get_ref(struct trace_event_call *dyn_call)
|
|
{
|
|
struct trace_event_call *call;
|
|
bool ret = false;
|
|
|
|
if (WARN_ON_ONCE(!(dyn_call->flags & TRACE_EVENT_FL_DYNAMIC)))
|
|
return false;
|
|
|
|
down_read(&trace_event_sem);
|
|
list_for_each_entry(call, &ftrace_events, list) {
|
|
if (call == dyn_call) {
|
|
atomic_inc(&dyn_call->refcnt);
|
|
ret = true;
|
|
}
|
|
}
|
|
up_read(&trace_event_sem);
|
|
return ret;
|
|
}
|
|
|
|
void trace_event_dyn_put_ref(struct trace_event_call *call)
|
|
{
|
|
if (WARN_ON_ONCE(!(call->flags & TRACE_EVENT_FL_DYNAMIC)))
|
|
return;
|
|
|
|
if (WARN_ON_ONCE(atomic_read(&call->refcnt) <= 0)) {
|
|
atomic_set(&call->refcnt, 0);
|
|
return;
|
|
}
|
|
|
|
atomic_dec(&call->refcnt);
|
|
}
|
|
|
|
bool trace_event_dyn_busy(struct trace_event_call *call)
|
|
{
|
|
return atomic_read(&call->refcnt) != 0;
|
|
}
|
|
|
|
int dyn_event_register(struct dyn_event_operations *ops)
|
|
{
|
|
if (!ops || !ops->create || !ops->show || !ops->is_busy ||
|
|
!ops->free || !ops->match)
|
|
return -EINVAL;
|
|
|
|
INIT_LIST_HEAD(&ops->list);
|
|
mutex_lock(&dyn_event_ops_mutex);
|
|
list_add_tail(&ops->list, &dyn_event_ops_list);
|
|
mutex_unlock(&dyn_event_ops_mutex);
|
|
return 0;
|
|
}
|
|
|
|
int dyn_event_release(const char *raw_command, struct dyn_event_operations *type)
|
|
{
|
|
struct dyn_event *pos, *n;
|
|
char *system = NULL, *event, *p;
|
|
int argc, ret = -ENOENT;
|
|
char **argv;
|
|
|
|
argv = argv_split(GFP_KERNEL, raw_command, &argc);
|
|
if (!argv)
|
|
return -ENOMEM;
|
|
|
|
if (argv[0][0] == '-') {
|
|
if (argv[0][1] != ':') {
|
|
ret = -EINVAL;
|
|
goto out;
|
|
}
|
|
event = &argv[0][2];
|
|
} else {
|
|
event = strchr(argv[0], ':');
|
|
if (!event) {
|
|
ret = -EINVAL;
|
|
goto out;
|
|
}
|
|
event++;
|
|
}
|
|
|
|
p = strchr(event, '/');
|
|
if (p) {
|
|
system = event;
|
|
event = p + 1;
|
|
*p = '\0';
|
|
}
|
|
if (event[0] == '\0') {
|
|
ret = -EINVAL;
|
|
goto out;
|
|
}
|
|
|
|
mutex_lock(&event_mutex);
|
|
for_each_dyn_event_safe(pos, n) {
|
|
if (type && type != pos->ops)
|
|
continue;
|
|
if (!pos->ops->match(system, event,
|
|
argc - 1, (const char **)argv + 1, pos))
|
|
continue;
|
|
|
|
ret = pos->ops->free(pos);
|
|
if (ret)
|
|
break;
|
|
}
|
|
tracing_reset_all_online_cpus();
|
|
mutex_unlock(&event_mutex);
|
|
out:
|
|
argv_free(argv);
|
|
return ret;
|
|
}
|
|
|
|
static int create_dyn_event(const char *raw_command)
|
|
{
|
|
struct dyn_event_operations *ops;
|
|
int ret = -ENODEV;
|
|
|
|
if (raw_command[0] == '-' || raw_command[0] == '!')
|
|
return dyn_event_release(raw_command, NULL);
|
|
|
|
mutex_lock(&dyn_event_ops_mutex);
|
|
list_for_each_entry(ops, &dyn_event_ops_list, list) {
|
|
ret = ops->create(raw_command);
|
|
if (!ret || ret != -ECANCELED)
|
|
break;
|
|
}
|
|
mutex_unlock(&dyn_event_ops_mutex);
|
|
if (ret == -ECANCELED)
|
|
ret = -EINVAL;
|
|
|
|
return ret;
|
|
}
|
|
|
|
/* Protected by event_mutex */
|
|
LIST_HEAD(dyn_event_list);
|
|
|
|
void *dyn_event_seq_start(struct seq_file *m, loff_t *pos)
|
|
{
|
|
mutex_lock(&event_mutex);
|
|
return seq_list_start(&dyn_event_list, *pos);
|
|
}
|
|
|
|
void *dyn_event_seq_next(struct seq_file *m, void *v, loff_t *pos)
|
|
{
|
|
return seq_list_next(v, &dyn_event_list, pos);
|
|
}
|
|
|
|
void dyn_event_seq_stop(struct seq_file *m, void *v)
|
|
{
|
|
mutex_unlock(&event_mutex);
|
|
}
|
|
|
|
static int dyn_event_seq_show(struct seq_file *m, void *v)
|
|
{
|
|
struct dyn_event *ev = v;
|
|
|
|
if (ev && ev->ops)
|
|
return ev->ops->show(m, ev);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct seq_operations dyn_event_seq_op = {
|
|
.start = dyn_event_seq_start,
|
|
.next = dyn_event_seq_next,
|
|
.stop = dyn_event_seq_stop,
|
|
.show = dyn_event_seq_show
|
|
};
|
|
|
|
/*
|
|
* dyn_events_release_all - Release all specific events
|
|
* @type: the dyn_event_operations * which filters releasing events
|
|
*
|
|
* This releases all events which ->ops matches @type. If @type is NULL,
|
|
* all events are released.
|
|
* Return -EBUSY if any of them are in use, and return other errors when
|
|
* it failed to free the given event. Except for -EBUSY, event releasing
|
|
* process will be aborted at that point and there may be some other
|
|
* releasable events on the list.
|
|
*/
|
|
int dyn_events_release_all(struct dyn_event_operations *type)
|
|
{
|
|
struct dyn_event *ev, *tmp;
|
|
int ret = 0;
|
|
|
|
mutex_lock(&event_mutex);
|
|
for_each_dyn_event(ev) {
|
|
if (type && ev->ops != type)
|
|
continue;
|
|
if (ev->ops->is_busy(ev)) {
|
|
ret = -EBUSY;
|
|
goto out;
|
|
}
|
|
}
|
|
for_each_dyn_event_safe(ev, tmp) {
|
|
if (type && ev->ops != type)
|
|
continue;
|
|
ret = ev->ops->free(ev);
|
|
if (ret)
|
|
break;
|
|
}
|
|
out:
|
|
tracing_reset_all_online_cpus();
|
|
mutex_unlock(&event_mutex);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int dyn_event_open(struct inode *inode, struct file *file)
|
|
{
|
|
int ret;
|
|
|
|
ret = tracing_check_open_get_tr(NULL);
|
|
if (ret)
|
|
return ret;
|
|
|
|
if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) {
|
|
ret = dyn_events_release_all(NULL);
|
|
if (ret < 0)
|
|
return ret;
|
|
}
|
|
|
|
return seq_open(file, &dyn_event_seq_op);
|
|
}
|
|
|
|
static ssize_t dyn_event_write(struct file *file, const char __user *buffer,
|
|
size_t count, loff_t *ppos)
|
|
{
|
|
return trace_parse_run_command(file, buffer, count, ppos,
|
|
create_dyn_event);
|
|
}
|
|
|
|
static const struct file_operations dynamic_events_ops = {
|
|
.owner = THIS_MODULE,
|
|
.open = dyn_event_open,
|
|
.read = seq_read,
|
|
.llseek = seq_lseek,
|
|
.release = seq_release,
|
|
.write = dyn_event_write,
|
|
};
|
|
|
|
/* Make a tracefs interface for controlling dynamic events */
|
|
static __init int init_dynamic_event(void)
|
|
{
|
|
struct dentry *entry;
|
|
int ret;
|
|
|
|
ret = tracing_init_dentry();
|
|
if (ret)
|
|
return 0;
|
|
|
|
entry = tracefs_create_file("dynamic_events", 0644, NULL,
|
|
NULL, &dynamic_events_ops);
|
|
|
|
/* Event list interface */
|
|
if (!entry)
|
|
pr_warn("Could not create tracefs 'dynamic_events' entry\n");
|
|
|
|
return 0;
|
|
}
|
|
fs_initcall(init_dynamic_event);
|
|
|
|
/**
|
|
* dynevent_arg_add - Add an arg to a dynevent_cmd
|
|
* @cmd: A pointer to the dynevent_cmd struct representing the new event cmd
|
|
* @arg: The argument to append to the current cmd
|
|
* @check_arg: An (optional) pointer to a function checking arg sanity
|
|
*
|
|
* Append an argument to a dynevent_cmd. The argument string will be
|
|
* appended to the current cmd string, followed by a separator, if
|
|
* applicable. Before the argument is added, the @check_arg function,
|
|
* if present, will be used to check the sanity of the current arg
|
|
* string.
|
|
*
|
|
* The cmd string and separator should be set using the
|
|
* dynevent_arg_init() before any arguments are added using this
|
|
* function.
|
|
*
|
|
* Return: 0 if successful, error otherwise.
|
|
*/
|
|
int dynevent_arg_add(struct dynevent_cmd *cmd,
|
|
struct dynevent_arg *arg,
|
|
dynevent_check_arg_fn_t check_arg)
|
|
{
|
|
int ret = 0;
|
|
|
|
if (check_arg) {
|
|
ret = check_arg(arg);
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
|
|
ret = seq_buf_printf(&cmd->seq, " %s%c", arg->str, arg->separator);
|
|
if (ret) {
|
|
pr_err("String is too long: %s%c\n", arg->str, arg->separator);
|
|
return -E2BIG;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* dynevent_arg_pair_add - Add an arg pair to a dynevent_cmd
|
|
* @cmd: A pointer to the dynevent_cmd struct representing the new event cmd
|
|
* @arg_pair: The argument pair to append to the current cmd
|
|
* @check_arg: An (optional) pointer to a function checking arg sanity
|
|
*
|
|
* Append an argument pair to a dynevent_cmd. An argument pair
|
|
* consists of a left-hand-side argument and a right-hand-side
|
|
* argument separated by an operator, which can be whitespace, all
|
|
* followed by a separator, if applicable. This can be used to add
|
|
* arguments of the form 'type variable_name;' or 'x+y'.
|
|
*
|
|
* The lhs argument string will be appended to the current cmd string,
|
|
* followed by an operator, if applicable, followed by the rhs string,
|
|
* followed finally by a separator, if applicable. Before the
|
|
* argument is added, the @check_arg function, if present, will be
|
|
* used to check the sanity of the current arg strings.
|
|
*
|
|
* The cmd strings, operator, and separator should be set using the
|
|
* dynevent_arg_pair_init() before any arguments are added using this
|
|
* function.
|
|
*
|
|
* Return: 0 if successful, error otherwise.
|
|
*/
|
|
int dynevent_arg_pair_add(struct dynevent_cmd *cmd,
|
|
struct dynevent_arg_pair *arg_pair,
|
|
dynevent_check_arg_fn_t check_arg)
|
|
{
|
|
int ret = 0;
|
|
|
|
if (check_arg) {
|
|
ret = check_arg(arg_pair);
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
|
|
ret = seq_buf_printf(&cmd->seq, " %s%c%s%c", arg_pair->lhs,
|
|
arg_pair->operator, arg_pair->rhs,
|
|
arg_pair->separator);
|
|
if (ret) {
|
|
pr_err("field string is too long: %s%c%s%c\n", arg_pair->lhs,
|
|
arg_pair->operator, arg_pair->rhs,
|
|
arg_pair->separator);
|
|
return -E2BIG;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* dynevent_str_add - Add a string to a dynevent_cmd
|
|
* @cmd: A pointer to the dynevent_cmd struct representing the new event cmd
|
|
* @str: The string to append to the current cmd
|
|
*
|
|
* Append a string to a dynevent_cmd. The string will be appended to
|
|
* the current cmd string as-is, with nothing prepended or appended.
|
|
*
|
|
* Return: 0 if successful, error otherwise.
|
|
*/
|
|
int dynevent_str_add(struct dynevent_cmd *cmd, const char *str)
|
|
{
|
|
int ret = 0;
|
|
|
|
ret = seq_buf_puts(&cmd->seq, str);
|
|
if (ret) {
|
|
pr_err("String is too long: %s\n", str);
|
|
return -E2BIG;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* dynevent_cmd_init - Initialize a dynevent_cmd object
|
|
* @cmd: A pointer to the dynevent_cmd struct representing the cmd
|
|
* @buf: A pointer to the buffer to generate the command into
|
|
* @maxlen: The length of the buffer the command will be generated into
|
|
* @type: The type of the cmd, checked against further operations
|
|
* @run_command: The type-specific function that will actually run the command
|
|
*
|
|
* Initialize a dynevent_cmd. A dynevent_cmd is used to build up and
|
|
* run dynamic event creation commands, such as commands for creating
|
|
* synthetic and kprobe events. Before calling any of the functions
|
|
* used to build the command, a dynevent_cmd object should be
|
|
* instantiated and initialized using this function.
|
|
*
|
|
* The initialization sets things up by saving a pointer to the
|
|
* user-supplied buffer and its length via the @buf and @maxlen
|
|
* params, and by saving the cmd-specific @type and @run_command
|
|
* params which are used to check subsequent dynevent_cmd operations
|
|
* and actually run the command when complete.
|
|
*/
|
|
void dynevent_cmd_init(struct dynevent_cmd *cmd, char *buf, int maxlen,
|
|
enum dynevent_type type,
|
|
dynevent_create_fn_t run_command)
|
|
{
|
|
memset(cmd, '\0', sizeof(*cmd));
|
|
|
|
seq_buf_init(&cmd->seq, buf, maxlen);
|
|
cmd->type = type;
|
|
cmd->run_command = run_command;
|
|
}
|
|
|
|
/**
|
|
* dynevent_arg_init - Initialize a dynevent_arg object
|
|
* @arg: A pointer to the dynevent_arg struct representing the arg
|
|
* @separator: An (optional) separator, appended after adding the arg
|
|
*
|
|
* Initialize a dynevent_arg object. A dynevent_arg represents an
|
|
* object used to append single arguments to the current command
|
|
* string. After the arg string is successfully appended to the
|
|
* command string, the optional @separator is appended. If no
|
|
* separator was specified when initializing the arg, a space will be
|
|
* appended.
|
|
*/
|
|
void dynevent_arg_init(struct dynevent_arg *arg,
|
|
char separator)
|
|
{
|
|
memset(arg, '\0', sizeof(*arg));
|
|
|
|
if (!separator)
|
|
separator = ' ';
|
|
arg->separator = separator;
|
|
}
|
|
|
|
/**
|
|
* dynevent_arg_pair_init - Initialize a dynevent_arg_pair object
|
|
* @arg_pair: A pointer to the dynevent_arg_pair struct representing the arg
|
|
* @operator: An (optional) operator, appended after adding the first arg
|
|
* @separator: An (optional) separator, appended after adding the second arg
|
|
*
|
|
* Initialize a dynevent_arg_pair object. A dynevent_arg_pair
|
|
* represents an object used to append argument pairs such as 'type
|
|
* variable_name;' or 'x+y' to the current command string. An
|
|
* argument pair consists of a left-hand-side argument and a
|
|
* right-hand-side argument separated by an operator, which can be
|
|
* whitespace, all followed by a separator, if applicable. After the
|
|
* first arg string is successfully appended to the command string,
|
|
* the optional @operator is appended, followed by the second arg and
|
|
* optional @separator. If no separator was specified when
|
|
* initializing the arg, a space will be appended.
|
|
*/
|
|
void dynevent_arg_pair_init(struct dynevent_arg_pair *arg_pair,
|
|
char operator, char separator)
|
|
{
|
|
memset(arg_pair, '\0', sizeof(*arg_pair));
|
|
|
|
if (!operator)
|
|
operator = ' ';
|
|
arg_pair->operator = operator;
|
|
|
|
if (!separator)
|
|
separator = ' ';
|
|
arg_pair->separator = separator;
|
|
}
|
|
|
|
/**
|
|
* dynevent_create - Create the dynamic event contained in dynevent_cmd
|
|
* @cmd: The dynevent_cmd object containing the dynamic event creation command
|
|
*
|
|
* Once a dynevent_cmd object has been successfully built up via the
|
|
* dynevent_cmd_init(), dynevent_arg_add() and dynevent_arg_pair_add()
|
|
* functions, this function runs the final command to actually create
|
|
* the event.
|
|
*
|
|
* Return: 0 if the event was successfully created, error otherwise.
|
|
*/
|
|
int dynevent_create(struct dynevent_cmd *cmd)
|
|
{
|
|
return cmd->run_command(cmd);
|
|
}
|
|
EXPORT_SYMBOL_GPL(dynevent_create);
|