91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

用文件仿硬盤的C語言程序——模仿linux下的EXT2文件系統(tǒng),類EXT2文件系統(tǒng)

資源截圖

代碼片段和文件信息

#define?DATA_BLOCK?263680
#define?BLOCK_SIZE?512
#define?DISK_START?0
#define?BLOCK_BITMAP?512
#define?INODE_BITMAP?1024
#define?INODE_TABLE?1536
#define?INODE_SIZE?64
#include?
#include?
#include?
#include?


struct?group_desc{
????char?bg_volume_name[16];?/*卷名*/
????unsigned?short?bg_block_bitmap;?/*保存塊位圖的塊號*/
????unsigned?short?bg_inode_bitmap;?/*保存索引結點位圖的塊號*/
????unsigned?short?bg_inode_table;?/*索引結點表的起始塊號*/
????unsigned?short?bg_free_blocks_count;?/*本組空閑塊的個數(shù)*/
????unsigned?short?bg_free_inodes_count;?/*本組空閑索引結點的個數(shù)*/
????unsigned?short?bg_used_dirs_count;?/*本組目錄的個數(shù)*/
????char?bg_pad[4];?/*填充(0xff)*/
};
struct?inode{
????unsigned?short?i_mode;?/*文件類型及訪問權限*/???????
????unsigned?short?i_blocks;?/*文件的數(shù)據(jù)塊個數(shù)*/
????unsigned?long?i_size;?/*大小(?字節(jié))*/
????unsigned?long?i_atime;?/*訪問時間*/
????unsigned?long?i_ctime;?/*創(chuàng)建時間*/
????unsigned?long?i_mtime;?/*修改時間*/
????unsigned?long?i_dtime;?/*刪除時間*/
????unsigned?short?i_block[8];?/*指向數(shù)據(jù)塊的指針*/
????char?i_pad[24];?/*填充(0xff)*/
};
struct?dir_entry{???//目錄項結構
????unsigned?short?inode;?/*索引節(jié)點號*/
????unsigned?short?rec_len;?/*目錄項長度*/
????unsigned?short?name_len;?/*文件名長度*/
????char?file_type;?/*文件類型(1:?普通文件,?2:?目錄..?)*/
????char?name[9];?/*文件名*/
};

char?Buffer[512];??//針對數(shù)據(jù)塊的?緩沖區(qū)
char?tempbuf[4097];?//
unsigned?char?bitbuf[512];?//位圖緩沖區(qū)
unsigned?short?index_buf[256];
short?fopen_table[16];?//??文件打開表
unsigned?short?last_alloc_inode;?//??最近分配的節(jié)點號
unsigned?short?last_alloc_block;?//??最近分配的數(shù)據(jù)塊號
unsigned?short?current_dir;???//??????當前目錄的節(jié)點號
struct?group_desc?super_block[1];?//???組描述符緩沖區(qū)
struct?inode?inode_area[1];??//???節(jié)點緩沖區(qū)
struct?dir_entry?dir[32];???//??目錄項緩沖區(qū)
char?current_path[256];????//????當前路徑名
unsigned?short?current_dirlen;
FILE?*fp;


/*************************************????????alloc??????????*******************************************************/


void?update_group_desc()
{
????fseek(fpDISK_STARTSEEK_SET);
????fwrite(super_blockBLOCK_SIZE1fp);
}
void?reload_group_desc()//載入組描述符
{
????fseek(fpDISK_STARTSEEK_SET);
????fread(super_blockBLOCK_SIZE1fp);
}
void?update_inode_bitmap()//更新inode位圖?
{
????fseek(fpINODE_BITMAPSEEK_SET);
????fwrite(bitbufBLOCK_SIZE1fp);
}
void?reload_inode_bitmap()//載入inode位圖?
{
????fseek(fpINODE_BITMAPSEEK_SET);
????fread(bitbufBLOCK_SIZE1fp);
}
void?update_block_bitmap()//更新block位圖?
{
????fseek(fpBLOCK_BITMAPSEEK_SET);
????fwrite(bitbufBLOCK_SIZE1fp);
}
void?reload_block_bitmap()//載入block位圖?
{
????fseek(fpBLOCK_BITMAPSEEK_SET);
????fread(bitbufBLOCK_SIZE1fp);
}
void?update_inode_entry(unsigned?short?i)//更新第i個inode入口?
{
????fseek(fpINODE_TABLE+(i-1)*INODE_SIZESEEK_SET);
????fwrite(inode_areaINODE_SIZE1fp);
}
void?reload_inode_entry(unsigned?short?i)//載入第i個inode入口
{
????fseek(fpINODE_TABLE+(i-1)*INODE_SIZESEEK_SET);
????fread(inode_areaINODE_SIZE1fp);
}

void?reload_dir(unsigned?short?i)//更新第i個目錄?
{
????fs

評論

共有 條評論