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

📄 dosfslibp.h

📁 用于EQUATOR处理器上的FAT32文件系统(vxWorks5.5)
💻 H
📖 第 1 页 / 共 2 页
字号:
typedef DOS_FAT_HDL *	DOS_FAT_HDL_ID;

/*
 * File handle.
 * This structure is shared by all file descriptors (see below).
 * that are opened for the same file.
 * Field <pDirHdl> is filled and used by directory handler.
 */
typedef struct DOS_FILE_HDL
    {
    fsize_t	size;		/* recent file size */
    u_int	deleted  : 1,	/* file deleted */
    		obsolet  : 1,	/* file was changed, but not closed yet */
    		changed  : 1,	/* file was changed, but not closed yet */
    		res	 : 29;

    /* FAT fields */

    uint32_t	startClust;	/* file start cluster */
    				/* ( 0 - not allocated yet ) */
    uint32_t	contigEndPlus1;	/* end clust. of contiguous area in file + 1 */
    uint32_t	fatSector;	/* last modified FAT sector */

    DOS_DIR_HDL	dirHdl;		/* directory entry descriptor */

    u_short	nRef;		/* reference count - the number of times */
    				/* file is simultaneously opened */
    u_char	attrib;		/* file attributes */
    } DOS_FILE_HDL;

typedef DOS_FILE_HDL *	DOS_FILE_HDL_ID;

/*
 * File descriptor.
 * This structure is allocated every time new file is opened.
 * Fields <curSec>, <nSec>, <cluster> are filled by fat handler
 * via get next cluster operation and then are corrected by other
 * modules in accordance with operation being executed.
 */
typedef struct DOS_FILE_DESC
    {
    DOS_VOLUME_DESC_ID	pVolDesc;	/* volume descriptor ptr */
    DOS_FILE_HDL_ID	pFileHdl;	/* file handle, that is shared */
    					/* between file descriptors */
    					/* of the same file */
    fsize_t	pos;		/* current absolute position in file */
    	    	    	    	/* for directory: absolute offset from */
				/* from directory start */
    fsize_t	seekOutPos;	/* save position in case seek passes EOF */
    	    	    	    	/* contains 0, if no such seek occurred */
    block_t	curSec;		/* current data sector */
    u_int	nSec;		/* number of contiguous sectors */
    cookie_t	cbioCookie;	/* last accessed sector ptr */
    				/* ( is filled by cbio ) */
    u_char	accessed;	/* file was accessed */
    u_char	changed;	/* file was changed */
    
    DOS_FAT_HDL	fatHdl;
    
    u_char	openMode;	/* open mode ( DRONLY/WRONLY/RDWR ) */
    
    BOOL	busy;
    } DOS_FILE_DESC;

typedef DOS_FILE_DESC *	DOS_FILE_DESC_ID;

/*
 * FAT handler descriptor.
 * This structure defines generic FAT handler API.
 * It must be start field in every FAT handler
 * descriptor structure.
 */
typedef struct DOS_FAT_DESC
    {
    /* interface functions */
    
    STATUS (*getNext)( DOS_FILE_DESC_ID pFd, u_int allocatePolicy );
    			/* get/allocate next cluster for file */
			/* <allocatePolicy> : FAT_NOT_ALLO/FAT_ALLOC/ */
			/* FAT_ALLOC_ONE */
    STATUS (*contigChk)( DOS_FILE_DESC_ID pFd );
    			/* check file chain for contiguity */
    STATUS (*truncate)( DOS_FILE_DESC_ID pFd, uint32_t sector,
                        uint32_t flag );
    			/* truncate chain starting from <sector>, */
			/* <sector> = FH_FILE_START - from file start; */
			/* <flag> : FH_INCLUDE/FH_EXCLUDE */
    STATUS (*seek)( DOS_FILE_DESC_ID pFd, uint32_t startSec, uint32_t nSec );
    			/* seek <nSec> sectors starting from */
    			/* <startClust>, */
			/* <startClust> = FH_FILE_START - from file start */
    fsize_t (*nFree)( DOS_FILE_DESC_ID pFd );
			/* free bytes on disk */
    STATUS (*contigAlloc)( DOS_FILE_DESC_ID pFd, uint32_t nSec );
			/* allocate <nSec> contiguous first feet chain */
    size_t (*maxContig)( DOS_FILE_DESC_ID pFd );
			/* max free contiguous chain length in sectors */
    void (*volUnmount)( DOS_VOLUME_DESC_ID pVolDesc );
    			/* free all resources, that were allocated */
    			/* for the volume */
    void (*show)( DOS_VOLUME_DESC_ID pVolDesc );
			/* display handler specific data */
    STATUS (*flush)( DOS_FILE_DESC_ID pFd );
			/* flush all internal FAT handler data that */
			/* belongs to the file */
    void (*syncToggle)( DOS_VOLUME_DESC_ID pVolDesc, BOOL syncEnable );
			/* toggle FAT copies mirroring; synchronize */
			/* FAT copies, when mirror is being enabled */
    STATUS (*clustValueSet)
        (
        DOS_FILE_DESC_ID	pFd,
    	uint32_t	fatCopyNum,	/* FAT copy to use */	
        uint32_t	clustNum,	/* cluster number to set */
        uint32_t	value,		/* DOS_FAT_AVAIL, DOS_FAT_EOF, */
					/* DOS_FAT_BAD, DOS_FAT_ALLOC, */
					/* DOS_FAT_INVAL, DOS_FAT_RESERV, */
					/* DOS_FAT_RAW */
        uint32_t	nextClust	/* next cluster number */
        );
    uint32_t (*clustValueGet)
        (
        DOS_FILE_DESC_ID	pFd,
    	uint32_t	fatCopyNum,	/* FAT copy to use */	
        uint32_t	clustNum,	/* cluster number to check */
        uint32_t *	pNextClust	/* return cluster value */
        );

    uint8_t	activeCopyNum;	/* number of active FAT copy */
    } DOS_FAT_DESC;

typedef DOS_FAT_DESC * 	DOS_FAT_DESC_ID;

/*
* Directory handler descriptor.
 * This structure defines generic directory handler API.
 * It must be start field in every directory handler
 * descriptor structure.
 */
typedef struct DOS_DIR_DESC
    {
    STATUS (*pathLkup)( DOS_FILE_DESC_ID pFd, void * pPath,
    		        u_int creatFlags );
    			/* lkup path file in directory hierarchy tree */
    STATUS (*readDir)( DOS_FILE_DESC_ID pFd, DIR * pDir,
		       DOS_FILE_DESC_ID pResFd );
    			/* regular readdir; <pResFd> if not NULL, is */
			/* filled for entry just accepted */
			/* on exit <pdir->dd_coocie> should contain */
			/* POS_TO_DD_COOKIE( pFd->pos ) */
    STATUS (*updateEntry)( DOS_FILE_DESC_ID pFd, u_int flags,
			   time_t curTime );
    			/* set directory entry values; */
    			/* size, start cluster, attributes and so on */
    			/* are delivered from file descriptor */ 
    			/* <flags> can be or-ed of */
    			/* DH_TIME_CREAT, DH_TIME_MODIFY, DH_TIME_ACCESS */
    	    	    	/* to encode <curTime> value into correspondence */
			/* field or DH_DELETE for to delete the entry */
    STATUS (*dateGet)( DOS_FILE_DESC_ID pFd, struct stat * pStat );
    			/* fill in date-time fields in stat structure */
    STATUS (*volLabel)( DOS_VOLUME_DESC_ID pVolDesc, u_char * label,
			u_int operation );
			/* get/set volume label */
			/* <operation> is one of FIOLABELGET/FIOLABELSET */
    STATUS (*nameChk)( DOS_VOLUME_DESC_ID pVolDesc, u_char * name );
			/* validate name (intended to check disk) */
    void (*volUnmount)( DOS_VOLUME_DESC_ID pVolDesc );
    			/* free all resources, that were allocated */
    			/* for the volume */
    void (*show)( DOS_VOLUME_DESC_ID pVolDesc );
			/* display handler specific data */
    u_int	rootStartSec;	/* root directory start sector: */
    				/* some value for FAT12/FAT16; */
    				/* 0 for FAT32; is filled by dir handler */
    u_int	rootNSec;	/* sectors per root directory */
    				/* some value for FAT12/FAT16; */
    				/* 0 for FAT32; is filled by dir handler */
    } DOS_DIR_DESC;

typedef DOS_DIR_DESC * 	DOS_DIR_DESC_ID;

/* check disk work structure */ 
 
typedef struct CHK_DSK_DESC 
    { 
    UINT32 *	chkFatMap;      /* clusters usage map */
    DIR		chkDir;        /* readdir buffer */
    fsize_t	chkTotalFSize;  /* total bytes in all files */
    fsize_t     chkTotalBytesInLostChains;
    u_int	nErrors;	/* total number of errors detected */
    UINT32      chkNDirs;       /* total directories */
    UINT32      chkNFiles;      /* total files */
    UINT32      chkNLostChains; /* total lost chains */
    UINT32      chkNFreeClusts; /* total # of free clusters */
    UINT32      chkNBadClusts;	/* total # of bad clusters */
    time_t	chkMaxCreatTime;
    time_t	chkMaxModifTime;
    time_t	chkMaxAccTime;
    BOOL	bufToDisk;	/* FAT copy used as tmp buffer */
    struct stat	stat;		/* buffer to accept file statistics */
    u_char	chkPath[ CHK_MAX_PATH ];	/* buffer for path strings */
    u_char	curPathLev;	/* dynamic counter of path levels */
    char	chkCurPath[ CHK_MAX_PATH + 256 ];
    } CHK_DSK_DESC;

