• 大小: 371KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-06
  • 语言: 其他
  • 标签: 华工  C/C++  

资源简介

设计一 设计任务:模拟Linux文件系统 在任一OS下,建立一个大文件,把它假象成一张盘,在其中实现一个简单的模拟Linux文件系统。 1. 在现有机器硬盘上开辟100M的硬盘空间,作为设定的硬盘空间。 2. 编写一管理程序simdisk对此空间进行管理,以模拟Linux文件系统,要求: (1) 盘块大小1k (2) 空闲盘块的管理:Linux位图法 (3) 结构:超级块, i结点区, 根目录区 3. 该simdisk管理程序的功能要求如下: (1) info: 显示整个系统信息(参考Linux文件系统的系统信息),文件可以根据用户进行读写保护。目录名和文件名支持全路径名和相对路径名,路径名各分量间用“/”隔开。

资源截图

代码片段和文件信息

#include
#include
#include
#include “structure.h“
#include “format.h“
#include “log.h“
#include “help.h“
#include “dir.h“
#include “file.h“
#include “display_sys.h“
#include “find_same_name.h“
#include “b_alloc_and_free.h“
#include “i_alloc_and_free.h“
#include “divide_path.h“
#include “check.h“
#include “install.h“
#include “exit.h“
#include “display_current_dir.h“

struct block_group _block_group[BLOCKS_GROUP_NUM]; //数据块组
struct inode inode_table[TOTAL_INODES_NUM]; //inode表
struct user _user[MAX_USER_NUM]; //用户
struct dir _current_dir; //目录
bool block_bitmap[TOTAL_BLOCKS_NUM]; //数据块位图
bool inode_bitmap[TOTAL_INODES_NUM]; //inode 位图
FILE *fd; //系统文件
unsigned int uid; //使用文件系统的用户ID
char pwd[20]; //密码
command cmd[13]; //命令
char current_path[1000]; //保存当前路径

void main()
{
install();
while(!login());
printf(“\n**************************欢迎使用模拟Linux文件系统!***************************\n“);
while(1)
{
char control[100]; //用于输入命令
char path1[1000]path2[1000]; //用于路径或名字输入
int i=0; //循环控制变量
fflush(stdin); //清除流
printf(“\n%s“current_path);
scanf(“%s“control);
for(i=0;i<13;i++)
if(strcmp(cmd[i].comcontrol)==0)
break;
switch(i)
{
case 0: //format
format();
break;
case 1: //info
display_sys_info();
break;
case 2: //cd
scanf(“%s“path1);
if(change_dir(path1sizeof(path1)))
display_current_dir(_current_dir);
break;
case 3: //dir
scanf(“%s“path1);
display_dir(path1sizeof(path1));
break;
case 4: //md
scanf(“%s“path1);
make_dir(path1sizeof(path1));
break;
case 5: //rd
scanf(“%s“path1);
remove_dir(path1sizeof(path1));
break;
case 6: //newfile
scanf(“%s“path1);
create_file(path1sizeof(path1));
break;
case 7: //cat
scanf(“%s“path1);
open_file(path1sizeof(path1));
break;
case 8: //copy
scanf(“%s“path1);
scanf(“%s“path2);
copy_file(path1sizeof(path1)path2sizeof(path2));
break;
case 9: //del
scanf(“%s“path1);
delete_file(path1sizeof(path1));
break;
case 10: //check
check();
break;
case 11: //exit
exit_sys();
break;
case 12: //help
help();
break;
default:
printf(“没有此命令!如需帮助请输入 hlep\n“);
}
}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2009-02-28 16:46  操作系统课程设计\
     文件      229451  2009-02-25 22:38  操作系统课程设计\simdisk.exe
     目录           0  2009-02-25 23:57  操作系统课程设计\src\
     文件        4314  2009-02-25 21:13  操作系统课程设计\src\b_alloc_and_free.h
     文件        2679  2009-02-25 01:04  操作系统课程设计\src\check.h
     文件       13104  2009-02-25 21:07  操作系统课程设计\src\dir.h
     文件         897  2009-02-25 18:03  操作系统课程设计\src\display_current_dir.h
     文件         753  2009-02-22 12:43  操作系统课程设计\src\display_sys.h
     文件        5458  2009-02-25 18:32  操作系统课程设计\src\divide_path.h
     文件         724  2009-02-25 18:02  操作系统课程设计\src\exit.h
     文件       13801  2009-02-25 18:10  操作系统课程设计\src\file.h
     文件         331  2009-02-21 13:01  操作系统课程设计\src\find_same_name.h
     文件        4631  2009-02-25 17:37  操作系统课程设计\src\format.h
     文件        1053  2009-02-25 17:37  操作系统课程设计\src\help.h
     文件        1686  2009-02-25 17:37  操作系统课程设计\src\install.h
     文件        1391  2009-02-22 16:01  操作系统课程设计\src\i_alloc_and_free.h
     文件        1017  2009-02-25 14:32  操作系统课程设计\src\log.h
     文件        2560  2009-02-25 19:56  操作系统课程设计\src\main.cpp
     文件        5579  2009-02-25 22:38  操作系统课程设计\src\structure.h
     文件      339391  2009-02-28 16:44  操作系统课程设计\实验报告.docx
     文件       55808  2009-02-11 12:17  操作系统课程设计\操作系统课程设计2008-simple.doc

评论

共有 条评论