halt.c

来自「此版本是在网上广为流传的 二级文件系统 基础上制作的.重新编写了块操作等模块,修」· C语言 代码 · 共 34 行

C
34
字号
#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 + =
减小字号Ctrl + -
显示快捷键?