操作系统课程设计_模拟一个简单二级文件管理系统.doc

上传人:rrsccc 文档编号:9327471 上传时间:2021-02-19 格式:DOC 页数:17 大小:99.50KB
返回 下载 相关 举报
操作系统课程设计_模拟一个简单二级文件管理系统.doc_第1页
第1页 / 共17页
操作系统课程设计_模拟一个简单二级文件管理系统.doc_第2页
第2页 / 共17页
操作系统课程设计_模拟一个简单二级文件管理系统.doc_第3页
第3页 / 共17页
操作系统课程设计_模拟一个简单二级文件管理系统.doc_第4页
第4页 / 共17页
操作系统课程设计_模拟一个简单二级文件管理系统.doc_第5页
第5页 / 共17页
点击查看更多>>
资源描述

《操作系统课程设计_模拟一个简单二级文件管理系统.doc》由会员分享,可在线阅读,更多相关《操作系统课程设计_模拟一个简单二级文件管理系统.doc(17页珍藏版)》请在三一文库上搜索。

1、evaluation of scientific development. Nature security type-nature security is to maintenance people of health value for target, through strengthening security based management, and risk management, and equipment management and technology supervision, ensure production in the people, and real, and sy

2、stem, and system, elements security reliable, and harmony unified, full control various against factors, achieved thought no slack, and management no empty document, and equipment no hidden, and system no blocked, and unit zero non-stopped. Quality and efficiency-quality benefit is to adhere to the

3、enterprise survival, profit and development business truth, adhere to the all activity is economic activity, all costs can be controlled, money should not be wasted management philosophy, management analysis, to improve management quality, improve cost control capacity and market competitiveness. In

4、novation of science and technology-science and technology innovation is to play the role of science and technology as the primary productive force, active use of new technologies, new materials, new processes, new equipment, increase investment in science and technology, strengthening scientific and

5、 technological training, speeding up transforming scientific and technological achievements, forming a number of proprietary technology, enhancing core competitiveness. Resource-saving-the-resources saving enterprise was to reduce coal consumption, water consumption, electricity at the core, enhance

6、 the operation of lean management to realize low consumption, high efficiency, reduce production costs. Second is to strengthen the business, financial, material, information and the optimization of organization and management, saving the internal transaction costs. Harmonious development of harmoni

7、ous development-is to construct a foreign environment for development. XING refers to the internal security firm and internal management of the internal management measures are effective, harmonious. Foreign currency means Enterprise coordinating development of homeopathy, well, get along with the n

8、eighbors better. (B) XX 2013 five enterprises building intrinsic safety power company goals are: unplanned outage 0 times. Class of disorders 0, 0 is equivalent forced outage rate. No personal injury accident, material and equipment accidents do not occur, no fire, no environmental pollution acciden

9、t. Enterprise integrated to achieve zero cases of violation, zero accidents, zero. Quality goal is: when generating capacity 7.5 billion-kilowatt, sales of over 7.11 billion kWh, total profits of 306.6 million Yuan, . BFS+、PI、MIS、SCM Information systems infrastructure, fully integrated information s

10、ystem to realize information resources sharing; to expand the breadth and depth of the portal system, information system of Enterprise Management Assistant role to play; to improve the day-to-day operation and maintenance operation record of promoting causes and transfer system; to strengthen the tr

11、aining模拟一个简单二级文件管理系统设计目的:通过具体的文件存储空间的管理、文件的物理结构、目录结构和文件操作的实现,加深对文件系统内部功能和实现过程的理解。设计内容:模拟一个简单二级文件管理系统 一、实验内容描述1 实验目标本实验的目的是通过一个简单多用户文件系统的设计,加深理解文件系统的内部功能及内部实现.2 实验要求为DOS系统设计一个简单的二级文件系统.要求做到以下几点:可以实现下列命令:login 用户登录dir 列文件目录create 创建文件delete 删除文件open 打开文件close 关闭文件read 读文件write 写文件列目录时要列出文件名、物理地址、保护码和文

