2016西安交通大學操作系統實驗報告_第1頁
2016西安交通大學操作系統實驗報告_第2頁
2016西安交通大學操作系統實驗報告_第3頁
2016西安交通大學操作系統實驗報告_第4頁
2016西安交通大學操作系統實驗報告_第5頁
免費預覽已結束,剩余28頁可下載查看

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、操作系統實驗報告實驗一:用戶接口實驗1 實驗目的1 .理解面向操作命令的接口Shell。2 .學會簡單的shell 編碼。3 .理解操作系統調用的運行機制。4 .掌握創(chuàng)建系統調用的方法。操作系統給用戶提供了命令接口和程序接口(系統調用)兩種操作方式。用戶接口實驗也因此而分為兩大部分。首先要熟悉Linux的基本操作命令,并在此基礎上學會簡單的shell 編程方法。然后通過想Linux內核添加一個自己設計的系統調用, 來理解系統調用的實現方法和運行機制。在本次實驗中,最具有吸引力的地方是:通過內核編譯,將一組源代碼變成操作系統的內核,并由此重新引導系統,這對我們初步了解操作系統的生成過程極為有利。

2、2 實驗內容1) 控制臺命令接口實驗該實驗是通過 “幾種操作系統的控制臺命令”、 “終端處理程序”、 “命令解釋程序”和“Linux 操作系統的bash”來讓實驗者理解面向操作命令的接口shell和進行簡單的shell 編程。查看bash 版本。編寫bash 腳本,統計/my 目錄下 c語言文件的個數2) 系統調用實驗該實驗是通過實驗者對“Linux操作系統的系統調用機制”的進一步了解來理解操作系統調用的運行機制;同時通過 “自己創(chuàng)建一個系統調用mycal(l ) ”和 “編程調用自己創(chuàng)建的系統調用”進一步掌握創(chuàng)建和調用系統調用的方法。編程調用一個系統調用fork(),觀察結果。編程調用創(chuàng)建的

3、系統調用foo(),觀察結果。mycall(),實現功能:顯示字符串到屏幕上。編程調用自己創(chuàng)建的系統調用。實驗步驟系統調用實驗:1. 首先將 Linux-3.0.tar.bz2 拷貝到/usr/src目錄下 命令: cp linux-3.0.tar.bz2 /usr/src/2. 打開終端,獲得root 權限命令: sudo s3. 進入 /usr/src目錄命令:cd /usr/src4. 解壓 linux 源碼命令:tar xvzf linux-3.0.tar.bz25. 進入目錄linux-3.0.5命令:cd linux-3.06. 添加系統調用操作:gedit kernel/myse

4、rvice.c 在文本編輯器中添加#include <linux/kernel.h>#include <linux/linkage.h> asmlinkage void sys_mycall()printk(KERN_INFO "Hello, world!n");return;7. 修改 kernel/Makefile 添加生成myservice.c添加到Makefile 的編譯規(guī)則中:obj-y += myservice.o8. .修改arch/x86/include/asm/unistd_32.h,添加以下內容:#define _NR_mycal

5、l SYS_ID/SYS_ID 表示新添加系統調用的調用號并修改文件中的NR_syscalls,將其值增加19. 修改arxh/x86/include/asm/syscalls.h添加以下內容:asmlinkage void sys_mycall();10. 修改arch/x86/kernel/syscall_table_32.S,添加以下內容:.long sys_mycall11. 配置內核(僅僅修改local versions即可)命令: make menuconfig12. 編譯內核命令: make j4 bzImage(開4個線程編譯)13. 編譯內核模塊命令:make j4 modu

6、les14. 安裝內核模塊命令:make modules_install15. 安裝內核命令: make install16. 重啟系統,在系統選擇頁面選擇進入自己編譯的linux-3.0 內核17. 在桌面建立測試的C 程序 test.c程序內容如下:#include <stdio.h>int main(int argc, char *argv)syscall(SYS_ID); / SYS_ID 表示新添加系統調用的調用號return 0;18. 編譯程序gcc test.c o a.out19. 運行程序./a.out20. 查看內核日志(printk 的輸出信息在內核日志中)

7、: dmesg實驗結果1. 成功完成內核編譯的任務,結果顯示圖如下:2. 下圖為添加系統調用結果五 實驗小結這次實驗的內核編譯需要進行一系列比較花時間的操作過程,但同時也鍛煉了實際動手能力,在實踐中對于操作系統這門課有了進一步的了解。同時,在本次實驗中,學習了linux 系統的使用方法,掌握了很多的基本命令,也明白了添加系統調用的方法,為以后的學習提供了很大的幫助。- 15 -實驗四:一個簡單文件系統的實現實驗目的1. 熟悉Ext 文件系統的原理2. 根據Ext 文件系統的數據結構和構建方法,自行實現一個簡單的內存文件系統實驗內容1 .設計并實現一個一級(單用戶)文件系統程序a.提供以下操作:

8、a) 文件創(chuàng)建/刪除接口命令create/deleteb) 目錄創(chuàng)建/刪除接口命令mkdir/rmdirc) 顯示目錄內容命令lsb.創(chuàng)建的文件不要求格式和內容2 .設計并實現一個二級文件系統程序a.提供用戶登錄;b.文件、目錄要有權限實驗原理1. Ext 文件系統結構:2. 引導塊BootBlock每個硬盤分區(qū)的開頭1024 字節(jié),即0 byte 至 1023 byte是分區(qū)的啟動扇區(qū)。 存放由ROM BIOS 自動讀入的引導程序和數據,但這只對引導設備有效,而對于非引導設備,該引導塊不含代碼。這個塊與ext2 沒有任何關系。3. 超級塊 SuperBlock每個分區(qū)均有一個super bl

9、ock塊,定義了文件系統的全局信息,包括塊的大小,總塊數,空閑塊,索引結點數,各種位圖和i 節(jié)點表的地址和大小等信息。4. 數據塊位圖這是 ext2 管理存儲空間的方法。即位圖法。每個位對應一個數據塊,位值為 0 表示空閑,1 表示已經分配。數據塊位圖定義為一個塊大小。于是,一個組中的數據塊個數就決定了。假設塊大小為b 字節(jié)。 可以區(qū)別的塊數為b*8 個5. 數據塊 DataBlocks每個組的數據最大個數是在塊大小定義后就確定了的。所以組容量也就確定了。假設塊大小為b 字節(jié)。那么組容量就確定為(b*8)*b 字節(jié)若 1 塊 =4K,則組塊大小=4K*8*4K=128M6. inode位圖與數

10、據塊位圖相似,用來表示索引結點是否已經被使用。假設塊大小為b字節(jié), 每個索引結點數據結構大小為128 字節(jié)。 最多可以有b*8 個索引結點,索引結點表需要占用的存儲空間大小為(b*8)*128 字節(jié)。 即 (b*8)*128/b=8*128個塊7. inode表索引結點表由若干個索引結點數據結構組成,需要占用若干個塊。Ext2中的每個索引結點數據結構大小為128字節(jié)。 每個索引結點即對應一個文件或是目錄。是對其除文件名(目錄名)以外的所有屬性的描述。例如:文件類型,文件創(chuàng)建時間,訪問時間,修改時間,文件所占數據塊的個數,指向數據塊的指針。其中,數據塊指針是由15 個元組的數據組成實驗步驟運行結

11、果1. 根據要求編寫源程序,實驗源代碼見附錄12. 運行程序,運行結果如圖:1. 根據提示輸入help,結果如圖:2. 輸入 ls 列出根目錄下的項目,然后創(chuàng)建文件目錄c 再輸入 ls 觀察是否創(chuàng)建成功:5 進入文件目錄c 并在c 中創(chuàng)建文件a6 打開a,并讀取a7 關閉 a8 刪除 a9. 刪除文件目錄c五 . 實驗小結本次實驗要求建立一個文件系統,由于在專業(yè)課上的基本知識學習比較薄弱,所以參考了網上的一些代碼,進行了一些修改后最后獲得結果。最后,也算完成了一個簡單的文件系統,具備了題目中的要求。但在以后的學習中,還要對這一方面的知識進行一些補充。附錄 1:實驗源碼:#include <

12、;stdio.h>#include <time.h>#include <string.h>#include <signal.h>#define DATA_BLOCK 263680/數據塊起始地址# define BLOCK_SIZE 512/塊大小# define DISK_START 0 / 磁盤開始地址# define BLOCK_BITMAP 512/塊位圖起始地址# define INODE_BITMAP 1024/inode 位圖起始地址# define INODE_TABLE 1536/ 索引節(jié)點表起始地址# define INODE_SI

13、ZE 64 /struct inode 的大小struct group_descchar bg_volume_name16; / 卷名unsigned short bg_block_bitmap; / 保存塊位圖的塊號unsigned short bg_inode_bitmap; / 保存索引結點位圖的塊號unsigned short bg_inode_table; /索引結點表的起始塊號unsigned short bg_free_blocks_count; / 本組空閑塊的個數unsigned short bg_free_inodes_count; /本組空閑索引結點的個數unsigned

14、 short bg_used_dirs_count; /本組目錄的個數char bg_pad4; /填充 (0xff);struct inodeunsigned short i_mode; /文件類型及訪問權限unsigned short i_blocks; / 文件的數據塊個數unsigned long i_size; / 大小 ( 字節(jié) )unsigned long i_atime; / 訪問時間unsigned long i_ctime; / 創(chuàng)建時間unsigned long i_mtime; / 修改時間unsigned long i_dtime; / 刪除時間unsigned sh

15、ort i_block8; / 指向數據塊的指針char i_pad24; / 填充 (0xff);struct dir_entry/目錄項結構unsigned short inode; /索引節(jié)點號unsigned short rec_len; /目錄項長度unsigned short name_len; /文件名長度char file_type; /文件類型(1: 普通文件,2: 目錄 . )char name9; /文件名;char Buffer512;/針對數據塊的緩沖區(qū)char tempbuf4097; /unsigned char bitbuf512; / 位圖緩沖區(qū) unsign

16、ed short index_buf256;short fopen_table16; / 文件打開表unsigned short last_alloc_inode; /最近分配的節(jié)點號unsigned short last_alloc_block; /最近分配的數據塊號unsigned short current_dir; /當前目錄的節(jié)點號struct group_desc super_block1; /組描述符緩沖區(qū)struct inode inode_area1; / 節(jié)點緩沖區(qū) struct dir_entry dir32;/ 目錄項緩沖區(qū)char current_path256; /

17、 當前路徑名 unsigned short current_dirlen;FILE *fp;void update_group_desc() fseek(fp,DISK_START,SEEK_SET); fwrite(super_block,BLOCK_SIZE,1,fp);void reload_group_desc()/ 載入組描述符fseek(fp,DISK_START,SEEK_SET); fread(super_block,BLOCK_SIZE,1,fp);void update_inode_bitmap()/ 更新 inode 位圖 fseek(fp,INODE_BITMAP,SE

18、EK_SET); fwrite(bitbuf,BLOCK_SIZE,1,fp);void reload_inode_bitmap()/ 載入 inode 位圖fseek(fp,INODE_BITMAP,SEEK_SET); fread(bitbuf,BLOCK_SIZE,1,fp);void update_block_bitmap()/ 更新 block 位圖fseek(fp,BLOCK_BITMAP,SEEK_SET); fwrite(bitbuf,BLOCK_SIZE,1,fp);void reload_block_bitmap()/ 載入 block 位圖fseek(fp,BLOCK_B

19、ITMAP,SEEK_SET);fread(bitbuf,BLOCK_SIZE,1,fp);void update_inode_entry(unsigned short i)/ 更新第 i 個 inode 入口 fseek(fp,INODE_TABLE+(i-1)*INODE_SIZE,SEEK_SET);fwrite(inode_area,INODE_SIZE,1,fp);void reload_inode_entry(unsigned short i)/ 載入第 i 個 inode 入口 fseek(fp,INODE_TABLE+(i-1)*INODE_SIZE,SEEK_SET);fre

20、ad(inode_area,INODE_SIZE,1,fp);void reload_dir(unsigned short i)/ 更新第 i 個目錄fseek(fp,DATA_BLOCK+i*BLOCK_SIZE,SEEK_SET);fread(dir,BLOCK_SIZE,1,fp);void update_dir(unsigned short i)/ 載入第 i 個目錄fseek(fp,DATA_BLOCK+i*BLOCK_SIZE,SEEK_SET);fwrite(dir,BLOCK_SIZE,1,fp);void reload_block(unsigned short i)/ 載入第

21、 i 個數據塊fseek(fp,DATA_BLOCK+i*BLOCK_SIZE,SEEK_SET);fread(Buffer,BLOCK_SIZE,1,fp);void update_block(unsigned short i)/ 更新第 i 個數據塊fseek(fp,DATA_BLOCK+i*BLOCK_SIZE,SEEK_SET);fwrite(Buffer,BLOCK_SIZE,1,fp);int alloc_block()/ 分配一個數據塊,返回數據塊號;unsigned short cur=last_alloc_block;unsigned char con=128;int fla

22、g=0;if(super_block0.bg_free_blocks_count=0) printf("There is no block to be alloced!n");return(0);reload_block_bitmap();cur=cur/8;while(bitbufcur=255) if(cur=511)cur=0;else cur+;while(bitbufcur&con)con=con/2;flag+;bitbufcur=bitbufcur+con;last_alloc_block=cur*8+flag;update_block_bitmap(

23、);super_block0.bg_free_blocks_count-; update_group_desc();return last_alloc_block;void remove_block(unsigned short del_num)/ 刪除一個blockunsigned short tmp;tmp=del_num/8;reload_block_bitmap();switch(del_num%8)/ 更改 block 位圖case 0:bitbuftmp=bitbuftmp&127;break;case 1:bitbuftmp=bitbuftmp&191;break

24、;case 2:bitbuftmp=bitbuftmp&223;break;case 3:bitbuftmp=bitbuftmp&239;break;case 4:bitbuftmp=bitbuftmp&247;break;case 5:bitbuftmp=bitbuftmp&251;break;case 6:bitbuftmp=bitbuftmp&253;break;case 7:bitbuftmp=bitbuftmp&254;break;update_block_bitmap();super_block0.bg_free_blocks_cou

25、nt+;update_group_desc();/int get_inode()/ 分配一個inode,返回序號unsigned short cur=last_alloc_inode;unsigned char con=128;int flag=0;if(super_block0.bg_free_inodes_count=0)printf("There is no Inode to be alloced!n");return 0;reload_inode_bitmap();cur=(cur-1)/8;while(bitbufcur=255)if(cur=511)cur=0;

26、else cur+;while(bitbufcur&con)con=con/2;flag+;bitbufcur=bitbufcur+con;last_alloc_inode=cur*8+flag+1;update_inode_bitmap();super_block0.bg_free_inodes_count-; update_group_desc();return last_alloc_inode;/void remove_inode(unsigned short del_num) unsigned short tmp;tmp=(del_num-1)/8;reload_inode_b

27、itmap();switch(del_num-1)%8)/ 更改 block 位圖case 0:bitbuftmp=bitbuftmp&127;break;case 1:bitbuftmp=bitbuftmp&191;break;case 2:bitbuftmp=bitbuftmp&223;break;case 3:bitbuftmp=bitbuftmp&239;break;case 4:bitbuftmp=bitbuftmp&247;break;case 5:bitbuftmp=bitbuftmp&251;break;case 6:bitbuf

28、tmp=bitbuftmp&253;break;case 7:bitbuftmp=bitbuftmp&254;break;update_inode_bitmap();super_block0.bg_free_inodes_count+;update_group_desc();/ dirvoid dir_prepare(unsigned short tmp,unsigned short len,int type) /新目錄和文件初始 化 .and .reload_inode_entry(tmp);/ 得到新目錄的節(jié)點入口地址if(type=2)/ 目錄inode_area0.i_

29、size=32;inode_area0.i_blocks=1;inode_area0.i_block0=alloc_block();dir0.inode=tmp;dir1.inode=current_dir;_len=len;_len=current_dirlen;dir0.file_type=dir1.file_type=2;for(type=2;type<32;type+)dirtype.inode=0;strcpy(,".");strcpy(,".");update_di

