📄 dosfslib.c
字号:
.iP "FIOLABELSET"Sets the volume label to the string specified as <newLabel>. The string mayconsist of up to eleven ASCII characters:.CS status = ioctl (fd, FIOLABELSET, "newLabel");.CE.iP "FIOATTRIBSET"Sets the file attribute byte in the DOS directory entry to the new value<newAttrib>. The file descriptor refers to the file whose entry is to be modified:.CS status = ioctl (fd, FIOATTRIBSET, newAttrib);.CE.iP "FIOCONTIG"Allocates contiguous disk space for a file or directory. The number ofbytes of requested space is specified in <bytesRequested>. In general,contiguous space should be allocated immediately after the file iscreated:.CS status = ioctl (fd, FIOCONTIG, bytesRequested);.CE.iP "FIONCONTIG"Copies to <maxContigBytes> the size of the largest contiguous free space, in bytes, on the volume:.CS status = ioctl (fd, FIONCONTIG, &maxContigBytes);.CE.iP "FIOREADDIR"Reads the next directory entry. The argument <dirStruct> is a DIRdirectory descriptor. Normally, the readdir() routine is used to read adirectory, rather than using the FIOREADDIR function directly. See dirLib..CS DIR dirStruct; fd = open ("directory", O_RDONLY); status = ioctl (fd, FIOREADDIR, &dirStruct);.CE.iP "FIOFSTATGET"Gets file status information (directory entry data). The argument<statStruct> is a pointer to a stat structure that is filled with datadescribing the specified file. Normally, the stat() or fstat() routine isused to obtain file information, rather than using the FIOFSTATGETfunction directly. See dirLib..CS struct stat statStruct; fd = open ("file", O_RDONLY); status = ioctl (fd, FIOFSTATGET, &statStruct);.CE.LPAny other ioctl() function codes are passed to the block device driver forhandling.MEMORY CONSUMPTIONIn order to minimize memory fragmentation in the system memory pool, allmemory consumed by dosFsLib will be contained within a dedicated memorypartition. This partition is accessible via the <dosFsMemPartId> globalvariable.To display the current amount of memory used by dosFsLib, callshow(dosFsMemPartId). Please see the manual page for memPartShow() formore details.The following varibles may be set .I before dosFsLibis initialized to change the behavior of the memory management.If the dosFsLib memory partition is not provided, one will be allocated fromthe system memory pool. It's size defaults to 8 K, which may be changedvia the <dosFsMemPartInitSize> global. To provide a memory pool, set <dosFsMemPartId> to a valid PART_ID returned from memPartCreate().The global variable <dosFsMemPartIdOptions> may be modified to change thebehavior of error handling for errors in malloc() and free(). Theoptions default to MEM_BLOCK_ERROR_LOG_FLAG, which will log informationabout errors detected by free(). These options only affect operations onthe dosFs memory partition.The private partition will dynamically grow as much as needed, allocatingadditional memory from the system memory pool, in units no smaller than 1 Kilobyte. This minumum unit size may be adjusted via the <dosFsMemPartGrowSize> global variable.The maximum size for the dosFs memory partition may be limited via the global variable <dosFsMemPartCap>. Once the cap limit has been reached or surpassed, dosFs will not attempt to allocate more memory from the system memory partition. The default value is -1, which allows uninterupted use of the system memory partition.Additional debugging may be enabled via the global boolean <dosFsDebug>.Setting this to 1 will enable verbose debug messages from the dosFs memory manager.INCLUDE FILES: dosFsLib.hSEE ALSO:ioLib, iosLib, dirLib, ramDrv,.I "Microsoft MS-DOS Programmer's Reference"(Microsoft Press),.I "Advanced MS-DOS Programming"(Ray Duncan, Microsoft Press),.I "VxWorks Programmer's Guide: I/O System, Local File Systems"INTERNAL:Note: To represent a backslash in documentation use "\e", not "\\".The double backslash sometimes works, but results may be unpredictable.NFS needs a way to uniquely identify files using 32 bytes or less ofinformation. For DOS, we use the inode number field (st_ino) of the statstructure to return two items of information: the "generation number," acounter that is incremented every time a file is created and maintained on aper-filesystem basis, and the starting cluster number of the file. Whenfiles are added to the directory entry tree, they are also added to a hashtable keyed off of the starting cluster number. Mapping between thegeneration/cluster number is a simple search of the hash table to locate amatching entry. The generation number is stored in the first two bytes ofthe FAT for each file system.*//* LINTLIBRARY */#include "vxWorks.h"#include "ctype.h"#include "dirent.h"#include "ioLib.h"#include "lstLib.h"#include "dosFsLib.h"#include "stdlib.h"#include "semLib.h"#include "sys/stat.h"#include "string.h"#include "errnoLib.h"#include "stdio.h"#include "pathLib.h"#include "time.h"#include "utime.h"#include "tickLib.h"#include "taskLib.h"#include "private/memPartLibP.h"#include "logLib.h"#define DEFAULT_MAX_ROOT_ENTS 112 /* default max # of root dir entries */#define DEFAULT_SEC_PER_CLUST 2 /* default sectors per cluster */#define DEFAULT_MEDIA_BYTE 0xF0 /* default media byte value */#define DEFAULT_NFATS 2 /* default number FAT copies */#define DEFAULT_NHIDDEN 0 /* default number of hidden sectors */#define DEFAULT_NRESERVED 1 /* default # of reserved sec's (min=1)*/#define DEFAULT_OPTIONS 0 /* default volume options */#define DOS_DEFAULT_HASH_SIZE 9 /* default hash table size (2^x) */ /* default NFS file permissions */#define DOS_DEFAULT_MODE (S_IRWXU | S_IRWXG | S_IRWXO)#define DOT_PADDED ". " /* "." padded to long filename length */#define DOTDOT_PADDED ".. " /* ".." padded to long filename length*/#define EXT_SPACES " " /* file extension-length set of spaces*/#define MODIFIED 1 /* "boolean" flags for FAT mod table */#define NOT_MODIFIED 0#define DOS_OPT_ALL (DOS_OPT_CHANGENOWARN | \ DOS_OPT_AUTOSYNC | \ DOS_OPT_LONGNAMES | \ DOS_OPT_EXPORT | \ DOS_OPT_LOWERCASE) /* all valid options */#define DOS_OPT_DYNAMIC (DOS_OPT_CHANGENOWARN | \ DOS_OPT_AUTOSYNC) /* dynamically changable options */#define DOS_OPT_INIT (DOS_OPT_DYNAMIC | DOS_OPT_EXPORT | DOS_OPT_LOWERCASE) /* options set during dosFsDevInit *//* Macros to test for options - * "vdptr" must be defined where these are used!! */#define AUTOSYNC_ENABLED (vdptr->dosvd_options & DOS_OPT_AUTOSYNC ? \ TRUE : FALSE)#define CHANGENOWARN_ENABLED (vdptr->dosvd_options & DOS_OPT_CHANGENOWARN ? \ TRUE : FALSE)#define LONGNAMES_ENABLED (vdptr->dosvd_options & DOS_OPT_LONGNAMES ? \ TRUE : FALSE)#define EXPORT_ENABLED (vdptr->dosvd_options & DOS_OPT_EXPORT ? \ TRUE : FALSE)#define LOWERCASE_ENABLED (vdptr->dosvd_options & DOS_OPT_LOWERCASE ? \ TRUE : FALSE)/* Macros for effective filename and on-disk directory entry sizes - * "vdptr" must be defined where these are used!! */#define EFFECTIVE_NAME_LEN (LONGNAMES_ENABLED ? \ DOS_LONG_NAME_LEN : DOS_NAME_LEN)#define EFFECTIVE_DISK_DIR_ENT_SIZE (LONGNAMES_ENABLED ? \ sizeof (DOS_DISK_EDIR_ENT) : \ sizeof (DOS_DISK_DIR_ENT))/* Macros to test if file name is "." or ".." * "vdptr" must be defined where these are used!! */#define IS_DOT(name) (strncmp ((char *) name, pDotPadded, \ EFFECTIVE_NAME_LEN) == 0)#define IS_DOTDOT(name) (strncmp ((char *) name, pDotDotPadded, \ EFFECTIVE_NAME_LEN) == 0)/* Define byte-swap functions as macros - some arch's may not need them */#if (_BYTE_ORDER == _BIG_ENDIAN) /* swapping macros for BIG_ENDIAN *//* Aligned transfers */#define SWAB(pSource16, pDest16) \ swab ((char *) pSource16, (char *) pDest16, 2)#define SWABL(pSource32, pDest32) \ {swab ((char *) pSource32 + 2, (char *) pDest32, 2); \ swab ((char *) pSource32, (char *) pDest32 + 2, 2);}#define SWABL2S(pSource32, pDest16) \ swab ((char *) pSource32 + 2, (char *) pDest16, 2)#define SWABS2L(pSource16, pDest32) \ swab ((char *) pSource16, (char *) pDest32 + 2, 2)#if (_DYNAMIC_BUS_SIZING == FALSE)/* unaligned transfers for big endian machines that do require alignment */#define USWAB(pSource16, pDest16) \ uswab ((char *) pSource16, (char *) pDest16, 2)#define USWABL(pSource32, pDest32) \ {uswab ((char *) pSource32 + 2, (char *) pDest32, 2); \ uswab ((char *) pSource32, (char *) pDest32 + 2, 2);}#define USWABL2S(pSource32, pDest16) \ uswab ((char *) pSource32 + 2, (char *) pDest16, 2)#define USWABS2L(pSource16, pDest32) \ uswab ((char *) pSource16, (char *) pDest32 + 2, 2)#else /* _DYNAMIC_BUS_SIZING == TRUE *//* unaligned transfers for big endian machines that don't require alignment */#define USWAB(pSource16, pDest16) SWAB(pSource16, pDest16)#define USWABL(pSource32, pDest32) SWABL(pSource32, pDest32)#define USWABL2S(pSource32, pDest16) SWABL2S(pSource32, pDest16)#define USWABS2L(pSource16, pDest32) SWABS2L(pSource16, pDest32)#endif /* _DYNAMIC_BUS_SIZING == TRUE */#else /* _BYTE_ORDER == _BIG_ENDIAN (little endian swapping macros) */ /* aligned transfers */#define SWAB(pSource16, pDest16) (*pDest16 = *pSource16)#define SWABL(pSource32, pDest32) (*pDest32 = *pSource32)#define SWABL2S(pSource32, pDest16) (*pDest16 = * (UINT16 *) pSource32)#define SWABS2L(pSource16, pDest32) (*pDest32 = (UINT32) *pSource16) /* unaligned transfers */#define USWAB(pSource16, pDest16) bcopy ((char *) (pSource16), \ (char *) (pDest16), 2)#define USWABL(pSource32, pDest32) bcopy ((char *) (pSource32), \ (char *) (pDest32), 4)#define USWABL2S(pSource32, pDest16) bcopy ((char *) (pSource32), \ (char *) (pDest16), 2)#define USWABS2L(pSource16, pDest32) bcopy ((char *) (pSource16), \ (char *) (pDest32), 2)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -