📄 format.c
字号:
#include <stdio.h>#include <string.h>#include "filesys.h" format(){ char* buff; super= (struct filesys* )malloc(sizeof(struct filesys)); fd=fopen("filesystem","w+"); buff= (char* )malloc(BLOCKNUM*BLOCKSIZE*sizeof(char)); if(buff ==NULL) { printf("\n file system file creat failed!!!\n"); } else { fseek(fd,0,SEEK_SET); fwrite(buff,BLOCKNUM*BLOCKSIZE*sizeof(char),1,fd); super->s_isize=BLOCKNUM; super->s_fsize=BLOCKNUM-DATABLOCKSTART; super->s_nfree=super->s_fsize; super->s_pfree=DATABLOCKSTART; super->s_ninode=INODENUMBER; super->s_pinode=0; fseek(fd,0,SEEK_SET); fwrite(super,sizeof(struct filesys),1,fd); fseek(fd,BLOCKSIZE,SEEK_SET); memset(block_buf,'0',BLOCKNUM); memset(block_buf,'1',DATABLOCKSTART); fwrite(block_buf,sizeof(char),BLOCKNUM,fd); fseek(fd,2*BLOCKSIZE,SEEK_SET); memset(inode_buf,'0',BLOCKNUM); fwrite(inode_buf,sizeof(char),BLOCKNUM,fd); super->s_free=block_buf; super->s_inode=inode_buf; newdir1("root","admin","root"); newdir2("root","admin"); } //fclose(fd);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -