• 大小: 35KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-01
  • 语言: C/C++
  • 标签: linux  

资源简介

linux ext2 文件系统模拟 c语言实现 我从google上下了修改些代码增加了一些东西 对学习ext2文件系统很有帮助

资源截图

代码片段和文件信息

/*
* app.c
*/

#include 
#include 
#include “sim_ext2.h“

int main(int argcchar **argv)
{
    char command[10]temp[9];
    initialize_memory();
    while(1)
    {
        printf(“%s]#“current_path);
        scanf(“%s“command);
        if(!strcmp(command“cd“))
        {
            scanf(“%s“temp);
            cd(temp);
        }
        else if(!strcmp(command“mkdir“))
        {
            scanf(“%s“temp);
            mkdir(temp2);
        }
        else if(!strcmp(command“mkf“))
        {
            scanf(“%s“temp);
            mkdir(temp1);
        }
        else if(!strcmp(command“rmdir“))
        {
            scanf(“%s“temp);
            rmdir(temp);
        }
        else if(!strcmp(command“rm“))
        {
            scanf(“%s“temp);
            del(temp);
        }
        else if(!strcmp(command“open“))
        {
            scanf(“%s“temp);
            open_file(temp);
        }
        else if(!strcmp(command“close“))
        {
            scanf(“%s“temp);
            close_file(temp);
        }
        else if(!strcmp(command“read“))
        {
            scanf(“%s“temp);
            read_file(temp);
        }
        else if(!strcmp(command“write“))
        {
            scanf(“%s\n“temp);
            write_file(temp);
        }
        else if(!strcmp(command“ls“))
        {
         ls();
        }
        else if(!strcmp(command“format“))
        {
            char tempch;
            printf(“Format will erase all the data in the Disk\n“);
            printf(“Are you sure?y/n:\n“);
            fflush(stdin);
            scanf(“ %c“&tempch);
            if(tempch==‘Y‘||tempch==‘y‘)
            {
                format();
            }
            else
            {
             printf(“Format Disk canceled\n“);
            }
        }
        else if(!strcmp(command“help“)||!strcmp(command“h“))
        {
         help();
        }
        else if(!strcmp(command“ckdisk“))
        {
         check_disk();
        }
        else if(!strcmp(command“quit“))
        {
         break;
        }
        else printf(“No this CommandPlease check!\n“);
    }
    return 0;
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2266  2010-10-15 12:22  sim_ext2_fs\app.c

     文件       6596  2010-10-15 12:22  sim_ext2_fs\app.o

     文件        351  2010-10-14 16:02  sim_ext2_fs\Makefile

     文件      28941  2010-10-15 12:25  sim_ext2_fs\simulator.c

     文件       4361  2010-10-15 11:25  sim_ext2_fs\simulator.h

     文件      32468  2010-10-15 12:25  sim_ext2_fs\simulator.o

     文件      34775  2010-10-15 12:25  sim_ext2_fs\sim_ext2

     文件        577  2010-10-15 11:11  sim_ext2_fs\sim_ext2.h

     文件    2361344  2010-10-15 12:24  sim_ext2_fs\sim_hd\FS_zqw_zzw.txt

     目录          0  2010-10-15 22:02  sim_ext2_fs\sim_hd

     目录          0  2010-10-15 22:02  sim_ext2_fs

----------- ---------  ---------- -----  ----

              2471679                    11


评论

共有 条评论