30、r(inode_area0.i_block0);inode_area0.i_mode=01006;/drwxrwxrwx: 目錄elseinode_area0.i_size=0;inode_area0.i_blocks=0;inode_area0.i_mode=0407;/drwxrwxrwx: 文件update_inode_entry(tmp);/unsigned short reserch_file(char tmp9,int file_type,unsigned short *inode_num,unsigned short *block_num,unsigned short *dir_

31、num)/查找文件并改寫緩沖區(qū)里節(jié)點號,所在目錄節(jié)點的數據塊號( 07) 、目錄項所在號unsigned short j,k;reload_inode_entry(current_dir);j=0;while(j<inode_area0.i_blocks)reload_dir(inode_area0.i_blockj);k=0;while(k<32)if(!dirk.inode|dirk.file_type!=file_type|strcmp(,tmp)k+; else*inode_num=dirk.inode;*block_num=j;*dir_num=k;re

32、turn 1;j+;return 0;/void cd(char tmp9)unsigned short i,j,k,flag;flag=reserch_file(tmp,2,&i,&j,&k);if(flag)current_dir=i;if(!strcmp(tmp,".")&&_len)current_pathstrlen(current_path)-_len-1='0'current_dirlen=_len;else if(!strcmp(tmp,&q

33、uot;.");else if(strcmp(tmp,".")current_dirlen=strlen(tmp);strcat(current_path,tmp);strcat(current_path,"/");else printf("The directory %s not exists!n",tmp);/unsigned short i,j,k,m,n,flag;m=0;flag=reserch_file(tmp,1,&i,&j,&k);if(flag)flag=0;while(fopen_

34、tableflag!=dirk.inode&&flag<16)flag+;if(flag<16)fopen_tableflag=0;reload_inode_entry(i);while(m<inode_area0.i_blocks)remove_block(inode_area0.i_blockm+);inode_area0.i_blocks=0;inode_area0.i_size=0;remove_inode(i);reload_inode_entry(current_dir);dirk.inode=0;/if(k!=0)dirk-1.rec_len+=

35、dirk.rec_len ;update_dir(inode_area0.i_blockj);inode_area0.i_size-=16;m=1;while(m<inode_areai.i_blocks)flag=n=0;reload_dir(inode_area0.i_blockm);while(n<32)if(!dirn.inode)flag+;n+;if(flag=32)remove_block(inode_areai.i_blockm);inode_areai.i_blocks-;while(m<inode_areai.i_blocks)inode_areai.i_

36、blockm=inode_areai.i_block+m;update_inode_entry(current_dir);else printf("The file %s not exists!n",tmp);/void mkdir(char tmp9,int type)- 18 -unsigned short tmpno,i,j,k,flag;reload_inode_entry(current_dir); / 獲得當前目錄的索引節(jié)點給inode_area0if(!reserch_file(tmp,type,&i,&j,&k) / 未找到同名文件i

37、f(inode_area0.i_size=4096) / 目錄項已滿printf("Directory has no room to be alloced!n");return;flag=1;32 個if(inode_area0.i_size!=inode_area0.i_blocks*512)/ 目錄中有某些個塊中項未滿i=0;while(flag&&i<inode_area0.i_blocks)reload_dir(inode_area0.i_blocki);j=0;while(j<32)if(dirj.inode=0)flag=0;brea

38、k;j+; i+;tmpno=dirj.inode=get_inode();_len=strlen(tmp);dirj.file_type=type;strcpy(,tmp);update_dir(inode_area0.i_blocki-1);else/全滿inode_area0.i_blockinode_area0.i_blocks=alloc_block();inode_area0.i_blocks+;reload_dir(inode_area0.i_blockinode_area0.i_blocks-1);tmpno=dir0.inode=get_i

39、node();_len=strlen(tmp);dir0.file_type=type;strcpy(,tmp);/初始化新塊for(flag=1;flag<32;flag+)dirflag.inode=0;update_dir(inode_area0.i_blockinode_area0.i_blocks-1); inode_area0.i_size+=16;update_inode_entry(current_dir);dir_prepare(tmpno,strlen(tmp),type);else /已經存在同名文件或目錄if(type=1)pr

40、intf("File has already existed!n");else printf("Directory has already existed!n");/void rmdir(char tmp9)unsigned short i,j,k,flag;unsigned short m,n;if(!strcmp(tmp,".")|!strcmp(tmp,".")printf("The directory can not be deleted!n");return;flag=reserch_

41、file(tmp,2,&i,&j,&k);if(flag)reload_inode_entry(dirk.inode); / 找到要刪除的目錄的節(jié)點并載入 if(inode_area0.i_size=32)/只有.and .inode_area0.i_size=0;inode_area0.i_blocks=0;/reload_dir(inode_area0.i_block0);/dir0.inode=0;/dir1.inode=0;remove_block(inode_area0.i_block0); reload_inode_entry(current_dir);/

42、得到當前目錄的節(jié)點并更改當前目錄項remove_inode(dirk.inode);dirk.inode=0;update_dir(inode_area0.i_blockj);inode_area0.i_size-=16;flag=0;- 31 -m=1;while(flag<32&&m<inode_area0.i_blocks) flag=n=0;reload_dir(inode_area0.i_blockm);while(n<32)if(!dirn.inode)flag+;n+;if(flag=32)remove_block(inode_area0.i_b

43、lockm);inode_area0.i_blocks-;while(m<inode_area0.i_blocks)inode_area0.i_blockm=inode_area0.i_block+m;update_inode_entry(current_dir);else printf("Directory is not null!n");else printf("Directory to be deleted not exists!n");/void ls() int i,j,k,tmpno,no;i=0;printf("items

44、type mode sizen");reload_inode_entry(current_dir);while(i<inode_area0.i_blocks)k=0;reload_dir(inode_area0.i_blocki);while(k<32)if(dirk.inode)printf("%s",);if(dirk.file_type=2)j=0;reload_inode_entry(dirk.inode);if(!strcmp(,".")while(j+<13)printf(&qu

45、ot; ");else if(!strcmp(,".")while(j+<14)printf(" ");else while(j+<15-_len)printf(" ");printf("<DIR>");switch(inode_area0.i_mode&7)case 1:printf("x");break;case 2:printf("_w_");break;case 3:printf("

46、;_w_x");break;case 4:printf("r");break;case 5:printf("r_x");break;case 6:printf("r_w_");break;case 7:printf("r_w_x");break; printf("");else if(dirk.file_type=1)j=0;reload_inode_entry(dirk.inode);while(j+<15-_len)printf(" ")

47、;printf("<FILE>");switch(inode_area0.i_mode&7)case 1:printf("x");break;case 2:printf("_w_");break;case 3:printf("_w_x");break;case 4:printf("r");break;case 5:printf("r_x");break;case 6:printf("r_w_");break;case 7:printf(

48、"r_w_x");break;printf("%d bytes ",inode_area0.i_size); printf("n");k+;reload_inode_entry(current_dir); i+;/ fileunsigned short search_file(unsigned short Ino)/ 在打開文件表中查找是否已打開文件unsigned short fopen_table_point=0;while(fopen_table_point<16&&fopen_tablefopen_tab

49、le_point+!=Ino);if(fopen_table_point=16)return 0;return 1;/void read_file(char tmp9)/ 讀文件unsigned short flag,i,j,k;flag=reserch_file(tmp,1,&i,&j,&k); / 返回文件目錄項的信息if(flag)if(search_file(dirk.inode)reload_inode_entry(dirk.inode);if(!(inode_area0.i_mode&4)/i_mode:111b: 讀 ,寫 ,執(zhí)行 printf(&

50、quot;The file %s can not be read!n",tmp);return;for(flag=0;flag<inode_area0.i_blocks;flag+)reload_block(inode_area0.i_blockflag);Buffer512='0'printf("%s",Buffer);if(flag=0)printf("The file %s is empty!n",tmp);else printf("n");else printf("The file %

51、s has not been opened!n",tmp);else printf("The file %s not exists!n",tmp); void write_file(char tmp9)/ 寫文件 unsigned short flag,i,j,k,size=0,need_blocks;flag=reserch_file(tmp,1,&i,&j,&k);if(flag)if(search_file(dirk.inode)reload_inode_entry(dirk.inode);if(!(inode_area0.i_mod

52、e&2)/i_mode:111b: 讀 ,寫 ,執(zhí)行 printf("The file %s can not be writed!n",tmp);return;while(1)tempbufsize=getchar(); if(tempbufsize='#') tempbufsize='0'break;if(size>=4096)printf("Sorry,the max size of a file is 4KB!n");tempbufsize='0'break; size+;need_bl

53、ocks=strlen(tempbuf)/512;if(strlen(tempbuf)%512)need_blocks+;if(need_blocks<9)while(inode_area0.i_blocks<need_blocks)inode_area0.i_blockinode_area0.i_blocks=alloc_block(); inode_area0.i_blocks+;j=0;while(j<need_blocks) if(j!=need_blocks-1)reload_block(inode_area0.i_blockj);memcpy(Buffer,tem

54、pbuf+j*BLOCK_SIZE,BLOCK_SIZE);update_block(inode_area0.i_blockj); elsereload_block(inode_area0.i_blockj);memcpy(Buffer,tempbuf+j*BLOCK_SIZE,strlen(tempbuf)-j*BLOCK_SIZE);if(strlen(tempbuf)>inode_area0.i_size)Bufferstrlen(tempbuf)-j*BLOCK_SIZE='0'inode_area0.i_size=strlen(tempbuf);update_block(inode_area0.i_blockj);j+;update_inode_entry(dirk.inode);else printf("Sorry,the

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論