12、件长度.源文件可以进行读写保护.二、程序主要内容1设计思路程序中要求每个用户在登陆后才可对其拥有的文件进行操作,用户对于其他用户的文件无操作权.文件操作包括浏览、创建、删除、打开、关闭、阅读、写入、修改模式.其他操作包括新建用户、帮助、用户登入、用户登出、退出系统.在程序文件夹下有个名为“file”的系统根目录,此目录下包括:一个名为“mfd”的文件,记录所有注册过的帐号及密码;用户文件,以用户名作为文件名,内容为其拥有的文件名及属性;一个名为“keiji”的文件夹.“keiji”文件夹中包括:“file.p”指针文件,记录所有已用的物理地址;一些以物理地址为名的文件,内容为文件内容.2 数据

13、结构file结构体系统文件数据结构:fpaddrint,文件的物理地址、flengthint,文件长度、fmodeint,文件模式 0.只读;1.可写;2.可读写;3.保护、 fnamechar,文件名;filemode结构体文件状态数据结构:isopenint,文件当前状态,0.关闭;1.打开、modeint,文件模式 0.只读;1.可写;2.可读写;3.初始化;user结构体用户信息数据结构:unamechar,用户名、upasswordchar,用户密码;userfile结构体用户文件数据结构:unamechar,用户名、ufilefile,用户拥有的文件数组.代码:#include #

14、include #include #include #include #define MaxUser 100 /定义最大MDF主目录文件 #define MaxDisk 512*1024 /模拟最大磁盘空间 #define commandAmount 12 /对文件操作的指令数 /存储空间管理有关结构体和变量 char diskMaxDisk; /模拟512K的磁盘存储空间 typedef struct distTable /磁盘块结构体 int maxlength; int start; int useFlag; distTable *next; diskNode; diskNode *di

15、skHead; struct fileTable /文件块结构体 char fileName10; int strat; /文件在磁盘存储空间的起始地址 int length; /文件内容长度 int maxlength; /文件的最大长度 char fileKind3; /文件的属性读写方式 struct tm *timeinfo; bool openFlag; /判断是否有进程打开了该文件 /fileTable *next; ; /两级目录结构体 typedef struct user_file_directory /用户文件目录文件UFD /char fileName10; fileTa

16、ble *file; user_file_directory *next; UFD; /UFD *headFile; typedef struct master_file_directory /主文件目录MFD char userName10; char password10; UFD *user; MFD; MFD userTableMaxUser; int used=0; /定义MFD目录中用已有的用户数 /文件管理 void fileCreate(char fileName,int length,char fileKind); /创建文件 void fileWrite(char file

17、Name); /写文件 void fileCat(char fileName); /读文件 void fileRen(char fileName,char rename); /重命名文件 void fileFine(char fileName); /查询文件 void fileDir(char UserName); /显示某一用户的所有文件 void fileClose(char fileName); /关闭已打开的文件 void fileDel(char fileName); /删除文件 void chmod(char fileName,char kind); /修改文件的读写方式 int

18、requestDist(int &startPostion,int maxLength); /磁盘分配查询 void initDisk(); /初始化磁盘 void freeDisk(int startPostion); /磁盘空间释放 void diskShow(); /显示磁盘使用情况 /用户管理 void userCreate(); int login(); int userID=-1; /用户登录的ID号,值为-1时表示没有用户登录 int main() char ordercommandAmount10; strcpy(order0,create); strcpy(order1,rm

19、); strcpy(order2,cat); strcpy(order3,write); strcpy(order4,fine); strcpy(order5,chmod); strcpy(order6,ren); strcpy(order7,dir); strcpy(order8,close); strcpy(order9,return); strcpy(order10,exit); strcpy(order11,df); char command50,command_str110,command_str210,command_str35,command_str43; int i,k,j;

