没有合适的资源?快使用搜索试试~ 我知道了~
操作系统课程设计 文件系统程序设计
4星 · 超过85%的资源 需积分: 9 29 下载量 138 浏览量
2011-12-20
11:26:10
上传
评论
收藏 21KB TXT 举报
温馨提示
试读
25页
1) 设计一个10个用户的文件系统,每次用户可保存10个文件,一次运行用户可以打开5个文件。 2) 程序采用二级文件目录(即设置主目录[MFD]和用户文件目录(UED)。另外,为打开文件设置了运行文件目录(AFD)。 3) 为了便于实现,对文件的读写作了简化,在执行读写命令时,只需改读写指针,并不进行实际的读写操作。
资源推荐
资源详情
资源评论
#include <stdio.h>
#include <memory.h>
#include <string>
#include <iostream>
using namespace std;
//1代表普通文件2代表目录文件0表示空文件
#define GENERAL 1
#define DIRECTORY 2
#define NULL 0
struct FCB
{
char fname[16]; //文件名
char type;
int size; //文件大小
int fatherBlockNum; //当前的父目录盘块号
int currentBlockNum; //当前的盘块
void initialize()
{
strcpy(fname,"/0");
type = NULL;
size =0;
fatherBlockNum = currentBlockNum = 0;
}
};
/*常量设置*/
const char* FilePath = "C://myfiles";
#include <memory.h>
#include <string>
#include <iostream>
using namespace std;
//1代表普通文件2代表目录文件0表示空文件
#define GENERAL 1
#define DIRECTORY 2
#define NULL 0
struct FCB
{
char fname[16]; //文件名
char type;
int size; //文件大小
int fatherBlockNum; //当前的父目录盘块号
int currentBlockNum; //当前的盘块
void initialize()
{
strcpy(fname,"/0");
type = NULL;
size =0;
fatherBlockNum = currentBlockNum = 0;
}
};
/*常量设置*/
const char* FilePath = "C://myfiles";
const int BlockSize = 512; //盘块大小
const int OPEN_MAX = 5; //能打开最多的文件数
const int BlockCount = 128; //盘块数
const int DiskSize = BlockSize*BlockCount; //磁盘大小
const int BlockFcbCount = BlockSize/sizeof(FCB);//目录文件的最多FCB数
int OpenFileCount = 0;
struct OPENLIST //用户文件打开表
{
int files; //当前打开文件数
FCB f[OPEN_MAX]; //FCB拷贝
OPENLIST()
{
files=0;
for(int i=0;i<OPEN_MAX;i++){
f[i].fatherBlockNum=-1;//为分配打开
f[i].type=GENERAL;
}
}
};
/*-------------目录文件结构---------------*/
struct dirFile
{
struct FCB fcb[BlockFcbCount];
void init(int _FatherBlockNum,int _CurrentBlockNum,char *name)//父块号,当前块号,目录名
{
strcpy(fcb[0].fname,name); //本身的FCB
fcb[0].fatherBlockNum=_FatherBlockNum;
const int OPEN_MAX = 5; //能打开最多的文件数
const int BlockCount = 128; //盘块数
const int DiskSize = BlockSize*BlockCount; //磁盘大小
const int BlockFcbCount = BlockSize/sizeof(FCB);//目录文件的最多FCB数
int OpenFileCount = 0;
struct OPENLIST //用户文件打开表
{
int files; //当前打开文件数
FCB f[OPEN_MAX]; //FCB拷贝
OPENLIST()
{
files=0;
for(int i=0;i<OPEN_MAX;i++){
f[i].fatherBlockNum=-1;//为分配打开
f[i].type=GENERAL;
}
}
};
/*-------------目录文件结构---------------*/
struct dirFile
{
struct FCB fcb[BlockFcbCount];
void init(int _FatherBlockNum,int _CurrentBlockNum,char *name)//父块号,当前块号,目录名
{
strcpy(fcb[0].fname,name); //本身的FCB
fcb[0].fatherBlockNum=_FatherBlockNum;
剩余24页未读,继续阅读
资源评论
- 凉SAMA2015-07-20注释挺详细,但数据结构不是我想要的二叉链表
- sadywish2012-11-30代码不错,确实能运行,就是里面的反斜杠都写错了……大概是有意的吧?
tangchu123
- 粉丝: 0
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功