struct dir{.....................................................................................................................................3
struct direct direct[DIRNUM];...................................................................................................3
__int16 size;...............................................................................................................................3
};.................................................................................................................................................3
2.3 全局变量和函数...................................................................................................................4
// 全局变量..................................................................................................................................4
unsigned __int8 di_bitmap[DINODENUM]; // 硬盘 inode 节点位图 1 表示已使用 0 表示未
使用.............................................................................................................................................4
unsigned __int8 bk_bitmap[DATABLKNUM]; // 数据块 block 位图......................................4
struct super_block filsys; //超级块.............................................................................................4
struct pwd pwd[PWDNUM];......................................................................................................4
FILE *fd; //文件指针..................................................................................................................4
struct inode *cur_inode; //i 节点当前目录指针........................................................................4
struct inode *inodetemp; //i 节点指针........................................................................................4
const char fsystemname[20]="Linux.EXT2"; //模拟硬盘的文件名.........................................4
struct direct dir_buf[BLOCKSIZ / sizeof(struct direct)]; //目录数组.......................................4
char cmdhead[20];//cmd 的头 表示所在哪个文件夹 、..........................................................4
int i_lock=0;//inode 位图锁 可能会多线程...............................................................................4
int b_lock=0;//block 位图锁.......................................................................................................4
struct pwd *cur_user;..................................................................................................................4
/* 全局函数 */............................................................................................................................4
extern int Format();//格式化磁盘...............................................................................................4
extern int Install();//启动,安装文件系统................................................................................4
struct inode * read_inode(int);//install 里面读取文件 dinode...................................................4
struct direct * read_dir_data(int);//读取存储文件夹的物理块.................................................4
extern void showdir();//命令 dir.................................................................................................4
int Enterdir(char[]);//进入某个文件夹 命令-- cd 文件名.........................................................4
int Fd_dirfile(char[]);//查找当前目录里的文件 没找到返回-1 找到返回 inode 号...............4
int Iscmd(char[]);//判断是否两个字符串的命令......................................................................4
void two_cmd(char[],char[]);//两个字符串的命令...................................................................4
int creat(char[]);//创建文件........................................................................................................4
void changeinode();//交换指针..................................................................................................4
char * ReadFile(char[]);//读取文件............................................................................................4
int mkdir(char[]);//创建文件夹..................................................................................................4
void showbitmap();//显示位图...................................................................................................4
int deletefd(char[]);//删除文件...................................................................................................4
int editfile(char[]);//编辑文件.....................................................................................................4
int rename(char[]);//重命名........................................................................................................4
void showhelp();//命令帮助.......................................................................................................4
void login();.................................................................................................................................4
void logout();...............................................................................................................................4
int access();//权限判断...............................................................................................................4
/*磁盘 i 节点的分配与释放(当一个新文件被建立的时候,在给该文件分配磁盘存储区
之前,.........................................................................................................................................4
..