




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
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 ma
4、rket competitiveness. innovation 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, stre
5、ngthening scientific and 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, electric
6、ity at the core, enhance 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. harmoniou
7、s development of harmonious 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 "
8、;enterprise coordinating development of homeopathy, well, get along with the neighbors 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, materi
9、al and equipment accidents do not occur, no fire, no environmental pollution accident. 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,
10、. bfs+、pi、mis、scm information systems infrastructure, fully integrated information system 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 mainte
11、nance operation record of promoting causes and transfer system; to strengthen the training模擬一個簡單二級文件管理系統(tǒng)設計目的:通過具體的文件存儲空間的管理、文件的物理結構、目錄結構和文件操作的實現(xiàn),加深對文件系統(tǒng)內部功能和實現(xiàn)過程的理解。設計內容:模擬一個簡單二級文件管理系統(tǒng) 一、實驗內容描述1 實驗目標本實驗的目的是通過一個簡單多用戶文件系統(tǒng)的設計,加深理解文件系統(tǒng)的內部功能及內部實現(xiàn).2 實驗要求為dos系統(tǒng)設計一個簡單的二級文件系統(tǒng).要求做到以下幾點:可以實現(xiàn)下列命令:login 用戶登錄dir
12、列文件目錄create 創(chuàng)建文件delete 刪除文件open 打開文件close 關閉文件read 讀文件write 寫文件列目錄時要列出文件名、物理地址、保護碼和文件長度.源文件可以進行讀寫保護.二、程序主要內容1設計思路程序中要求每個用戶在登陸后才可對其擁有的文件進行操作,用戶對于其他用戶的文件無操作權.文件操作包括瀏覽、創(chuàng)建、刪除、打開、關閉、閱讀、寫入、修改模式.其他操作包括新建用戶、幫助、用戶登入、用戶登出、退出系統(tǒng).在程序文件夾下有個名為“file”的系統(tǒng)根目錄,此目錄下包括:一個名為“mfd”的文件,記錄所有注冊過的帳號及密碼;用戶文件,以用戶名作為文件名,內容為其擁有的文件名
13、及屬性;一個名為“keiji”的文件夾.“keiji”文件夾中包括:“file.p”指針文件,記錄所有已用的物理地址;一些以物理地址為名的文件,內容為文件內容.2 數(shù)據(jù)結構file結構體系統(tǒng)文件數(shù)據(jù)結構:fpaddrint,文件的物理地址、flengthint,文件長度、fmodeint,文件模式 0.只讀;1.可寫;2.可讀寫;3.保護、 fnamechar,文件名;filemode結構體文件狀態(tài)數(shù)據(jù)結構:isopenint,文件當前狀態(tài),0.關閉;1.打開、modeint,文件模式 0.只讀;1.可寫;2.可讀寫;3.初始化;user結構體用戶信息數(shù)據(jù)結構:unamechar,用戶名、up
14、asswordchar,用戶密碼;userfile結構體用戶文件數(shù)據(jù)結構:unamechar,用戶名、ufilefile,用戶擁有的文件數(shù)組.代碼:#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <time.h> #include <string.h> #define maxuser 100 /定義最大mdf主目錄文件 #define maxdisk 512*1024 /模擬最大磁盤空間 #define commandamount 12 /對文件操作
15、的指令數(shù) /存儲空間管理有關結構體和變量 char diskmaxdisk; /模擬512k的磁盤存儲空間 typedef struct disttable /磁盤塊結構體 int maxlength; int start; int useflag; disttable *next; disknode; disknode *diskhead; struct filetable /文件塊結構體 char filename10; int strat; /文件在磁盤存儲空間的起始地址 int length; /文件內容長度 int maxlength; /文件的最大長度 char filekind3
16、; /文件的屬性讀寫方式 struct tm *timeinfo; bool openflag; /判斷是否有進程打開了該文件 /filetable *next; ; /兩級目錄結構體 typedef struct user_file_directory /用戶文件目錄文件ufd /char filename10; filetable *file; user_file_directory *next; ufd; /ufd *headfile; typedef struct master_file_directory /主文件目錄mfd char username10; char passwor
17、d10; ufd *user; mfd; mfd usertablemaxuser; int used=0; /定義mfd目錄中用已有的用戶數(shù) /文件管理 void filecreate(char filename,int length,char filekind); /創(chuàng)建文件 void filewrite(char filename); /寫文件 void filecat(char filename); /讀文件 void fileren(char filename,char rename); /重命名文件 void filefine(char filename); /查詢文件 void
18、filedir(char username); /顯示某一用戶的所有文件 void fileclose(char filename); /關閉已打開的文件 void filedel(char filename); /刪除文件 void chmod(char filename,char kind); /修改文件的讀寫方式 int requestdist(int &startpostion,int maxlength); /磁盤分配查詢 void initdisk(); /初始化磁盤 void freedisk(int startpostion); /磁盤空間釋放 void disksho
19、w(); /顯示磁盤使用情況 /用戶管理 void usercreate(); int login(); int userid=-1; /用戶登錄的id號,值為-1時表示沒有用戶登錄 int main() char ordercommandamount10; strcpy(order0,"create"); strcpy(order1,"rm"); strcpy(order2,"cat"); strcpy(order3,"write"); strcpy(order4,"fine"); strcp
20、y(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
21、; int i,k,j; int length; initdisk(); /初始化磁盤 for(i=0;i<maxuser;i+) /初始化用戶ufd目錄文件的頭指針 usertablei.user=(ufd *)malloc(sizeof(ufd); usertablei.user->next=null; while(1) printf("*n"); printf(" 1、creat usern"); printf(" 2、loginn"); printf("*n"); printf("pl
22、ease chooce the function key:>"); int choice; scanf("%d",&choice); if(choice=1) usercreate(); else if(choice=2) userid=login(); else printf("您的輸入有誤,請重新選擇n"); while(userid!=-1) fflush(stdin); printf("n"); printf(" create-創(chuàng)建 格式:create a1 1000 rw,將創(chuàng)建名為a1,長
23、度為1000字節(jié)可讀可寫的文件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"); printf("
24、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(&
25、quot;please imput your command:>"); gets(command); int select; for(i=0;commandi!=' '&&commandi!='0'i+) /command_str1字符串存儲命令的操作類型 command_str1i=commandi; k=i; command_str1k='0' for(i=0;i<commandamount;i+) if(!strcmp(command_str1,orderi) select=i; break; if(i
26、=commandamount) printf("您輸入的命令有誤,請重新輸入n"); continue; for(i=k+1,k=0;commandi!=' '&&commandi!='0'i+,k+) /commmand_str2字符串存儲文件名或用戶名 command_str2k=commandi; command_str2k='0' k=i; switch(select) case 0:for(i=k+1,k=0;commandi!=' 'i+,k+) command_str3k=comm
27、andi; command_str3k='0' k=i; j=1; length=0; /初始化文件長度 for(i=strlen(command_str3)-1;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,le
28、ngth,command_str4);break; case 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
29、39; chmod(command_str2,command_str3);break; case 6:for(i=k+1,k=0;commandi!='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
30、->next;p!=null;p=p->next) /退出用戶之前關閉所有打的文件 if(p->file->openflag) p->file->openflag=false; system("cls"); userid=-1;break; case 10:exit(0);break; case 11:diskshow();break; return 0; void usercreate() char c; char username10; int i; if(used<maxuser) printf("請輸入用戶名:&q
31、uot;); for(i=0;c=getch();i+) if(c=13) break; else usernamei=c; printf("%c",c); usernamei='0' for(i=0;i<used;i+) if(!strcmp(usertablei.username,username) printf("n"); printf("該用戶名已存在,創(chuàng)建用戶失敗n"); system("pause"); return; strcpy(usertableused.username,u
32、sername); printf("n"); printf("請輸入密碼:"); for(i=0;c=getch();i+) if(c=13) break; else usertableused.passwordi=c; printf("*"); usertableuserid.passwordi='0' printf("n"); printf("創(chuàng)建用戶成功n"); used+; system("pause"); else printf("創(chuàng)建用戶
33、失敗,用戶已達到上限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;i<used;i+) if(!strcmp(usertablei.username,name) br
34、eak; if(i=used) printf("n您輸入的用戶名不存在n"); system("pause"); return -1; for(times=0;times<3;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;i<used;i
35、+) if(!strcmp(psw,usertablei.password) printf("用戶登錄成功n"); system("pause"); break; if(i=used) printf("您輸入的密碼錯誤,您還有%d次輸入機會n",2-times); if(times=2) exit(0); else break; fflush(stdin); return i; void initdisk() diskhead=(disknode *)malloc(sizeof(disknode); diskhead->maxl
36、ength=maxdisk; diskhead->useflag=0; diskhead->start=0; diskhead->next=null; int requestdist(int &startpostion,int maxlength) int flag=0; /標記是否分配成功 disknode *p,*q,*temp; p=diskhead; while(p) if(p->useflag=0&&p->maxlength>maxlength) startpostion=p->start; q=(disknode *
37、)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; else while(temp->next) temp=t
38、emp->next; temp->next=q; break; p=p->next; return flag; void filecreate(char filename,int length,char filekind) /int i,j; time_t rawtime; int startpos; ufd *filenode,*p; for(p=usertableuserid.user->next;p!=null;p=p->next) if(!strcmp(p->file->filename,filename) printf("文件重名,
39、創(chuàng)建文件失敗n"); system("pause"); return; if(requestdist(startpos,length) filenode=(ufd *)malloc(sizeof(ufd); filenode->file=(filetable *)malloc(sizeof(filetable); /這一步必不可少,因為filenode里面的指針也需要申請地址,否則filenode->file指向會出錯 strcpy(filenode->file->filename,filename); strcpy(filenode-&g
40、t;file->filekind,filekind); filenode->file->maxlength=length; filenode->file->strat=startpos; filenode->file->openflag=false; time(&rawtime); filenode->file->timeinfo=localtime(&rawtime); filenode->next=null; if(usertableuserid.user->next=null) usertableuseri
41、d.user->next=filenode; else p=usertableuserid.user->next; while(p->next) p=p->next; p->next=filenode; printf("創(chuàng)建文件成功n"); system("pause"); else printf("磁盤空間已滿或所創(chuàng)建文件超出磁盤空閑容量,磁盤空間分配失敗n"); system("pause"); void freedisk(int startpostion) disknode *p
42、; for(p=diskhead;p!=null;p=p->next) if(p->start=startpostion) break; p->useflag=false; void filedel(char filename) ufd *p,*q,*temp; q=usertableuserid.user; p=q->next; while(p) if(!strcmp(p->file->filename,filename) break; else p=p->next; q=q->next; if(p) if(p->file->ope
43、nflag!=true) /先判斷是否有進程打開該文件 temp=p; q->next=p->next; freedisk(temp->file->strat); /磁盤空間回收 free(temp); printf("文件刪除成功n"); system("pause"); else printf("該文件已被進程打開,刪除失敗n"); system("pause"); else printf("沒有找到該文件,請檢查輸入的文件名是否正確n"); system("pause"); void filecat(char file
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 露天煤礦安全生產技術露天煤礦安全管理培訓
- 中介房屋買賣擔保協(xié)議
- 現(xiàn)代倉儲管理與物流信息平臺
- 手術室醫(yī)療器械清洗消毒協(xié)議
- 商品房屋回購協(xié)議
- 事業(yè)單位要就業(yè)協(xié)議書
- 廚房工裝知識培訓課件
- 2025年角質溶解藥項目建議書
- 合作水鉆租賃合同范本
- 代發(fā)產品合同范例
- 開學安全第一課主題班會課件
- 新版《醫(yī)療器械經營質量管理規(guī)范》(2024)培訓試題及答案
- 2025年初級社會工作者綜合能力全國考試題庫(含答案)
- 部編人教版二年級道德與法治下冊同步練習(全冊)
- 余杭區(qū)住宅房屋裝修備案申請表
- 住宅建筑工程施工重點與難點應對措施方案
- 中醫(yī)婦科病證診斷療效標準
- 護士職業(yè)素養(yǎng)課件
- 專業(yè)醫(yī)院lovo常用文件產品介紹customer presentation
- 叉車日常使用狀況點檢記錄表(日常檢查記錄)
- ME基礎知識培訓PPT學習教案
評論
0/150
提交評論