typedef CHK_DSK_DESC * CHK_DSK_DESC_ID;

/* Volume descriptor */

typedef struct DOS_VOLUME_DESC
    {
    DEV_HDR     	devHdr;		/* i/o system device header */
    u_int		magic;		/* control magic number */
    					/* DOS_FS_MAGIC */
    BOOL		mounted;	/* volume mounted */
    CBIO_DEV_ID 	pCbio;		/* cached I/O device handle */
    DOS_DIR_DESC_ID	pDirDesc;	/* directory handler descriptor ptr */
    DOS_FAT_DESC_ID	pFatDesc;	/* FAT handler descriptor ptr */
    SEMAPHORE		devSem;		/* device mutual semaphore, */
    SEMAPHORE		shortSem;	/* protect very short operations, */
    					/* such as allocation of file */
    					/* descriptor */
    DOS_FILE_DESC_ID	pFdList;	/* file descriptors array */
    DOS_FILE_HDL_ID	pFhdlList;	/* file handles array */
    SEMAPHORE *		pFsemList;	/* file semaphores array */
    
    /* -- boot sector data -- */
    
    u_int	bootSecNum;	/* number of sector containing boot */
				/* information */
    UINT32	volId;		/* volume Id */
    UINT32	secPerFat;	/* sectors per FAT copy */
    UINT32	nHiddenSecs;	/* hiden sectors (unused tail) */
    UINT32	totalSec;	/* total number of sectors */
    UINT16	bytesPerSec;
    UINT16	secPerClust;
    UINT16	nReservedSecs;	/* reserved sectors (ahead first fat copy) */
    UINT8	nFats;		/* number of FAT copies */
    UINT32	nFatEnts;	/* number of entries in FAT */
    char	bootVolLab[ DOS_VOL_LABEL_LEN];	/* volume label */
    /*     --    --       */
    
    enum { FAT12, FAT16, FAT32 } fatType;

    u_int	dataStartSec;		/* sector number of the start */
    					/* cluster (DOS_MIN_CLUCT) */
    u_short	maxFiles;		/* maximum open files in a time */
    u_short	nBusyFd;		/* number of fd-s in use */
    u_short	volIdOff;		/* offset of volume Id field */
					/* in boot sector */
    u_short	volLabOff;		/* offset of volume label field */
					/* in boot sector */
    u_char	secSizeShift;		/* log2( bytesPerSect ) */

    /* check disk fields */

    CHK_DSK_DESC_ID	pChkDesc;
    u_char		autoChk;	/* autocheck on mount level */
    u_char		autoChkVerb;	/* autocheck verbosity */
    u_char		chkLevel;       /* check disk progress level */
    u_char		chkVerbLevel;   /* check disk verbosity level */

    FUNCPTR	fatVolMount;
    } DOS_VOLUME_DESC;

typedef struct DOS_HDLR_DESC
    {
    u_int	id;	/* unique handler Id */
			/* 0 - 256 reserved by implementation */
    STATUS (*mountRtn)( DOS_VOLUME_DESC_ID pVolDesc, void * arg );
    void *	arg;	/* handler dependent argument */
    }	DOS_HDLR_DESC;

typedef DOS_HDLR_DESC *	DOS_HDLR_DESC_ID;
    	    
/* function pointers to chk and fmt handlers */
IMPORT STATUS (*dosFsChkRtn)( DOS_FILE_DESC_ID pFd ); /* check disk routine */
IMPORT STATUS (*dosFsVolFormatRtn)( void * dev, int opt,
                                    FUNCPTR pPromptFunc );
/* handler lists for fat and dir handlers */
IMPORT DOS_HDLR_DESC	dosFatHdlrsList[];
IMPORT DOS_HDLR_DESC	dosDirHdlrsList[];

/* forward declarations */

IMPORT STATUS dosFsHdlrInstall( DOS_HDLR_DESC_ID hdlrsList,
			        DOS_HDLR_DESC_ID hdlr );

#ifdef __cplusplus
    }
#endif

#endif /* __INCdoFsLibP */

⌨️ 快捷键说明

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