天津科技大学操作系统课程设计.docx

上传人:b****5 文档编号:2961286 上传时间:2022-11-16 格式:DOCX 页数:48 大小:210.41KB
下载 相关 举报
天津科技大学操作系统课程设计.docx_第1页
第1页 / 共48页
天津科技大学操作系统课程设计.docx_第2页
第2页 / 共48页
天津科技大学操作系统课程设计.docx_第3页
第3页 / 共48页
天津科技大学操作系统课程设计.docx_第4页
第4页 / 共48页
天津科技大学操作系统课程设计.docx_第5页
第5页 / 共48页
点击查看更多>>
下载资源
资源描述

天津科技大学操作系统课程设计.docx

《天津科技大学操作系统课程设计.docx》由会员分享,可在线阅读,更多相关《天津科技大学操作系统课程设计.docx(48页珍藏版)》请在冰豆网上搜索。

天津科技大学操作系统课程设计.docx

天津科技大学操作系统课程设计

 

操作系统课程设计报告

 

专业:

学号:

姓名:

提交日期:

 

【设计题目】

二级文件系统设计

【设计目的】

1、本实验的目的是通过一个简单多用户文件系统的设计,加深理解文件系统的内部功能和内部实现。

2、结合数据结构、程序设计、计算机原理等课程的知识,设计一个二级文件系统,进一步理解操作系统。

3、通过分对实际问题的分析、设计、编程实现,提高学生实际应用、编程的能力.

【设计内容】

一、任务

为Linux系统设计一个简单的二级文件系统。

要求做到以下几点:

1.可以实现下列几条命令:

login用户登录

dir列目录

create创建文件

delete删除文件

open打开文件

close关闭文件

read读文件

write写文件

cd进出目录

2.列目录时要列出文件名,物理地址,保护码和文件长度

3.源文件可以进行读写保护

二、程序设计

设计思想

本文件系统采用两级目录,其中第一级对应于用户账号,第二级对应于用户帐号下的文件。

另外,为了简便文件系统未考虑文件共享,文件系统安全以及管道文件与设备文件等特殊内容。

首先应确定文件系统的数据结构:

主目录、子目录及活动文件等。

主目录和子目录都以文件的形式存放于磁盘,这样便于查找和修改。

用户创建的文件,可以编号存储于磁盘上。

如:

file0,file1,file2…并以编号作为物理地址,在目录中进行登记

【实验环境】

C++/VC++

【设计原理】

对采用二级文件目录的文件系统工作的机理了如指掌,对文件系统的相关操作要掌握。

【设计思路】

1.主要数据结构

#defineMAXNAME25/*thelargestlengthofmfdname,ufdname,filename*/

#defineMAXCHILD50/*thelargestchild每个用户名下最多有50个文件*/

#defineMAX(MAXCHILD*MAXCHILD)/*thesizeoffpaddrno*/

typedefstruct/*thestructureofOSFILE定义主文件*/

{

intfpaddr;/*filephysicaladdress*/

intflength;/*filelength*/

intfmode;/*filemode:

0-ReadOnly;1-WriteOnly;2-ReadandWrite;3-Protect;*/

charfname[MAXNAME];/*filename*/

}OSFILE;

typedefstruct/*thestructureofOSUFD定义用户文件目录*/

{

charufdname[MAXNAME];/*ufdname*/

OSFILEufdfile[MAXCHILD];/*ufdownfile*/

}OSUFD;

typedefstruct/*thestructureofOSUFD'LOGIN定义登陆*/

{

charufdname[MAXNAME];/*ufdname*/

charufdpword[8];/*ufdpassword*/

}OSUFD_LOGIN;

typedefstruct/*fileopenmode定义操作方式*/

{

intifopen;/*ifopen:

0-close,1-open*/

intopenmode;/*0-readonly,1-writeonly,2-readandwrite,3-initial*/

}OSUFD_OPENMODE;

2.主要函数

voidLoginF();/*LOGINFileSystem*/

voidDirF();/*DirFileSystem*/

voidCreateF();/*CreateFile*/

voidDeleteF();/*DeleteFile*/

voidModifyFM();/*ModifyFileMode*/

voidOpenF();/*OpenFile*/

voidCloseF();/*CloseFile*/

voidReadF();/*ReadFile*/

