天津科技大学操作系统课程设计Word文档格式.docx

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

天津科技大学操作系统课程设计Word文档格式.docx

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

天津科技大学操作系统课程设计Word文档格式.docx

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定义登陆*/

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"

string.h"

conio.h"

stdlib.h"

#defineMAXCHILD50/*thelargestchild*/

typedefstruct/*thestructureofOSFILE*/

typedefstruct/*thestructureofOSUFD*/

LOGIN*/

typedefstruct/*fileopenmode*/

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;

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);

char*ltrim(char*str);

if((fp_mfd=fopen("

c:

\\osfile\\mfd.txt"

"

rb"

))==NULL)

{

fp_mfd=fopen("

wb"

fclose(fp_mfd);

}

for(i=0;

i<

MAX;

i++)fpaddrno[i]=0;

//textattr(BLACK*16|WHITE);

clrscr();

/*clearscreen*/

LoginF();

/*userlo

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

当前位置:首页 > 求职职场 > 简历

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

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