📚往期笔录记录✏️:
✏️ 鸿蒙(HarmonyOS)北向开发知识点记录~
✏️ 鸿蒙(OpenHarmony)南向开发保姆级知识点汇总~
✏️ 鸿蒙应用开发与鸿蒙系统开发哪个更有前景?
✏️ 嵌入式开发适不适合做鸿蒙南向开发?看完这篇你就了解了~
✏️ 对于大前端开发来说,转鸿蒙开发究竟是福还是祸?
✏️ 鸿蒙岗位需求突增!移动端、PC端、IoT到底该怎么选?
✏️ 记录一场鸿蒙开发岗位面试经历~
✏️ 持续更新中……
1、VFS结构体定义
在文件components\fs\vfs\fs_operations.h中定义了VFS虚拟文件系统操作涉及的结构体。⑴处的struct MountOps结构体封装了挂载相关的操作,包含挂载、卸载和文件系统统计操作。⑵处的struct FsMap结构体映射文件系统类型及其对应的挂载操作和文件系统操作,支持的文件类型包含“fat”和“littlefs”两种,通过这个结构体可以获取对应文件类型的挂载操作及文件系统操作接口。⑶处的struct FileOps封装文件系统的操作接口,包含文件操作、目录操作,统计等相应的接口。
⑴ struct MountOps {
int (*Mount)(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags,
const void *data);
int (*Umount)(const char* target);
int (*Umount2)(const char* target, int flag);
int (*Statfs)(const char *path, struct statfs *buf);
};
⑵ struct FsMap {
const char *fileSystemtype;
const struct MountOps *fsMops;
const struct FileOps *fsFops;
};
⑶ struct FileOps {
int (*Open)(const char *path, int openFlag, ...);
int (*Close)(int fd);
int (*Unlink)(const char *fileName);
int (*Rmdir)(const char *dirName);
int (*Mkdir)(const char *dirName, mode_t mode);
struct dirent *(*Readdir)(DIR *dir);
DIR *(*Opendir)(const char *dirName);
int (*Closedir)(DIR *dir);
int (*Read)(int fd, vo