WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
proc_fs.h
浏览该文件的文档.
1/* ----------------------------------------------------------------------------
2 * Copyright (c) Huawei Technologies Co., Ltd. 2015-2019. All rights reserved.
3 * Description: LiteOS PROC FS Headfile
4 * Author: Huawei LiteOS Team
5 * Create: 2013-01-01
6 * Redistribution and use in source and binary forms, with or without modification,
7 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 * to endorse or promote products derived from this software without specific prior written
15 * permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * --------------------------------------------------------------------------- */
28
29#ifndef _PROC_FS_H
30#define _PROC_FS_H
31#include <sys/types.h>
32
33#ifdef LOSCFG_FS_PROC
34#include "linux/spinlock.h"
35#include "asm/atomic.h"
36#include "fs/fs.h"
37
38#ifdef __cplusplus
39extern "C" {
40#endif /* __cplusplus */
41
42typedef unsigned short fmode_t;
43#define MAX_NAMELEN 32
44
45struct proc_file;
46struct proc_dir_entry;
47struct proc_file_operations;
48
49typedef int (*read_proc_t)(struct proc_file *pf, void *buf);
50typedef int (*write_proc_t)(struct proc_file *pf, const char *buf, size_t count, loff_t *ppos);
51
52struct proc_file_operations {
53 char *name;
54
55 /* make a proc file */
56 loff_t (*llseek)(struct proc_file *pf, loff_t offset, int whence);
57 int (*open)(struct inode *inode, struct proc_file *pf);
58 int (*release)(struct inode *inode, struct proc_file *pf);
59 ssize_t (*read)(struct proc_file *pf, char *buf, size_t count, loff_t *ppos);
60 ssize_t (*write)(struct proc_file *pf, const char *buf, size_t count, loff_t *ppos);
61};
62
63struct proc_dir_entry {
64 mode_t mode;
65 int flags;
66 const struct proc_file_operations *proc_fops;
67 struct proc_file *pf;
68 struct proc_dir_entry *next, *parent, *subdir;
69 void *data;
70 read_proc_t read_proc;
71 write_proc_t write_proc;
72 atomic_t count; /* open file count */
73 spinlock_t pde_unload_lock;
74
75 int namelen;
76 struct proc_dir_entry *pdir_current;
77 char name[MAX_NAMELEN];
78};
79
80struct proc_file {
81 fmode_t f_mode;
82 spinlock_t f_lock;
83 atomic_t f_count;
84 struct proc_dir_entry *pPDE;
85 void *private_data;
86 unsigned long long f_version;
87 loff_t f_pos;
88 char name[MAX_NAMELEN];
89};
90
120extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
121 struct proc_dir_entry *parent);
122
145extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
146
172extern struct proc_dir_entry *proc_mkdir(const char *name, struct proc_dir_entry *parent);
173
201extern struct proc_dir_entry *proc_create(const char *name, mode_t mode,
202 struct proc_dir_entry *parent, const struct proc_file_operations *proc_fops);
203
225extern void proc_fs_init(void);
226
227#ifdef __cplusplus
228}
229#endif /* __cplusplus */
230
231#endif /* LOSCFG_FS_PROC */
232#endif /* _PROC_FS_H */
INT32 ssize_t
Definition los_typedef.h:77
Definition hal_uart_v151_regs_def.h:38