?? main.c
字號:
#include <stdio.h>
#include <stdlib.h>
#include "filesys.h"
struct hinode hinode[NHINO];
struct dir dir;
struct file sys_ofile[SYSOPENFILE];
struct filsys filsys;
struct user user[USERNUM];
FILE *fd;
struct inode *cur_path_inode;
int user_id,file_block;
main()
{
unsigned short ab_fd1,ab_fd2,ab_fd3,ab_fd4;
unsigned short bhy_fd1;
char *buf;
int i;
/* printf("\nDo you want to format the disk? y/n \n");
if(getchar()=='y')
{printf("\nFormat Will erase all context on the disk. Are You Sure? y/n\n");getchar();}
else
exit(0);
if(getchar()=='y')
format();
else
exit(0);
*/
printf(".....................................................\n");
printf("command:format \n");
printf("formatting...\n");
format();
printf("installed filesystem\n");
install();
printf(".....................................................\n");
printf("command:list\n");//列出目錄
dirlt(20);
_dir();
/* user_id=0;*/
printf(".....................................................\n");
printf("command:mkdir mydir\n");//創(chuàng)建mydir目錄
mkdir("mydir");
printf(".....................................................\n");
printf("command:list\n");//再次列出目錄
dirlt(2);
_dir();
printf(".....................................................\n");
printf("command:chdir mydir\n");//進(jìn)入mydir目錄
chdir("mydir");
printf(".....................................................\n");
printf("command:list\n");
dirlt(2); //再次列出目錄
_dir();
file_block=BLOCKSIZ*6+5;
printf(".....................................................\n");
printf("command:creat myfile.c\n");//創(chuàng)建myfile.c文件
ab_fd1=creat(user_id,"myfile.c",01777);
buf=(char*)malloc(BLOCKSIZ*6+5);
write(ab_fd1,buf,BLOCKSIZ*6+5);
close(user_id,ab_fd1);
free(buf);
printf(".....................................................\n");
printf("command:list\n");
dirlt(2); //再次列出目錄
_dir();
/*
printf("\nin---->mkdir:subdir\n");
mkdir("subdir");
chdir("subdir");
dirlt(2);
_dir();
file_block=BLOCKSIZ*4+20;
ab_fd2=creat(user_id,"ab_file1.c",01777);
buf=(char *)malloc(BLOCKSIZ*4+20);
write(ab_fd2,buf,BLOCKSIZ*4+20);
close(user_id,ab_fd2);
free(buf);
dirlt(2);
_dir();
printf("\nin---->chdir:..\n");
chdir("..");
dirlt(2);
_dir();
printf("\nin---->creat(ab_file2.c)\n");
file_block=BLOCKSIZ*3+255;
ab_fd3=creat(user_id,"ab_file2.c",01777);
buf=(char*)malloc(BLOCKSIZ*3+255);
write(ab_fd3,buf,BLOCKSIZ*3+255);
close(user_id,ab_fd3);
free(buf);
dirlt(2);
_dir();
*/
printf(".....................................................\n");
printf("command:delete myfile.c\n");
delete("myfile.c");
printf(".....................................................\n");
printf("command:list\n");
dirlt(2); //再次列出目錄
_dir();
/* printf("\nin---->creat(ab_file3.c)\n");
file_block=BLOCKSIZ*8+300;
ab_fd4=creat(user_id,"ab_fi1e3.c",01777);
buf=(char *)malloc(BLOCKSIZ *8+300);
write(ab_fd4,buf,BLOCKSIZ*8+300);
close(user_id,ab_fd4);
free(buf);
dirlt(2);
_dir();
*/
/*
printf("\nin---->open(ab_file2.c)\n");
file_block=BLOCKSIZ*3+100;
ab_fd3=open(user_id,"ab_file2.c",FAPPEND);
buf=(char *)malloc(BLOCKSIZ*3+100);
write(ab_fd3,buf,BLOCKSIZ*3+100);
close(user_id,ab_fd3);
free(buf);
dirlt(2);
_dir();
*/
/*
printf("\nin---->chdir()\n");
chdir ("..");
*/
printf(".....................................................\n");
printf("command:quit\n");
halt( );
/*注意:先刪除調(diào)試10中的pause();語句。*/
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -