⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.txt

📁 文件摸拟:实现文件系统的基本操作的主函数.(C语言)
💻 TXT
字号:
/*主程序main.。用来测试文件系统的各种设计功能,其主要功能描述如程序设计中的第4部分*/
#include<stdio.h>
#include "filesys.h"

struct hinode hinode[NHINO];

struct dir dir;
struct file sys_ofile [SYSOPENFILE];
struct filsys filsys;
struct pwd pwd[PWDNUM];
struct user user[USERNUM];
FILE *fp;
struct inode *cur_path_inode;
int user_id,file_block;
void main()
{
	unsigned short ab_fd1,ab_fd2,ab_fd3,ab_fd4;
	
	char *buf;
	
	format();
	install();
	user_id=0;

	_dir();
	
	login(2118,"abcd");
	
	_dir();

	
	mkdir("a2118");
	chdir ("a2118");
	_dir();
	
	file_block= BLOCKSIZ*6+5;
	ab_fd1 = creat(user_id,"ab_file0.c",01777);
//	ab_fd1 = creat(user_id,"ab_file0.c",01700);
	
	buf = (char*)malloc(BLOCKSIZ*6 + 5);
	write (ab_fd1,buf,BLOCKSIZ * 6+5);
	close(user_id,ab_fd1);
	free (buf);
	
	_dir();

	mkdir("subdir");
	chdir("subdir");
	
	_dir();

	file_block = BLOCKSIZ*4 +20;

	ab_fd2=creat(user_id,"ab_filel.c", 01777);
//	ab_fd2=creat(user_id,"ab_filel.c", 01700);

	buf=(char*) malloc (BLOCKSIZ * 4+20);
	write(ab_fd2,buf, BLOCKSIZ * 4+20);
	close(user_id, ab_fd2);
	free (buf);
	
	_dir();
	
	chdir("..");
	
	file_block = BLOCKSIZ*3 +255;
	
	ab_fd3 =creat(user_id,"ab_file2.c", 01777);
//	ab_fd3 =creat(user_id,"ab_file2.c", 01700);
	buf=(char *)malloc (BLOCKSIZ*3+255);   
	write (ab_fd3,buf,BLOCKSIZ*3+255);
	close(user_id,ab_fd3);
	free (buf);
	
	_dir();
	
	delete("ab_file0.c");
	
	_dir();
	
	file_block = BLOCKSIZ *8 + 300;
	
	ab_fd4=creat(user_id,"ab_file3.c",01777);
//	ab_fd4=creat(user_id,"ab_file3.c",01700);

	buf = (char *)malloc(BLOCKSIZ*8+300);
	write (ab_fd4,buf,BLOCKSIZ*8+300);
	close (user_id,ab_fd4);
	free(buf);
	
	_dir();
	
	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);
	
	_dir();
/**/	
/*	chdir("..");
	
	logout(user_id);
	
	_dir();
/**/	
	halt();  
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -