halt.c
来自「基于UNIX6的文件系统模拟程序」· C语言 代码 · 共 42 行
C
42 行
#include <stdio.h>
#include <stdlib.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 filesus 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("\nThe FileSystem is terminated!\nPress any to exit...");
getch(); //exit(0);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?