⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defrag.h

📁 PDA上的CF CARD 文件系统的建立程式
💻 H
字号:

#ifndef _DEFRAG_H
#define _DEFRAG_H

#include "ramdisk.h"


struct entryInfo
{
  struct directory *theEntry;		// pointer to the file/dir's directory entry
  void *prev;
  void *next;
};

struct pieceInfo
{
  void *piece;				// pointer to the piece
  void *next;
};



/*************************************************************
Fuction : readDirEntryInfo
	read the directory entry information of a directory
Input:
	entryList - the head of the entry list
	startBlock - the starting block of the directory
Output:
	0	no error is found
	-1	system error (check RDerrno)
Note:
**************************************************************/
int readDirEntryInfo(struct entryInfo *head, struct diskBlock *startBlock);


/*************************************************************
Fuction : clearDirEntryInfo
	clear the directory entry information list
Input:
	head - the head of the entry information list
Output:
	none
**************************************************************/
void clearDirEntryInfo(struct entryInfo *head);


/*************************************************************
Fuction : eLInsert
	insert an entry information into the information list
Input:
	head - the head of the entry information list
	entry - the target entry
Output:
	none
Note:
	Entries are inserted descendingly according to the
	start block address.
**************************************************************/
void eLInsert(struct entryInfo *head, struct entryInfo *entry);


/*************************************************************
Fuction : eLRemove
	remove an entry information and all those in front of this
	entry from the information list
Input:
	head - the head of the entry information list
	entry - the target entry
Output:
	none
Note:
	All Entries from the head of the list to the target entry
	(including) are removed from the entry information list.
**************************************************************/
void eLRemove(struct entryInfo *head, struct entryInfo *entry);


/*************************************************************
Fuction : eLUpdate
	update the entry addresses of the entries within a block
	that is a directory block which has been moved
Input:
	head - the head of the entry information list
	block - the starting location of the target block
	offset - the offset of movement
Output:
	none
Note:
**************************************************************/
void eLUpdate(struct entryInfo *head, void *block, long offset);


/*************************************************************
Fuction : pLInsert
	insert a piece information into the information list
Input:
	head - the head of the piece information list
	piece - the target piece information
Output:
	none
Note:
	Piece info are inserted ascendingly according to the
	start piece address.
**************************************************************/
void pLInsert(struct pieceInfo *head, struct pieceInfo *pieceInfo);


/*************************************************************
Fuction : clearPieceInfo
	clear the  information list
Input:
	head - the head of the entry information list
Output:
	none
**************************************************************/
void clearPieceInfo(struct pieceInfo *head);


/*************************************************************
Fuction : RD_defrag
	defragment the RAMDisk
Input:
	NONE
Output:
	0	no error is found
	-1	system error (check RDerrno)
Note:
	Remember to
	1. Check the file handle table if the buffered blocks
	   have been moved. Update any pointer in file handle
	   to the buffer block if it has been moved.
	2. Check the FirstFreeBlock to see if it has been moved.
	   Oh, this is easy - just set FirstFreeBlock to the
	   resulting single free block.
	3. Check the directory entries because the starting
	   block of a file may have been moved to other place.
**************************************************************/
int RD_defrag(void);


#endif

⌨️ 快捷键说明

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