xv6-simplified 0.1
简化版xv6
Loading...
Searching...
No Matches
Functions | Variables
file.c File Reference

文件相关数据结构和函数 More...

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

Functions

void fileinit (void)
 初始化文件池中的文件
 
struct filefilealloc (void)
 从文件描述符池中申请文件描述符
 
struct filefiledup (struct file *f)
 增加文件描述符f的引用计数值
 
void fileclose (struct file *f)
 关闭文件描述符;若引用数不为0,则减少引用数,否则关闭
 
int filestat (struct file *f, uint64 addr)
 获取文件的元数据(只针对stat结构体)
 
int fileread (struct file *f, uint64 addr, int n)
 读文件f
 
int filewrite (struct file *f, uint64 addr, int n)
 写文件f
 

Variables

struct devsw devsw [NDEV]
 
struct { 
 
   struct file   file [NFILE
 
ftable 
 

Detailed Description

文件相关数据结构和函数

Date
23.5.26
Author
yrz、xin
Version
0.2 @status Stable

Function Documentation

◆ filealloc()

struct file * filealloc ( void  )

从文件描述符池中申请文件描述符

Returns
指向文件描述符的指针

◆ fileclose()

void fileclose ( struct file f)

关闭文件描述符;若引用数不为0,则减少引用数,否则关闭

Parameters
f待关闭的文件描述符
Here is the call graph for this function:
Here is the caller graph for this function:

◆ filedup()

struct file * filedup ( struct file f)

增加文件描述符f的引用计数值

Parameters
f文件描述符
Returns
文件描述符f
Here is the call graph for this function:

◆ fileinit()

void fileinit ( void  )

初始化文件池中的文件

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileread()

int fileread ( struct file f,
uint64  addr,
int  n 
)

读文件f

Parameters
f文件
addr用户虚拟地址
n读取字节数
Returns
读取到的字节数
Here is the call graph for this function:

◆ filestat()

int filestat ( struct file f,
uint64  addr 
)

获取文件的元数据(只针对stat结构体)

Parameters
f文件描述符
addr存放元数据的用户虚拟地址
Returns
0:成功 -1:失败
Here is the call graph for this function:

◆ filewrite()

int filewrite ( struct file f,
uint64  addr,
int  n 
)

写文件f

Parameters
f文件描述符
addr源数据用户虚拟地址
n写字节数
Returns
写入字节数
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ devsw

struct devsw devsw[NDEV]

◆ file

struct file file[NFILE]

◆ [struct]

struct { ... } ftable