📄 dosfslibp.h
字号:
/* dosFsLibP.h - DOS file system private header file */
/* Copyright 1984-1999 Wind River Systems, Inc. */
/* modification history
--------------------
01h,31aug99,jkf CBIO API overhaul changes.
01i,31jul99,jkf added DOS_BOOT_FSTYPE_ID, and DOS_BOOT_FSTYPE_LEN,
SPR#28272, 28273, 28274, 28275.
01h,31jul99,jkf T2 merge, tidiness & spelling.
01g,21dec98,mjc changed name of <contigEnd> field in structure <DOS_FILE_HDL>
to <contigEndPlus1>
01f,22nov98,vld field <seekOut> changed to <seekOutPos> in
DOS_FILE_DESC structure;
added macros POS_TO_DD_COOKIE() and DD_COOKIE_TO_POS();
fields <rootStartSec> and <rootNSec> added to
DOS_DIR_DESC structure
01e,23sep98,vld field <bufToDisk> added to CHK_DSK_DESC;
01d,17sep98,vld field <activeCopyNum> added to DOS_FAT_DESC;
changed prototypes of some func ptr fields of DOS_FAT_DESC;
func ptr field <syncToggle> added to DOS_FAT_DESC;
added constant DOS_FAT_RAW;
added constant DOS_FAT_SET_ALL;
changed prototypes of some function ptrs
in DOS_FAT_DESC;
01c,16sep98,vld definition of DOS_VOL_LABEL_LEN moved to dosFsLib.h
01b,02jul98,lrn ready for prerelease
01a,22jan98,vld written,
*/
#ifndef __INCdoFsLibP
#define __INCdoFsLibP
#ifdef __cplusplus
extern "C" {
#endif
#include "vxWorks.h"
#include "semLib.h"
#include "iosLib.h"
#include "private/semLibP.h"
#include "cbioLib.h"
#include "dirent.h"
#include "stat.h"
#include "dosFsLib.h"
/* defines */
/* use 64-bit arithmetic */
#define SIZE64
#define DOS_FS_MAGIC 0xdfac9723 /* used for verification of vol desc */
#define DOS_VX_LONG_NAMES_SYS_ID "VXEXT"
#define SLASH '/'
#define BACK_SLASH '\\'
#define DOT '.'
#define SPACE ' '
/*
* handlers ID.
* Each handler (FAT, Directory and so on) must have its own
* identification number in order to be able to distinguish
* different handler types when selecting handlers
*/
/* directory handlers */
#define DOS_DIR_HDLR_MASK (1 << 8) /* dir handlers mask */
#define DOS_DIROLD_ID (DOS_DIR_HDLR_MASK +1) /* 8.3 and vxLong names */
/* FAT handlers */
#define DOS_FAT_HDLR_MASK (1 << 9) /* fat handlers mask */
/* function arguments */
/* for directory handler API */
#define DH_TIME_CREAT 1
#define DH_TIME_MODIFY (1<<1)
#define DH_TIME_ACCESS (1<<2)
#define DH_DELETE (1<<8)
/* FAT handler API */
#define FAT_NOT_ALLOC 0
#define FAT_ALLOC (1<<31)
#define FAT_ALLOC_ONE (FAT_ALLOC|1)
#define FH_INCLUDE 0
#define FH_EXCLUDE 1
#define FH_FILE_START ((u_int)(-1))
/* dosFs file system constants */
#define DOS_BOOT_SEC_NUM 0 /* sector number of boot sector */
#define DOS_MIN_CLUST 2 /* lowest cluster number used */
#define DOS_SYS_ID_LEN 8 /* length of system ID string */
#define DOS_FAT_12BIT_MAX 4085 /* max clusters for 12-bit FAT entries*/
#define DOS_NFILES_DEFAULT 20 /* default max number of files */
/* Boot sector offsets */
/* Because the MS-DOS boot sector format has word data items
* on odd-byte boundaries, it cannot be represented as a standard C
* structure. Instead, the following symbolic offsets are used to
* isolate data items. Non-string data values longer than 1 byte are
* in "Intel 8086" order.
*
* These definitions include fields used by MS-DOS Version 4.0.
*/
#define DOS_BOOT_JMP 0x00 /* 8086 jump instruction (3 bytes)*/
#define DOS_BOOT_SYS_ID 0x03 /* system ID string (8 bytes)*/
#define DOS_BOOT_BYTES_PER_SEC 0x0b /* bytes per sector (2 bytes)*/
#define DOS_BOOT_SEC_PER_CLUST 0x0d /* sectors per cluster (1 byte) */
#define DOS_BOOT_NRESRVD_SECS 0x0e /* # of reserved sectors (2 bytes)*/
#define DOS_BOOT_NFATS 0x10 /* # of FAT copies (1 byte) */
#define DOS_BOOT_MAX_ROOT_ENTS 0x11 /* max # of root dir entries (2 bytes)*/
#define DOS_BOOT_NSECTORS 0x13 /* total # of sectors on vol (2 bytes)*/
#define DOS_BOOT_MEDIA_BYTE 0x15 /* media format ID byte (1 byte) */
#define DOS_BOOT_SEC_PER_FAT 0x16 /* # of sectors per FAT copy (2 bytes)*/
#define DOS_BOOT_SEC_PER_TRACK 0x18 /* # of sectors per track (2 bytes)*/
#define DOS_BOOT_NHEADS 0x1a /* # of heads (surfaces) (2 bytes)*/
#define DOS_BOOT_NHIDDEN_SECS 0x1c /* # of hidden sectors (4 bytes)*/
#define DOS_BOOT_LONG_NSECTORS 0x20 /* total # of sectors on vol (4 bytes)*/
#define DOS_BOOT_DRIVE_NUM 0x24 /* physical drive number (1 byte) */
#define DOS_BOOT_SIG_REC 0x26 /* boot signature record (1 byte) */
#define DOS_BOOT_VOL_ID 0x27 /* binary volume ID number (4 bytes)*/
#define DOS_BOOT_VOL_LABEL 0x2b /* volume label string (11 bytes)*/
#define DOS_BOOT_FSTYPE_ID 0x36 /* new MS ID, FAT12 or FAT16 */
#define DOS_BOOT_FSTYPE_LEN 0x08 /* length in bytes of FSTYPE */
#define DOS_BOOT_FSTYPE_FAT16 "FAT16 " /* FSTYPE_ID FAT16 */
#define DOS_BOOT_FSTYPE_FAT12 "FAT12 " /* FSTYPE_ID FAT12 */
#define DOS_BOOT_SYSID_FAT32 "FAT32 " /* FAT32 SYS_ID, */
#define DOS_BOOT_PART_TBL 0x1be /* first disk partition tbl (16 bytes)*/
#define DOS_EXT_BOOT_SIG 0x29 /* value written to boot signature */
/* record to indicate extended */
/* (DOS v4) boot record in use */
/* extended FAT32 fields offsets */
#define DOS32_BOOT_SEC_PER_FAT 0x24 /* sectors per FAT (4 bytes)*/
#define DOS32_BOOT_EXT_FLAGS 0x28 /* FAT miscellaneous flags (2 bytes)*/
#define DOS32_BOOT_FS_VERSION 0x2a /* file system version (2 bytes)*/
#define DOS32_BOOT_ROOT_START_CLUST 0x2c /* root start cluster (4 bytes)*/
#define DOS32_BOOT_FS_INFO_SEC 0x30 /* file system info sector (2 bytes)*/
#define DOS32_BOOT_BOOT_BKUP 0x32 /* bkup of boot sector (2 bytes)*/
#define DOS32_BOOT_RESERVED 0x3a /* reserved area (6 bytes)*/
#define DOS32_BOOT_BIOS_DRV_NUM 0x40 /* 0x80 for hard disk (1 byte)*/
#define DOS32_BOOT_SIGNATURE 0x42 /* ')' (0x29) (1 byte)*/
#define DOS32_BOOT_VOL_ID 0x43 /* binary volume Id (4 bytes*/
#define DOS32_BOOT_VOL_LABEL 0x47 /* volume label string (11 bytes)*/
#define DOS32_BOOT_FS_TYPE 0x52 /* string FAT32 */
#define DOS_BOOT_BUF_SIZE 0x80 /* size of buffer large enough to */
/* get boot sector data to */
/* ( without partition table ) */
#define CHK_MAX_PATH 1024 /* max path in check disk's message */
/* macros */
/* endian data conversion macros, disk always L.E. */
#define DISK_TO_VX_16( pSrc ) (UINT16)( \
( *((u_char *)(pSrc)+1) << 8 ) | \
( *(u_char *)(pSrc) ) )
#define DISK_TO_VX_32( pSrc ) (UINT32)( \
( *((u_char *)(pSrc)+3)<<24 ) | \
( *((u_char *)(pSrc)+2)<<16 ) | \
( *((u_char *)(pSrc)+1)<< 8 ) | \
( *(u_char *)(pSrc) ) )
#define VX_TO_DISK_16( src, pDst ) \
( * (u_char *)(pDst) = (src) & 0xff, \
*((u_char *)(pDst) + 1) = ((src)>> 8) & 0xff )
#define VX_TO_DISK_32( src, pDst ) \
( * (u_char *)(pDst) = (src) & 0xff, \
*((u_char *)(pDst) + 1) = ((src)>> 8) & 0xff, \
*((u_char *)(pDst) + 2) = ((src)>> 16) & 0xff, \
*((u_char *)(pDst) + 3) = ((src)>> 24) & 0xff ) \
/* sector macros */
#define NSECTORS( pVolDesc, off ) ( (off) >> (pVolDesc)->secSizeShift )
#define OFFSET_IN_SEC( pVolDesc, off ) \
( (off) & ((pVolDesc)->bytesPerSec - 1) )
/* conversions of sector <-> cluster numbers */
/* check, if directory is root */
#define IS_ROOT( pFd ) \
((pFd)->pFileHdl->dirHdl.parDirStartCluster == (u_long) NONE)
#define ROOT_SET( pFd ) \
((pFd)->pFileHdl->dirHdl.parDirStartCluster = NONE)
/* FAT entry types, returned by clustValueSet() and clustValueGet() */
#define DOS_FAT_AVAIL 0x00000001 /* available cluster */
#define DOS_FAT_EOF 0x00000002 /* end of file's cluster chain */
#define DOS_FAT_BAD 0x00000004 /* bad cluster (damaged media) */
#define DOS_FAT_ALLOC 0x00000008 /* allocated cluster */
#define DOS_FAT_INVAL 0x00000010 /* invalid cluster (illegal value) */
#define DOS_FAT_RESERV 0x00000020 /* reserved cluster */
#define DOS_FAT_RAW 0x00000040 /* write raw data, when fat copy */
/* is used as temporary buffer */
#define DOS_FAT_SET_ALL 0x00000080 /* fill all bytes of FAT copy with */
/* a specified value. */
#define DOS_FAT_ERROR 0x11111111 /* CBIO ERROR */
/*
* handlers Id-s. All installed handlers are sorted by
* Id-s, and are tried on every volume in accordance with that order
*/
#define DOS_MAX_HDLRS 4 /* max handlers of one type */
#define DOS_FATALL_HDLR_ID 255 /* dosFsFat16 - supports FAT 12/16/32 */
/* in a simple manner */
/* ( without any buffering ) */
#define DOS_VDIR_HDLR_ID 1 /* dosVDirLib - supports VDIR */
/* directory structure for all FAT types */
#define DOS_DIROLD_HDLR_ID 2 /* dosDirOldLib - supports DOS4.0 */
/* "8.3" names and vxLong names for */
/* all FAT types */
/* definition of 64-bit type and macro to check for 32-bit overflowing */
#ifdef SIZE64
typedef long long fsize_t;
#define DOS_IS_VAL_HUGE( val ) ( ( (fsize_t)(val) >> 32 ) != 0 )
/* test for 32 bit overflowing */
#define DOS_MAX_FSIZE ( ~((fsize_t)1<<(sizeof(fsize_t)*8-1)) )
/* max disk/file size */
#else /* ! SIZE64 */
typedef u_long fsize_t;
#define DOS_IS_VAL_HUGE( val ) FALSE
#define DOS_MAX_FSIZE ( (fsize_t)(-1) ) /* max disk/file size */
#endif /* SIZE64 */
/*
* processing for dd_cookie field in DIR structure.
* Current position in directory supposed to be always power of 2
*/
#define POS_TO_DD_COOKIE( pos ) ( ((u_long)(pos)) | 1 )
#define DD_COOKIE_TO_POS( pDir ) ( ((DIR *)(pDir))->dd_cookie & (~1) )
/* typedefs */
typedef struct DOS_VOLUME_DESC * DOS_VOLUME_DESC_ID;
/*
* Directory entry descriptor.
* This structure is part of file handle and
* is intended to directory handlers usage.
*/
typedef struct DOS_DIR_HDL
{
u_int parDirStartCluster; /* sector containing parent */
/* directory entry */
block_t sector; /* sector containing alias (short name) */
/* directory entry */
off_t offset; /* alias (short name) directory entry offset */
/* in sector */
block_t lnSector; /* sector containing long name start */
off_t lnOffset; /* long name offset in sector */
cookie_t cookie; /* for cache quick access */
/* implementation private usage */
u_long dh_Priv1;
u_long dh_Priv2;
u_long dh_Priv3;
u_long dh_Priv4;
u_char crc; /* crcon directory entry (not used) */
} DOS_DIR_HDL;
typedef DOS_DIR_HDL * DOS_DIR_HDL_ID;
/*
* File FAT descriptor.
* This structure is part of file descriptor and
* is intended to FAT handlers usage.
*/
typedef struct DOS_FAT_HDL
{
uint32_t lastClust; /* number of last passed cluster in chain */
uint32_t nextClust; /* contents of <lastClust> entry */
cookie_t cbioCookie; /* CBIO dev. cookie for last accessed sector */
uint32_t errCode; /* */
} DOS_FAT_HDL;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -