- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
文件系统设计
1.文件系统
①下列几条命令
LOGIN 用户登陆
DIR 列文件目录
CREATE创建文件
DELETE删除文件
OPEN 打开文件
CLOSE 关闭文件
READ 读文件
WRITE 写文件
②列目录时要列出文件名,物理地址,保护码和文件长度。
③源文件可以进行读写保护。
①首先应确定文件系统的数据结构:主目录、子目录及活动文件等。主目录和子目录都以文件的形式存放于磁盘,这样便于查找和修改。
②用户创建的文件,可以编号存储于磁盘上。如:file0,file1,file2…并以编号作为物理地址,在目录中进行登记。
程序见下(本程序需要在c:下建一个名为osfile的目录及一个名为file的子目录):
#include stdio.h
#include string.h
#include conio.h
#include stdlib.h
#define MAXNAME 25 /*the largest length of mfdname,ufdname,filename*/
#define MAXCHILD 50 /*the largest child*/
#define MAX MAXCHILD*MAXCHILD /*the size of fpaddrno*/
typedef struct /*the structure of OSFILE*/int fpaddr; /*file physical address*/ int flength;/*file length*/ int fmode;/*file mode:0-Read Only;1-Write Only;2-Read and Writedefault;*/ char fname[MAXNAME]; /*file name*/ OSFILE;
typedef struct /*the structure of OSUFD*/char ufdname[MAXNAME];/*ufd name*/ OSFILE ufdfile[MAXCHILD];/*ufd own file*/OSUFD;
typedef struct /*the structure of OSUFDLOGIN*/char ufdname[MAXNAME]; /*ufd name*/ char ufdpword[8];/*ufd password*/ OSUFD_LOGIN;
typedef struct /*file open mode*/int ifopen; /*ifopen:0-close,1-open*/ int openmode;/*0-read only,1-write only,2-read and write,3-initial*/OSUFD_OPENMODE;
OSUFD *ufd[MAXCHILD];/*ufd and ufd own files*/
OSUFD_LOGIN ufd_lp;
int ucount0; /*the count of mfds ufds*/
int fcount[MAXCHILD]; /*the count of ufds files*/
int loginsuc0; /*whether login successfully*/
char username[MAXNAME]; /*record login users name22*/
char dirname[MAXNAME];/*record current directory*/
int fpaddrno[MAX]; /*record file physical address num*/
OSUFD_OPENMODE ifopen[MAXCHILD][MAXCHILD]; /*record file open/close*/
int wgetchar; /*whether getchar*/
FILE *fp_mfd,*fp_ufd,*fp_file_p,*fp_file;
void main
int i,j,choice1;
char choice[50]; /*choice operation:dir,create,delete,open,delete,modify,read,write*/
int choiceend1; /*whether choice end*/
char *rtrimchar *str; /*remove the trailing blanks.*/
char *ltrimchar *str;
文档评论(0)