欢迎来到冰点文库! | 帮助中心 分享价值,成长自我!
冰点文库
全部分类
  • 临时分类>
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • ImageVerifierCode 换一换
    首页 冰点文库 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    操作系统课程设计--二级文件系统设计.docx

    • 资源ID:567541       资源大小:98.28KB        全文页数:40页
    • 资源格式: DOCX        下载积分:3金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要3金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    操作系统课程设计--二级文件系统设计.docx

    1、操作系统课程设计报告专 业 : 学 号 : 姓 名 : 提交日期:操作系统课程设计报告【设计题目】二级文件系统设计【设计目的】1、本实验的目的是通过一个简单多用户文件系统的设计,加深理解文件系统的内部功能和内部实现。2、结合数据结构、程序设计、计算机原理等课程的知识,设计一个二级文件系统,进一步理解操作系统。3、通过分对实际问题的分析、设计、编程实现,提高学生实际应用、编程的能力.【设计内容】一、任务为 Linux 系统设计一个简单的二级文件系统。要求做到以下几点:1. 可以实现下列几条命令: login 用 户 登 录dir 列 目 录create 创 建 文 件delete 删 除 文 件

    2、open 打 开 文 件close 关 闭 文 件read 读 文 件write 写 文 件cd 进 出 目 录2. 列目录时要列出文件名,物理地址,保护码和文件长度3. 源文件可以进行读写保护二、程序设计设计思想本文件系统采用两级目录,其中第一级对应于用户账号,第二级对应于用户帐号下的文件。另外,为了简便文件系统未考虑文件共享,文件系统安全以及管道文件与设备文件等特殊内容。首先应确定文件系统的数据结构:主目录、子目录及活动文件等。主目录和子目录都以文件的形式存放于磁盘,这样便于查找和修改。用户创建的文件,可以编号存储于磁盘上。如:file0,file1,file2并以编号作为物理地址,在目录

    3、中进行登记【实验环境】C+/VC+【设计原理】对采用二级文件目录的文件系统工作的机理了如指掌,对文件系统的相关操作要掌握。【设计思路】1. 主要数据结构#defineMAXNAME 25 /*the largest length of mfdname,ufdname,filename*/ #defineMAXCHILD 50 /*the largest child 每个用户名下最多有50个文件*/ #defineMAX (MAXCHILD*MAXCHILD) /*the size of fpaddrno*/typedef struct /*the structure of OSFILE 定义主

    4、文件*/ 39int fpaddr; /*file physical address*/ int flength; /*file length*/ int fmode; /*file mode:0-Read Only;1-Write Only;2-Read and Write; 3-Protect;*/ charfnameMAXNAME; /*file name*/ OSFILE; typedef struct/*the structure of OSUFD 定义用户文件目录*/ charufdnameMAXNAME; /*ufd name*/OSFILE ufdfileMAXCHILD; /

    5、*ufd own file*/OSUFD; typedef struct /*the structure of OSUFDLOGIN 定义登陆*/ charufdnameMAXNAME; /*ufd name*/ charufdpword8; /*ufd password*/ OSUFD_LOGIN; typedef struct/*file open mode 定义操作方式*/ intifopen; /*ifopen:0-close,1-open*/ intopenmode; /*0-read only,1-write only,2-read and write,3-initial*/OSU

    6、FD_OPENMODE; 2. 主要函数voidLoginF(); /*LOGIN FileSystem*/ voidDirF(); /*Dir FileSystem*/ voidCreateF(); /*Create File*/ voidDeleteF(); /*Delete File*/ voidModifyFM(); /*Modify FileMode*/ voidOpenF(); /*Open File*/ voidCloseF(); /*Close File*/ voidReadF(); /*Read File*/ voidWriteF(); /*Write File*/ void

    7、QuitF(); /*Quit FileSystem*/ voidCdF(); /*Change Dir*/ voidhelp(); 3. 程序流程设计总体功能程序结构图开始注册账号登录选择操作结束列目创建删除打开关闭读文写文进出录文件文件文件文件件件目录打开命令的程序流程图开始输入文件内容是否存在是否是否打开出现错误是是打开文件结束删除命令的程序流程图开始输入文件内容是否存在是否是否关闭出现错误否是删除文件结束关闭命令的程序流程图开始输入文件内容是否存在是否是否关闭出现错误否是关闭文件结束写命令的程序流程图开始输入文件内容是否存在是否是否打开出现错误否是打开文件写入内容结束【源程序清单】#i

    8、nclude 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*/intfpaddr;/*file physical

    9、 address*/intflength;/*file length*/intfmode;/*file mode:0-Read Only;1-Write Only;2-Read and Write; 3-Protect;*/ 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

    10、 of OSUFDLOGIN*/char 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

    11、 ufd_lp;int 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

    12、_OPENMODE ifopenMAXCHILDMAXCHILD; /*record file open/close*/ int wgetchar; /*whether getchar()*/FILE *fp_mfd,*fp_ufd,*fp_file_p,*fp_file;void LoginF(); /*LOGIN FileSystem*/ void DirF(); /*Dir FileSystem*/void CdF(); /*Change Dir*/ void CreateF(); /*Create File*/ void DeleteF(); /*Delete File*/void M

    13、odifyFM(); /*Modify FileMode*/ void OpenF(); /*Open File*/void CloseF(); /*Close File*/ void ReadF(); /*Read File*/ void WriteF(); /*Write File*/void QuitF(); /*Quit FileSystem*/ void help();char *rtrim(char *str); /*remove the trailing blanks.*/ char *ltrim(char *str); /*remove the heading blanks.*

    14、/void InputPW(char *password); /*input password,use * replace*/void SetPANo(int RorW); /*Set physical address num*/int ExistD(char *dirname); /*Whether DirName Exist,Exist-i,Not Exist-0*/ int WriteF1(); /*write file*/int ExistF(char *filename); /*Whether FileName Exist,Exist-i,Not Exist-0*/ int Find

    15、PANo(); /*find out physical address num*/void clrscr()system(cls);void main()int i,choice1;char choice50; /*choice operation:dir,create,delete,open,delete,modify,read,write*/ int choiceend=1; /*whether choice end*/char *rtrim(char *str); /*remove the trailing blanks.*/ char *ltrim(char *str); /*remo

    16、ve the heading blanks.*/if(fp_mfd=fopen(c:osfilemfd.txt,rb)=NULL)fp_mfd=fopen(c:osfilemfd.txt,wb); fclose(fp_mfd);for(i=0;i,strupr(dirname);elseprintf(Bad command or file name.nC:%s,strupr(username); gets(choice);strcpy(choice,ltrim(rtrim(strlwr(choice);if (strcmp(choice,dir)=0) choice1=1;else if(st

    17、rcmp(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(choice,close)=0) choice1=6; else if(strcmp(choice,read)=0) choice1=7; else if(strcmp(choice,write)=0) choice1=8; else if(

    18、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;switch(choice1)elsecase 1:DirF();choiceend=1;break;case 2:CreateF();choiceend=1;if(!wgetchar) getchar();break; case 3:Delete

    19、F();choiceend=1;if(!wgetchar)getchar();break; case 4:ModifyFM();choiceend=1;if(!wgetchar) getchar();break; case 5:OpenF();choiceend=1;if (!wgetchar) getchar();break; case 6:CloseF();choiceend=1;if (!wgetchar) getchar();break; case 7:ReadF();choiceend=1;if (!wgetchar) getchar();break; case 8:WriteF()

    20、;choiceend=1;if (!wgetchar) getchar();break; case 9:printf(nYou have exited this system.);QuitF();exit(0);break;case 10:clrscr();choiceend=1;break; case 11:CdF();choiceend=1;break; case 20:help();choiceend=1;break; default:choiceend=0;printf(nAccess denied.);void help(void)printf(nThe Command Listn)

    21、;printf(nCd Attrib CreatewriteReadOpenClsDeleteExitClosen);char *rtrim(char *str) /*remove the trailing blanks.*/int n=strlen(str)-1; while(n=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

    22、,fp_ufd)!=0;i+,fcountj+)ifopenji.ifopen=0; ifopenji.openmode=4;fclose(fp_ufd);fclose(fp_mfd); ucount=j;elseSetPANo(0);printf(nnLogin successful! Welcome to this FileSystemnn); loginsuc=1;return;printf(nn); flag=1; while(flag)printf(Login Failed! Password Error. Try Again(Y/N):); gets(a);ltrim(rtrim(

    23、a);if (strcmp(strupr(a),Y)=0)loginsuc=0; flag=0;else if(strcmp(strupr(a),N)=0)elseloginsuc=0; flag=0; return;printf(New Password(=8):);InputPW(loginpw); /*input new password,use * replace*/ printf(nConfirm Password(=8):); /*input new password,use * replace*/ InputPW(logincpw);if (strcmp(loginpw,logi

    24、ncpw)=0)strcpy(ufd_lp.ufdname,strupr(loginame); strcpy(ufd_lp.ufdpword,loginpw); fp_mfd=fopen(c:osfilemfd.txt,ab); fwrite(&ufd_lp,sizeof(OSUFD_LOGIN),1,fp_mfd); fclose(fp_mfd);strcpy(username,strupr(loginame); strcpy(dirname,loginame);/ strcpy(str,c:osfile); strcat(str,username);strcat(str,.txt); if(fp_ufd=fopen(str,rb)=NULL)fp_ufd=fopen(str,wb); fclose(fp_ufd);fp_mfd=fopen(c:osfilemfd.txt,rb); for(j=0;fread(&ufd_lp,sizeof(OSUFD_LOGIN),1,fp_mfd)!=0;j+)/ strcpy(str,c:osfile); strcat(s


    注意事项

    本文(操作系统课程设计--二级文件系统设计.docx)为本站会员主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2023 冰点文库 网站版权所有

    经营许可证编号:鄂ICP备19020893号-2


    收起
    展开