ImageVerifierCode 换一换
格式:DOCX , 页数:37 ,大小:33.07KB ,
资源ID:10913149      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/10913149.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(实验六文件资料系统设计结果.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

实验六文件资料系统设计结果.docx

1、实验六 文件资料系统设计结果实验六 文件系统设计1目的和要求本实验的目的是通过一个简单多用户文件系统的设计,加深理解文件系统的内部功能和内部实现。2实验内容为DOS系统设计一个简单的二级文件系统,可以实现下列几条命令DIR 列文件目录CREATE 创建文件DELETE 删除文件MODIFY 修改文件OPEN 打开文件CLOSE 关闭文件列目录时要列出文件名,物理地址,保护码和文件长度。3实验环境PC兼容机Windows、DOS系统、Turbo c 2.0C语言4实验提示首先应确定文件系统的数据结构:主目录、活动文件等。主目录文件的形式存放于磁盘,这样便于查找和修改。主目录结构:Ufdname

2、用户名 Ufdfile 指向用户的活动文件活动文件结构:Fpaddr 文件物理地址 Flength 文件长度 Fmode 文件属性(file mode:0-Read Only;1-Write Only;2-Read and Write(default)) Fname 文件名称用户创建的文件,可以编号存储于磁盘上。如:file0,file1,file2并以编号作为物理地址,在目录中进行登记。本程序需要在c:下建一个名为osfile的目录及一个名为file的子目录,在利用程序创建了文件系统后,可以在这个文件夹下查看到相关的内容。5实验程序#include stdio.h#include strin

3、g.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; /*fi

4、le length*/ int fmode; /*file mode:0-Read Only;1-Write Only;2-Read and Write(default);*/ char fnameMAXNAME; /*file name*/ OSFILE;typedef struct /*the structure of OSUFD*/ char ufdnameMAXNAME; /*ufd name*/ OSFILE ufdfileMAXCHILD; /*ufd own file*/OSUFD;typedef struct /*the structure of OSUFDLOGIN*/ ch

5、ar ufdnameMAXNAME; /*ufd name*/ char ufdpword8; /*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 *ufdMAXCHILD; /*ufd and ufd own files*/OSUFD_LOGIN ufd_lp;int

6、 ucount=0; /*the count of mfds ufds*/int fcountMAXCHILD; /*the count of ufds files*/int loginsuc=0; /*whether login successfully*/char usernameMAXNAME; /*record login users name22*/char dirnameMAXNAME;/*record current directory*/int fpaddrnoMAX; /*record file physical address num*/OSUFD_OPENMODE ifo

7、penMAXCHILDMAXCHILD; /*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 choice50; /*choice operation:dir,create,delete,open,delete,modify,read,write*/ int choiceend=1; /*whether choice end*/ char *rtrim(char *str);

8、/*remove the trailing blanks.*/ char *ltrim(char *str); /*remove the heading blanks.*/ void LoginF(); /*LOGIN FileSystem*/ void DirF(); /*Dir FileSystem*/ void CdF(); /*Change Dir*/ void CreateF(); /*Create File*/ void DeleteF(); /*Delete File*/ void ModifyFM(); /*Modify FileMode*/ void OpenF(); /*O

9、pen File*/ void CloseF(); /*Close File*/ void ReadF(); /*Read File*/ void WriteF(); /*Write File*/ void QuitF(); /*Quit FileSystem*/ void help(); if(fp_mfd=fopen(c:osfilemfd,rb)=NULL) fp_mfd=fopen(c:osfilemfd,wb); fclose(fp_mfd); for(i=0;i,strupr(dirname); else printf(Bad command or file name.nC:%s,

10、strupr(username); gets(choice); strcpy(choice,ltrim(rtrim(strlwr(choice); if (strcmp(choice,dir)=0) choice1=1; else if(strcmp(choice,create)=0) choice1=2; else if(strcmp(choice,delete)=0) choice1=3; else if(strcmp(choice,attrib)=0) choice1=4; else if(strcmp(choice,open)=0) choice1=5; else if(strcmp(

11、choice,close)=0) choice1=6; else if(strcmp(choice,read)=0) choice1=7; else if(strcmp(choice,modify)=0) choice1=8; else if(strcmp(choice,exit)=0) choice1=9; else if(strcmp(choice,cls)=0) choice1=10; else if(strcmp(choice,cd)=0) choice1=11; else if(strcmp(choice,help)=0) choice1=20; else choice1=12; s

12、witch(choice1) case 1:DirF();choiceend=1;break; case 2:CreateF();choiceend=1;if(!wgetchar) getchar();break; case 3:DeleteF();choiceend=1;if(!wgetchar)getchar();break; case 4:ModifyFM();choiceend=1;if(!wgetchar) getchar();break; case 5:choiceend=1;OpenF();if (!wgetchar) getchar();break; case 6:choice

13、end=1;CloseF();if (!wgetchar) getchar();break; case 7:choiceend=1;ReadF();if (!wgetchar) getchar();break; case 8:choiceend=1;WriteF();if (!wgetchar) getchar();break; case 9:printf(nYou have exited this system.); QuitF();exit(0);break; case 10:choiceend=1;clrscr();break; case 11:CdF();choiceend=1;bre

14、ak; case 20:help();choiceend=1;break; default:choiceend=0; else printf(nAccess denied.);void help(void) printf(nThe Command Listn); /*printf(nCd Attrib Create Modify Read Open Cls Delete Exit Closen);*/ printf(Create : Create a file(You can initialize files attribute and content.)n); printf(Open : O

15、pen a file to modifyn); printf(Close : Close a file.n); printf(Modify : Modify the opened file.n); printf(Delete : Delete existed files.n); printf(CD : Change current directory.n); printf(Exit : Exit this program.n);char *rtrim(char *str) /*remove the trailing blanks.*/ int n=strlen(str)-1; while(n=

16、0) if(*(str+n)!= ) *(str+n+1)=0; break; else n-; if (nufdname,strupr(ufd_lp.ufdname); fp_ufd=fopen(str,rb); fcountj=0; for(i=0;fread(&ufdj-ufdfilei,sizeof(OSFILE),1,fp_ufd)!=0;i+,fcountj+) ifopenji.ifopen=0; ifopenji.openmode=4; fclose(fp_ufd); fclose(fp_mfd); ucount=j; SetPANo(0); printf(nnLogin su

17、ccessful! Welcome to this FileSystemnn); loginsuc=1; return; else printf(nn); flag=1; while(flag) printf(Login Failed! Password Error. Try Again(Y/N):); gets(a); ltrim(rtrim(a); if (strcmp(strupr(a),Y)=0) loginsuc=0;flag=0; else if(strcmp(strupr(a),N)=0)loginsuc=0;flag=0;return; else printf(New Pass

18、word(=8):); InputPW(loginpw); /*input new password,use * replace*/ printf(nConfirm Password(ufdname,strupr(ufd_lp.ufdname); fp_ufd=fopen(str,rb); for(i=0;fread(&ufdj-ufdfilei,sizeof(OSFILE),1,fp_ufd)!=0;i+,fcountj+) ifopenji.ifopen=0; ifopenji.openmode=4; fclose(fp_ufd); fclose(fp_mfd); ucount=j; Se

19、tPANo(0); printf(nnLogin Successful! Welcome to this Systemnn); loginsuc=1; return; else printf(nn); flag=1; while(flag) printf(Login Failed! Password Error. Try Again(Y/N):); gets(a); ltrim(rtrim(a); if (strcmp(strupr(a),Y)=0) loginsuc=0;flag=0; else if(strcmp(strupr(a),N)=0)loginsuc=0;flag=0;retur

20、n; void SetPANo(int RorW) /*Set physical address num,0-read,1-write*/ int i,j; if (RorW=0) if(fp_file_p=fopen(c:osfilefilefile_p,rb)=NULL) fp_file_p=fopen(c:osfilefilefile_p,wb); fclose(fp_file_p); fp_file_p=fopen(c:osfilefilefile_p,rb); for(i=0;fread(&j,sizeof(int),1,fp_file_p)!=0;i+) fpaddrnoj=1;

21、/*for(i=1;iMAX;i+) if (i%13)=0) fpaddrnoi=1;*/ else fp_file_p=fopen(c:osfilefilefile_p,wb); /*for(i=1;iMAX;i+) if(i%13)=0) fpaddrnoi=0;*/ for(i=0;iMAX;i+) if (fpaddrnoi=1) fwrite(&i,sizeof(int),1,fp_file_p); fclose(fp_file_p);void InputPW(char *password) /*input password,use * replace*/ int j; for(j=0;j=7;j+)

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1