1 /*
2  * Copyright (c) 2006-2023, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  */
9 
10 #include "proc.h"
11 #include "procfs.h"
12 
13 #include <rthw.h>
14 #include <rtdbg.h>
15 
16 #include <fcntl.h>
17 #include <errno.h>
18 
19 #include <dfs_dentry.h>
20 
21 static char *__proc_cmdline = NULL;
22 
proc_cmdline_save(const char * cmdline)23 int proc_cmdline_save(const char *cmdline)
24 {
25     if (__proc_cmdline)
26     {
27         free(__proc_cmdline);
28         __proc_cmdline = NULL;
29     }
30 
31     __proc_cmdline = strdup(cmdline);
32 
33     return 0;
34 }
35 
single_show(struct dfs_seq_file * seq,void * data)36 static int single_show(struct dfs_seq_file *seq, void *data)
37 {
38     if (__proc_cmdline)
39     {
40         dfs_seq_puts(seq, __proc_cmdline);
41     }
42 
43     return 0;
44 }
45 
proc_cmdline_init(void)46 int proc_cmdline_init(void)
47 {
48     struct proc_dentry *dentry = proc_create_single_data("cmdline", 0, NULL, single_show, NULL);
49     proc_release(dentry);
50 
51     return 0;
52 }
53 INIT_ENV_EXPORT(proc_cmdline_init);
54