xv6-simplified 0.1
简化版xv6
Loading...
Searching...
No Matches
Data Structures | Functions
fat32.c File Reference

FAT32文件系统相关 More...

#include "include/types.h"
#include "include/stat.h"
#include "include/param.h"
#include "include/riscv.h"
#include "include/fat32.h"
#include "include/buf.h"
#include "include/proc.h"
#include "include/defs.h"
#include "include/fsutils.h"
Include dependency graph for fat32.c:

Data Structures

struct  entry_cache
 

Functions

int fat32_init ()
 初始化 FAT32 文件系统
 
struct direntdirlookup (struct dirent *entry, char *filename, uint *poff)
 在指定目录项中查找指定文件名的目录项
 
char * formatname (char *name)
 对输入的文件名进行格式化
 
struct direntedup (struct dirent *entry)
 增加目录项的引用链接数
 
void eupdate (struct dirent *entry)
 将目录的更改更新到磁盘上
 
void eput (struct dirent *entry)
 把目录项entry插入到root之后,减少entry引用链接数
 
void estat (struct dirent *de, struct stat *st)
 将一个目录项的信息转换为一个文件状态结构体
 
void elock (struct dirent *entry)
 判断地址和链接数是否合法
 
void eunlock (struct dirent *entry)
 判断地址和链接数是否合法
 
int enext (struct dirent *dp, struct dirent *ep, uint off, int *count)
 在dp描述的目录项的off个字节偏移处寻找相应的目录项并存放到ep中
 
struct direntename (char *path)
 根据路径名查目录
 
int eread (struct dirent *entry, int user_dst, uint64 dst, uint off, uint n)
 从一个文件的指定偏移量开始读取一定数量的字节
 
int ewrite (struct dirent *entry, int user_src, uint64 src, uint off, uint n)
 从一个文件的指定偏移量开始写入一定数量的字节
 

Detailed Description

FAT32文件系统相关

Date
23.05.26
Author
xin
Version
0.2

Function Documentation

◆ dirlookup()

struct dirent * dirlookup ( struct dirent entry,
char *  filename,
uint poff 
)

在指定目录项中查找指定文件名的目录项

Parameters
entry指定的目录项
filename目标文件名
poff若找到目标目录项不启用,否则用于记录与目标文件等长目录项的空目录项的起始偏移或目录末尾
Returns
在内存中找到的目录项,若未找到返回0
Here is the call graph for this function:

◆ edup()

struct dirent * edup ( struct dirent entry)

增加目录项的引用链接数

Parameters
entry待更新的目录项
Returns
更新后的目录项
Here is the caller graph for this function:

◆ elock()

void elock ( struct dirent entry)

判断地址和链接数是否合法

Parameters
entry目录
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ename()

struct dirent * ename ( char *  path)

根据路径名查目录

Parameters
path路径名
Returns
查找到的目录项
Here is the caller graph for this function:

◆ enext()

int enext ( struct dirent dp,
struct dirent ep,
uint  off,
int *  count 
)

在dp描述的目录项的off个字节偏移处寻找相应的目录项并存放到ep中

Parameters
dp要查找目录项所在的上级目录描述符
ep存放目标目录项的描述符
off从dp开始的偏移字节数
count存放目标目录项数量的地址
Returns
1:成功找到目标目录项
0:dp的off偏移处的目录项已被删除
-1:查找失败或没找到
Here is the call graph for this function:
Here is the caller graph for this function:

◆ eput()

void eput ( struct dirent entry)

把目录项entry插入到root之后,减少entry引用链接数

Parameters
entry目录
Here is the call graph for this function:
Here is the caller graph for this function:

◆ eread()

int eread ( struct dirent entry,
int  user_dst,
uint64  dst,
uint  off,
uint  n 
)

从一个文件的指定偏移量开始读取一定数量的字节

Parameters
entry目录项的指针,要读取的文件
user_dst目标地址是否在用户空间
dst数据读取的目标地址
off从文件的哪个偏移量开始读取
n读取的字节数
Returns
0:失败 tot:读取字节数
Here is the caller graph for this function:

◆ estat()

void estat ( struct dirent ep,
struct stat st 
)

将一个目录项的信息转换为一个文件状态结构体

Parameters
de目录项
st文件状态结构体
Here is the call graph for this function:
Here is the caller graph for this function:

◆ eunlock()

void eunlock ( struct dirent entry)

判断地址和链接数是否合法

Parameters
entry目录
Here is the call graph for this function:
Here is the caller graph for this function:

◆ eupdate()

void eupdate ( struct dirent entry)

将目录的更改更新到磁盘上

Parameters
entry目录
Here is the caller graph for this function:

◆ ewrite()

int ewrite ( struct dirent entry,
int  user_src,
uint64  src,
uint  off,
uint  n 
)

从一个文件的指定偏移量开始写入一定数量的字节

Parameters
entry目录项的指针,要写入的文件
user_src数据来源是否在用户空间
src数据来源的地址
off写入文件的偏移量
n写入的字节数
Returns
-1:失败 tot:写入字节数
Here is the caller graph for this function:

◆ fat32_init()

int fat32_init ( void  )

初始化 FAT32 文件系统

从磁盘上读取文件系统的元数据,然后将这些元数据存储在内存中的相应数据结构中

Returns
0:成功 -1:失败
Here is the call graph for this function:
Here is the caller graph for this function:

◆ formatname()

char * formatname ( char *  name)

对输入的文件名进行格式化

Parameters
name要格式化的文件名
Returns
指向格式化后的文件名的指针
Here is the call graph for this function:

Variable Documentation

◆ [struct]

struct { ... } bpb

◆ byts_per_clus

uint32 byts_per_clus

◆ byts_per_sec

uint16 byts_per_sec

◆ data_clus_cnt

uint32 data_clus_cnt

◆ data_sec_cnt

uint32 data_sec_cnt

◆ fat_cnt

uint8 fat_cnt

◆ fat_sz

uint32 fat_sz

◆ first_data_sec

uint32 first_data_sec

◆ hidd_sec

uint32 hidd_sec

◆ root_clus

uint32 root_clus

◆ rsvd_sec_cnt

uint16 rsvd_sec_cnt

◆ sec_per_clus

uint8 sec_per_clus

◆ tot_sec

uint32 tot_sec