更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
mounts_proc.c 文件参考

浏览源代码.

函数

static int ShowType (const char *devPoint, const char *mountPoint, struct statfs *statBuf, void *arg)
 
static int MountsProcFill (struct SeqBuf *m, void *v)
 读取 mount 接口实现 更多...
 
void ProcMountsInit (void)
 

变量

static const struct ProcFileOperations MOUNTS_PROC_FOPS
 实现 操作proc file 接口,也可理解为驱动程序不同 更多...
 

函数说明

◆ MountsProcFill()

static int MountsProcFill ( struct SeqBuf m,
void v 
)
static

读取 mount 接口实现

在文件 mounts_proc.c78 行定义.

79{
81 (void)foreach_mountpoint(handler, (void *)m);
82
83 return 0;
84}
int(* foreach_mountpoint_t)(const char *devpoint, const char *mountpoint, struct statfs *statbuf, void *arg)
Definition: mount.h:96
int foreach_mountpoint(foreach_mountpoint_t handler, void *arg)
static int ShowType(const char *devPoint, const char *mountPoint, struct statfs *statBuf, void *arg)
Definition: mounts_proc.c:41
ARG_NUM_3 ARG_NUM_1 ARG_NUM_2 ARG_NUM_2 ARG_NUM_3 ARG_NUM_1 ARG_NUM_4 ARG_NUM_2 ARG_NUM_2 ARG_NUM_5 ARG_NUM_2 void
函数调用图:

◆ ProcMountsInit()

void ProcMountsInit ( void  )

在文件 mounts_proc.c90 行定义.

91{
92 struct ProcDirEntry *pde = CreateProcEntry("mounts", 0, NULL);
93 if (pde == NULL) {
94 PRINT_ERR("creat mounts error!\n");
95 return;
96 }
97
98 pde->procFileOps = &MOUNTS_PROC_FOPS;//操作 /proc/mounts 的具体实现
99}
static const struct ProcFileOperations MOUNTS_PROC_FOPS
实现 操作proc file 接口,也可理解为驱动程序不同
Definition: mounts_proc.c:86
struct ProcDirEntry * CreateProcEntry(const char *name, mode_t mode, struct ProcDirEntry *parent)
create a proc node
Definition: proc_file.c:364
proc 目录/文件项, @notethinking 直接叫 ProcEntry不香吗 ? 操作 /proc的 真正结构体
Definition: proc_fs.h:101
const struct ProcFileOperations * procFileOps
驱动程序,每个 /proc 下目录的驱动程序都不一样
Definition: proc_fs.h:106
函数调用图:
这是这个函数的调用关系图:

◆ ShowType()

static int ShowType ( const char *  devPoint,
const char *  mountPoint,
struct statfs *  statBuf,
void arg 
)
static

在文件 mounts_proc.c41 行定义.

42{
43 struct SeqBuf *seqBuf = (struct SeqBuf *)arg;
44 char *type = NULL;
45
46 switch (statBuf->f_type) {//目前鸿蒙支持的文件系统
47 case PROCFS_MAGIC: //虚拟文件系统,通过它可以使鸿蒙在内核空间和用户空间之间进行通信
48 type = "proc";
49 break;
50 case JFFS2_SUPER_MAGIC:
51 type = "jffs2"; //基于 nor flash的文件系统
52 break;
53 case NFS_SUPER_MAGIC://网络文件系统
54 type = "nfs";
55 break;
56 case TMPFS_MAGIC://tmpfs /mnt/wsl windows10的 wsl 实现是 tmpfs方式
57 type = "tmpfs"; //内存文件系统
58 break;
59 case MSDOS_SUPER_MAGIC:
60 type = "vfat";
61 break;
62 case ZPFS_MAGIC:
63 type = "zpfs";
64 break;
65 default:
66 return 0;
67 }
68
69 if (strlen(devPoint) == 0) {
70 (void)LosBufPrintf(seqBuf, "%s %s %s %s %d %d\n", type, mountPoint, type, "()", 0, 0);
71 } else {
72 (void)LosBufPrintf(seqBuf, "%s %s %s %s %d %d\n", devPoint, mountPoint, type, "()", 0, 0);
73 }
74
75 return 0;
76}
int LosBufPrintf(struct SeqBuf *seqBuf, const char *fmt,...)
支持可变参数 写 buf
Definition: los_seq_buf.c:133
函数调用图:
这是这个函数的调用关系图:

变量说明

◆ MOUNTS_PROC_FOPS

const struct ProcFileOperations MOUNTS_PROC_FOPS
static
初始值:
= {
.read = MountsProcFill,
}
static int MountsProcFill(struct SeqBuf *m, void *v)
读取 mount 接口实现
Definition: mounts_proc.c:78

实现 操作proc file 接口,也可理解为驱动程序不同

在文件 mounts_proc.c86 行定义.