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

📄 halt.c

📁 此版本是在网上广为流传的 二级文件系统 基础上制作的.重新编写了块操作等模块,修正了N多BUG. 实现的命令有 ls-列目录 md-创建目录 cd-进入子目录 mf-创建文件 cat-显示文件内
💻 C
字号:
#include <stdio.h>
#include "filesys.h"
halt()
{
    struct inode * inode;
    int i,j;
    /*1. write back the current dir */
    chdir("..");
    iput(cur_path_inode);
    /* 2. free the u_ofile and sys_ofile and inode */
    for (i=0;i<USERNUM;i++)
    {
        if (user[i].u_uid !=0)
        {
           for (j=0;j<NOFILE;j++)
           {
                if(user[i].u_ofile[j]!=SYSOPENFILE+1)
                {
                    close(user[i].u_ofile[j]);
                    user[i].u_ofile[j]=SYSOPENFILE+1;
                }
           }
        }
    }
   /* 3. write back the filesys to the disk */
   fseek (fd,BLOCKSIZ,SEEK_SET);
   fwrite(&filsys,1,sizeof(struct filsys),fd);
   /*  4.  close the file system column  */
    fclose(fd);
    /*  5.say GOOD BYE to all the user  */
    printf("\nGood Bye.See You Next Time.Please turn off the switch\n");
    exit(0);
}    

⌨️ 快捷键说明

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