filehdr.h

来自「操作系统课程设计。在UNIX平台下实现Solary操作系统的一些功能」· C头文件 代码 · 共 85 行

H
85
字号
/////////////////////////////////////////////////////////////
//FileName		: filehdr.h
//
//Creator		: Fang WenBin(0410706)
//CreateTime	: 2006-12-26
//
//File Desc: 
//		the header of filehdr.cc, which implement two class:
//		1. s_Bitmap -- bimap used for allocate disk space
//		2. FileHeader -- the inode!
/////////////////////////////////////////////////////////////#include "copyright.h"#ifndef FILEHDR_H#define FILEHDR_H#include "disk.h"#include "bitmap.h"#define NumDirect 	((SectorSize - 2 * sizeof(int)) / sizeof(int))#define MaxFileSize 	(NumDirect * SectorSize)#define s_NUM_OF_INDEX 6			//the total number of inode index slot
///
///use for inode's s_fileMode field
///#define s_DIR_TYPE	0x00000001		//directory type	#define s_FILE_TYPE 0x00000002		//file type#define s_DIR_ONE	0x00000010		//level 1 dir#define s_DIR_TWO	0x00000020		//level 2 dir#define s_DIR_THREE 0x00000040		//level 3 dir#define s_DIR_FOUR	0x00000080		//level 4 dir
///
///use for allocate disk space
///class s_Bitmap{	public:		s_Bitmap(int nitems);		~s_Bitmap();					void Mark(int which);		void Clear(int which);		bool Test(int which);		int Find();		int NumClear();		void Print();		void FetchFrom(int startSector, int totalSector);		void WriteBack(int startSector, int totalSector);		int numBits;				int numBytes;		//total bytes in this bitmap to manage		char *map;			//the bits buffer};///
/// inode!
///class FileHeader {  public:    bool Allocate(BitMap *bitMap, int fileSize);    void Deallocate(BitMap *bitMap);  	    void FetchFrom(int sectorNumber, int pos);     void WriteBack(int sectorNumber, int pos); 	    int ByteToSector(int offset);	    int FileLength();		    void Print();			void s_Allocate(s_Bitmap *zMap, char *data, int size);	void s_DeAllocate(s_Bitmap *zMap);	int s_fileMode;							//file attribute	int s_dataSectors[s_NUM_OF_INDEX];		//data slot numbers    int numBytes;							//file size};#endif // FILEHDR_H

⌨️ 快捷键说明

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