44#include "sys/statfs.h"
52#define MAX_LFNAME_LENGTH 256
54#define FAT_RESERVED_NUM 2
55#define FAT32_MAXSIZE 0x100000000
56#define BAD_CLUSTER 0x7FFFFFFF
57#define DISK_ERROR 0xFFFFFFFF
58#define FAT12_END_OF_CLUSTER 0x00000FFF
59#define FAT16_END_OF_CLUSTER 0x0000FFFF
60#define FAT32_END_OF_CLUSTER 0x0FFFFFFF
64#define MBR_PRIMARY_PART_NUM 4
65#define JUMP_CODE "\xEB\xFE\x90"
70#define EXTENDED_PARTITION_CHS 0x05
74#define EXTENDED_PARTITION_LBA 0x0F
75#define GPT_PROTECTIVE_MBR 0xEE
79#define VBR_BS_NOT_FAT 2
84#define FAT_MAX_CLUSTER_SIZE 64
85#define FAT32_MAX_CLUSTER_SIZE 128
86#define FAT32_ENTRY_SIZE 4
87#define FAT16_ENTRY_SIZE 2
88#define VOL_MIN_SIZE 128
89#define SFD_START_SECTOR 63
90#define MAX_BLOCK_SIZE 32768
93#define FAT32_RESERVED_SECTOR 32
94#define FAT_RESERVED_SECTOR 1
96#define DIR_NAME_LEN 11
97#define DIR_READ_COUNT 7
99#define VOLUME_CHAR_LENGTH 4
103#define FDEBUG(format, ...) do { \
104 PRINTK("[%s:%d]"format"\n", __func__, __LINE__, ##__VA_ARGS__); \
112#define FMT_FAT32 0x02
114#define FMT_ERASE 0x08
139int fatfs_rename(
struct Vnode *oldvnode,
struct Vnode *newparent,
const char *oldname,
const char *newname);
149FRESULT
_mkfs(
los_part *partition,
const MKFS_PARM *opt, BYTE *work, UINT len);
int fatfs_stat(struct Vnode *vnode, struct stat *buff)
int fatfs_statfs(struct Mount *mount, struct statfs *info)
int fatfs_closedir(struct Vnode *vnode, struct fs_dirent_s *dir)
int fatfs_rewinddir(struct Vnode *vnode, struct fs_dirent_s *dir)
int fatfs_mkdir(struct Vnode *parent, const char *name, mode_t mode, struct Vnode **vpp)
FRESULT find_fat_partition(FATFS *fs, los_part *part, BYTE *format, QWORD *start_sector)
int fatfs_fsync(struct file *filep)
int fatfs_2_vfs(int result)
FRESULT _mkfs(los_part *partition, const MKFS_PARM *opt, BYTE *work, UINT len)
int fatfs_rename(struct Vnode *oldvnode, struct Vnode *newparent, const char *oldname, const char *newname)
int fatfs_ioctl(struct file *filep, int req, unsigned long arg)
int fatfs_fscheck(struct Vnode *vnode, struct fs_dirent_s *dir)
int fatfs_chattr(struct Vnode *vnode, struct IATTR *attr)
FRESULT init_fatobj(FATFS *fs, BYTE fmt, QWORD start_sector)
int fatfs_readdir(struct Vnode *vnode, struct fs_dirent_s *idir)
int fatfs_lookup(struct Vnode *parent, const char *name, int len, struct Vnode **vpp)
fat文件系统对 Lookup 接口的实现
int fatfs_create(struct Vnode *parent, const char *name, int mode, struct Vnode **vpp)
创建 fat vnode 节点
int fatfs_fallocate64(struct file *filep, int mode, off64_t offset, off64_t len)
int fatfs_mount(struct Mount *mount, struct Vnode *device, const void *data)
fat将分区文件系统挂载 举例: mount /dev/mmcblk0p0 /bin1/vs/sd vfat
int fatfs_fallocate(struct file *filep, int mode, off_t offset, off_t len)
off64_t fatfs_lseek(struct file *filep, off_t offset, int whence)
int fatfs_read(struct file *filep, char *buff, size_t count)
off_t fatfs_lseek64(struct file *filep, off64_t offset, int whence)
int fatfs_rmdir(struct Vnode *parent, struct Vnode *vp, const char *name)
int fatfs_mkfs(struct Vnode *device, int sectors, int option)
int fatfs_write(struct file *filep, const char *buff, size_t count)
int fatfs_umount(struct Mount *mount, struct Vnode **device)
int fatfs_truncate64(struct Vnode *vnode, off64_t len)
int fatfs_truncate(struct Vnode *vnode, off_t len)
int fatfs_opendir(struct Vnode *vnode, struct fs_dirent_s *idir)
int fatfs_unlink(struct Vnode *parent, struct Vnode *vp, const char *name)
举例: mount /dev/mmcblk0p0 /bin1/vs/sd vfat 将/dev/mmcblk0p0 挂载到/bin1/vs/sd目录
vnode并不包含文件名,因为 vnode和文件名是 1:N 的关系
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 ARG_NUM_0 ARG_NUM_2 ARG_NUM_1 ARG_NUM_2 ARG_NUM_3 ARG_NUM_7 ARG_NUM_2 ARG_NUM_3 ARG_NUM_2 ARG_NUM_4 off64_t
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 ARG_NUM_0 ARG_NUM_2 ARG_NUM_1 ARG_NUM_2 ARG_NUM_3 ARG_NUM_7 ARG_NUM_2 ARG_NUM_3 ARG_NUM_2 ARG_NUM_4 ARG_NUM_5 ARG_NUM_6 ARG_NUM_3 ARG_NUM_5 ARG_NUM_7 ARG_NUM_1 ARG_NUM_4 ARG_NUM_5 ARG_NUM_4 ARG_NUM_7 ARG_NUM_2 ARG_NUM_3 ARG_NUM_7 ARG_NUM_7 ARG_NUM_3 ARG_NUM_3 ARG_NUM_3 ARG_NUM_7 ARG_NUM_3 ARG_NUM_2 char ARG_NUM_2 ARG_NUM_1 ARG_NUM_0 ARG_NUM_0 ARG_NUM_3 void ARG_NUM_1 ARG_NUM_0 unsigned ARG_NUM_0 ARG_NUM_2 ARG_NUM_3 ARG_NUM_2 ARG_NUM_5 ARG_NUM_3 ARG_NUM_3 ARG_NUM_4 ARG_NUM_1 ARG_NUM_1 ARG_NUM_3 ARG_NUM_2 mode_t