voidWriteF();/*WriteFile*/

voidQuitF();/*QuitFileSystem*/

voidCdF();/*ChangeDir*/

voidhelp();

3.程序流程设计

总体功能程序结构图

打开命令的程序流程图

 

删除命令的程序流程图

关闭命令的程序流程图

写命令的程序流程图

【源程序清单】

#include"stdio.h"

#include"string.h"

#include"conio.h"

#include"stdlib.h"

#defineMAXNAME25/*thelargestlengthofmfdname,ufdname,filename*/

#defineMAXCHILD50/*thelargestchild*/

#defineMAX(MAXCHILD*MAXCHILD)/*thesizeoffpaddrno*/

typedefstruct/*thestructureofOSFILE*/

{

intfpaddr;/*filephysicaladdress*/

intflength;/*filelength*/

intfmode;/*filemode:

0-ReadOnly;1-WriteOnly;2-ReadandWrite;3-Protect;*/

charfname[MAXNAME];/*filename*/

}OSFILE;

typedefstruct/*thestructureofOSUFD*/

{

charufdname[MAXNAME];/*ufdname*/

OSFILEufdfile[MAXCHILD];/*ufdownfile*/

}OSUFD;

typedefstruct/*thestructureofOSUFD'LOGIN*/

{

charufdname[MAXNAME];/*ufdname*/

charufdpword[8];/*ufdpassword*/

}OSUFD_LOGIN;

typedefstruct/*fileopenmode*/

{

intifopen;/*ifopen:

0-close,1-open*/

intopenmode;/*0-readonly,1-writeonly,2-readandwrite,3-initial*/

}OSUFD_OPENMODE;

OSUFD*ufd[MAXCHILD];/*ufdandufdownfiles*/

OSUFD_LOGINufd_lp;

intucount=0;/*thecountofmfd'sufds*/

intfcount[MAXCHILD];/*thecountofufd'sfiles*/

intloginsuc=0;/*whetherloginsuccessfully*/

charusername[MAXNAME];/*recordloginuser'sname22*/

chardirname[MAXNAME];/*recordcurrentdirectory*/

intfpaddrno[MAX];/*recordfilephysicaladdressnum*/

OSUFD_OPENMODEifopen[MAXCHILD][MAXCHILD];/*recordfileopen/close*/

intwgetchar;/*whethergetchar()*/

FILE*fp_mfd,*fp_ufd,*fp_file_p,*fp_file;

voidLoginF();/*LOGINFileSystem*/

voidDirF();/*DirFileSystem*/

voidCdF();/*ChangeDir*/

voidCreateF();/*CreateFile*/

voidDeleteF();/*DeleteFile*/

voidModifyFM();/*ModifyFileMode*/

voidOpenF();/*OpenFile*/

voidCloseF();/*CloseFile*/

voidReadF();/*ReadFile*/

voidWriteF();/*WriteFile*/

voidQuitF();/*QuitFileSystem*/

voidhelp();

char*rtrim(char*str);/*removethetrailingblanks.*/

char*ltrim(char*str);/*removetheheadingblanks.*/

voidInputPW(char*password);/*inputpassword,use'*'replace*/

voidSetPANo(intRorW);/*Setphysicaladdressnum*/

intExistD(char*dirname);/*WhetherDirNameExist,Exist-i,NotExist-0*/

intWriteF1();/*writefile*/

intExistF(char*filename);/*WhetherFileNameExist,Exist-i,NotExist-0*/

intFindPANo();/*findoutphysicaladdressnum*/

 

voidclrscr()

{

system("cls");

}

voidmain()

{

inti,choice1;

charchoice[50];/*choiceoperation:

dir,create,delete,open,delete,modify,read,write*/

intchoiceend=1;/*whetherchoiceend*/

char*rtrim(char*str);/*removethetrailingblanks.*/

char*ltrim(char*str);/*removetheheadingblanks.*/

if((fp_mfd=fopen("c:

\\osfile\\mfd.txt","rb"))==NULL)

{

fp_mfd=fopen("c:

\\osfile\\mfd.txt","wb");

fclose(fp_mfd);

}

for(i=0;i

//textattr(BLACK*16|WHITE);

clrscr();/*clearscreen*/

LoginF();/*userlo

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 表格模板 > 合同协议

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

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