20、int length; initDisk(); /初始化磁盘 for(i=0;inext=NULL; while(1) printf(*n); printf( 1、Creat usern); printf( 2、loginn); printf(*n); printf(Please chooce the function key:); int choice; scanf(%d,&choice); if(choice=1) userCreate(); else if(choice=2) userID=login(); else printf(您的输入有误,请重新选择n); while(userID

21、!=-1) fflush(stdin); printf(n); printf( create-创建 格式:create a1 1000 rw,将创建名为a1,长度为1000字节可读可写的文件n); printf( rm-删除 格式:rm a1,将删除名为a1的文件n); printf( cat-查看文件内容 格式:cat a1,显示a1的内容n); printf( write-写入 格式:write a1n); printf( fine-查询 格式:fine a1 ,将显示文件 a1的属性n); printf( chmod-修改 格式:chmod a1 r,将文件a1的权限改为只读方式n);

22、printf( ren-重命名 格式:ren a1 b1 ,将a1改名为b1n); printf( dir-显示文件 格式:dir aaa,将显示aaa用户的所有文件n); printf( df-显示磁盘空间使用情况 格式:dfn); printf( close-关闭文件 格式:close a1,将关闭文件a1n); printf( return-退出用户,返回登录界面n); printf( exit-退出程序n); printf(n); printf(please imput your command:); gets(command); int select; for(i=0;command

23、i!= &commandi!=0;i+) /command_str1字符串存储命令的操作类型 command_str1i=commandi; k=i; command_str1k=0; for(i=0;i=0;i-) /把字符串转换为十进制 length+=(command_str3i-48)*j; j*=10; for(i=k+1,k=0;commandi!= &commandi!=0;i+,k+) command_str4k=commandi; command_str4k=0; fileCreate(command_str2,length,command_str4);break; case

24、 1:fileDel(command_str2);break; case 2:fileCat(command_str2);break; case 3: fileWrite(command_str2);break; case 4:fileFine(command_str2);break; case 5:for(i=k+1,k=0;commandi!= &commandi!=0;i+,k+) command_str3k=commandi; command_str3k=0; chmod(command_str2,command_str3);break; case 6:for(i=k+1,k=0;co

25、mmandi!=0;i+,k+) command_str3k=commandi; command_str3k=0; fileRen(command_str2,command_str3);break; case 7:fileDir(command_str2);break; case 8:fileClose(command_str2);break; case 9:UFD *p; for(p=userTableuserID.user-next;p!=NULL;p=p-next) /退出用户之前关闭所有打的文件 if(p-file-openFlag) p-file-openFlag=false; sy

26、stem(cls); userID=-1;break; case 10:exit(0);break; case 11:diskShow();break; return 0; void userCreate() char c; char userName10; int i; if(usedMaxUser) printf(请输入用户名:); for(i=0;c=getch();i+) if(c=13) break; else userNamei=c; printf(%c,c); userNamei=0; for(i=0;iused;i+) if(!strcmp(userTablei.userNam

27、e,userName) printf(n); printf(该用户名已存在,创建用户失败n); system(pause); return; strcpy(userTableused.userName,userName); printf(n); printf(请输入密码:); for(i=0;c=getch();i+) if(c=13) break; else userTableused.passwordi=c; printf(*); userTableuserID.passwordi=0; printf(n); printf(创建用户成功n); used+; system(pause); e

28、lse printf(创建用户失败,用户已达到上限n); system(pause); fflush(stdin); int login() char name10,psw10; char c; int i,times; printf(请输入用户名:); for(i=0;c=getch();i+) if(c=13) break; else namei=c; printf(%c,c); namei=0; for(i=0;iused;i+) if(!strcmp(userTablei.userName,name) break; if(i=used) printf(n您输入的用户名不存在n); sy

29、stem(pause); return -1; for(times=0;times3;times+) memset(psw,0,sizeof(psw); printf(n请输入密码:); for(i=0;c=getch();i+) if(c=13) break; else pswi=c; printf(*); printf(n); for(i=0;imaxlength=MaxDisk; diskHead-useFlag=0; diskHead-start=0; diskHead-next=NULL; int requestDist(int &startPostion,int maxLength

30、) int flag=0; /标记是否分配成功 diskNode *p,*q,*temp; p=diskHead; while(p) if(p-useFlag=0&p-maxlengthmaxLength) startPostion=p-start; q=(diskNode *)malloc(sizeof(diskNode); q-start=p-start; q-maxlength=maxLength; q-useFlag=1; q-next=NULL; diskHead-start=p-start+maxLength; diskHead-maxlength=p-maxlength-maxLength; flag=1; temp=p; if(diskHead-next=NULL) diskHead-next=q;

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

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1