操作系统二级文件系统(报告 源代码)天津科技大学

上传人:m**** 文档编号:385844125 上传时间:2023-07-16 格式:DOC 页数:42 大小:677KB
返回 下载 相关 举报
操作系统二级文件系统(报告 源代码)天津科技大学_第1页
第1页 / 共42页
操作系统二级文件系统(报告 源代码)天津科技大学_第2页
第2页 / 共42页
操作系统二级文件系统(报告 源代码)天津科技大学_第3页
第3页 / 共42页
操作系统二级文件系统(报告 源代码)天津科技大学_第4页
第4页 / 共42页
操作系统二级文件系统(报告 源代码)天津科技大学_第5页
第5页 / 共42页
点击查看更多>>
资源描述

《操作系统二级文件系统(报告 源代码)天津科技大学》由会员分享,可在线阅读,更多相关《操作系统二级文件系统(报告 源代码)天津科技大学(42页珍藏版)》请在金锄头文库上搜索。

1、操作系统课程设计报告11103303 程路峰操作系统课程设计报告专 业:软件工程学 号:11103303姓 名:程路峰提交日期:2014/1/2【设计目的】1、本实验的目的是通过一个简单多用户文件系统的设计,加深理解文件系统的内部功能和内部实现。2、结合数据结构、程序设计、计算机原理等课程的知识,设计一个二级文件系统,进一步理解操作系统。.【设计内容】为Linux系统设计一个简单的二级文件系统。要求做到以下几点:可以实现下列几条命令:login 用户登录dir 列目录 Attrib 修改文件属性create 创建文件delete 删除文件open 打开文件close 关闭文件read 读文件w

2、rite 写文件cd 进出目录列目录时要列出文件名,物理地址,保护码和文件长度源文件可以进行读写保护.【实验环境】Windows7操作平台Visual Studio2010【相关知识综述】理解二级目录的文件系统的组织;掌握常用的数据结构;系统采用两级目录,其中第一级对应于用户账号,第二级对应于用户帐号下的文件;使用文件来模拟外存,进行数据结构设计和操作算法的设计,实现一个文件系统并实现基本的文件操作(为了简便文件系统,不考虑文件共享,文件系统安全以及管道文件与设备文件等特殊内容)。【设计思路】采用的数据结构、主要的函数说明、程序流程设计等本文件系统采用两级目录,其中第一级对应于用户账号,第二级

3、对应于用户帐号下的文件。另外,为了简便文件系统未考虑文件共享,文件系统安全以及管道文件与设备文件等特殊内容。首先应确定文件系统的数据结构:主目录、子目录及活动文件等。主目录和子目录都以文件的形式存放于磁盘,这样便于查找和修改。用户创建的文件,可以编号存储于磁盘上。如:file0,file1,file2并以编号作为物理地址,在目录中进行登记1.主要的数据结构#define MAXNAME 25 /*the largest length of mfdname,ufdname,filename表示三种文件的长度都为25*/#define MAXCHILD 50 /*the largest child

4、每个用户下可以有50个文件*/#define MAX (MAXCHILD*MAXCHILD) /*the size of fpaddrno定义一个常量2500个扇区*/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 Write; 3-Protect;*/ char fnameMAXNAME; /

5、*file name文件名*/ OSFILE;typedef struct /*the structure of OSUFD*/char ufdnameMAXNAME; /*ufd name*/OSFILE ufdfileMAXCHILD; /*ufd own file*/OSUFD;/*osf文件的数据结构*/typedef struct /*the structure of OSUFDLOGIN*/char ufdnameMAXNAME; /*ufd name*/ char ufdpword8; /*ufd password*/ OSUFD_LOGIN;typedef struct /*f

6、ile 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;2.主要函数void LoginF(); /*LOGIN FileSystem*/void DirF(); /*Dir FileSystem*/void CdF(); /*Change Dir*/void CreateF(); /*Create File*/void DeleteF(); /*Delete File*/voi

7、d ModifyFM(); /*Modify FileMode*/void OpenF(); /*Open File*/void CloseF(); /*Close File*/void ReadF(); /*Read File*/void WriteF(); /*Write File*/void QuitF(); /*Quit FileSystem退出文件系统*/void help();3总体功能程序结构图打开命令的程序流程图 关闭命令的程序流程图写命令程序流程图 删除命令的程序流程图:【部分源程序清单】打开函数void OpenF() int fc,i;char fnameMAXNAME,

8、fmode25;int fm;printf(nPlease input FileName:);gets(fname);ltrim(rtrim(fname);if (ExistF(fname)0)printf(nError. Name %s is not existed.n,fname);wgetchar=1;elsei=ExistD(username);for(int a=0;aufdfilea.fname)=0)fc=a;break;ifopenifc.ifopen=1;printf(Please input OpenMode(0-Read Only, 1-Write Only, 2-Rea

9、d and Write, 3-Protect):);gets(fmode);fm=atoi(fmode);ifopenifc.openmode=fm;printf(nOpen successed);wgetchar=1;关闭函数void CloseF() char fnameMAXNAME;int i,k;if (strcmp(strupr(dirname),strupr(username)!=0) printf(nError.You can only modify filemode in yourself dir.n);elseprintf(nPlease input FileName:);

10、gets(fname);ltrim(rtrim(fname); i=ExistF(fname); if (i=0) k=ExistD(username); if(ifopenki.ifopen=0) printf(nError. %s has been closed. you can not close it again.n,fname);else ifopenki.ifopen=0; ifopenki.openmode=4; printf(%s has been closed successfully!,fname);else printf(nError. %s dose not exist

11、.n,fname);删除函数void DeleteF() /*Delete File*/char fnameMAXNAME,str50,str150;int i,k,j;int fpaddrno1;if (strcmp(strupr(ltrim(rtrim(dirname),)=0) printf(nError.Please convert to ufd dir before delete.n);wgetchar=1;if (strcmp(strupr(dirname),strupr(username)!=0) printf(nError.You can only modify filemod

12、e in yourself dir.n);wgetchar=1;elseprintf(nPlease input FileName:);gets(fname);ltrim(rtrim(fname);i=ExistF(fname);if (i=0)k=ExistD(username);if(ifopenki.ifopen=1)printf(nError.%s is in open status. Close it before delete.n,fname); wgetchar=1;elseif(ufdk-ufdfilei.fmode=3)printf(nError.%s is in protect status. Close it before delete.n,fname); wgetchar=1;elsefpaddrno1=ufdk-ufdfilei.fpaddr;fpaddrnofpaddrno1=0;for(j=i;jufdfilej=ufdk-ufdfilej+1;

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号