summaryrefslogtreecommitdiff
path: root/components/dfs/dfs_v2/filesystems/procfs/proc_cmdline.c
blob: 5845b5ff88390ef3f0aae28791345b659b5a1a2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * Copyright (c) 2006-2023, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 */

#include "proc.h"
#include "procfs.h"

#include <rthw.h>
#include <rtdbg.h>

#include <fcntl.h>
#include <errno.h>

#include <dfs_dentry.h>

static char *__proc_cmdline = NULL;

int proc_cmdline_save(const char *cmdline)
{
    if (__proc_cmdline)
    {
        free(__proc_cmdline);
        __proc_cmdline = NULL;
    }

    __proc_cmdline = strdup(cmdline);

    return 0;
}

static int single_show(struct dfs_seq_file *seq, void *data)
{
    if (__proc_cmdline)
    {
        dfs_seq_puts(seq, __proc_cmdline);
    }

    return 0;
}

int proc_cmdline_init(void)
{
    struct proc_dentry *dentry = proc_create_single_data("cmdline", 0, NULL, single_show, NULL);
    proc_release(dentry);

    return 0;
}
INIT_ENV_EXPORT(proc_cmdline_init);