Download VxWorks Reference Manual 5.3.1
Transcript
VxWorks Reference Manual, 5.3.1
dosFsLib
FILE ATTRIBUTES
Directory entries on dosFs volumes contain an attribute byte consisting of bit-flags which
specify various characteristics of the entry. The attributes which are identified are: readonly file, hidden file, system file, volume label, directory, and archive. The VxWorks
symbols for these attribute bit-flags are:
DOS_ATTR_RDONLY
DOS_ATTR_HIDDEN
DOS_ATTR_SYSTEM
DOS_ATTR_VOL_LABEL
DOS_ATTR_DIRECTORY
DOS_ATTR_ARCHIVE
All the flags in the attribute byte, except the directory and volume label flags, may be set
or cleared using the ioctl( ) FIOATTRIBSET function. This function is called after opening
the specific file whose attributes are to be changed. The attribute byte value specified in
the FIOATTRIBSET call is copied directly. To preserve existing flag settings, the current
attributes should first be determined via fstat( ), and the appropriate flag(s) changed
using bitwise AND or OR operations. For example, to make a file read-only, while leaving
other attributes intact:
struct stat fileStat;
fd = open ("file", O_RDONLY, 0);
/* open file
*/
fstat (fd, &fileStat);
/* get file status
*/
ioctl (fd, FIOATTRIBSET, (fileStat.st_attrib | DOS_ATTR_RDONLY));
/* set read-only flag */
close (fd);
/* close file
*/
CONTIGUOUS FILE SUPPORT
The VxWorks dosFs file system provides efficient handling of contiguous files, meaning
files which are made up of a consecutive series of disk sectors. This support includes both
the ability to allocate contiguous space to a file (or directory) and optimized access to such
a file when it is used.
To allocate a contiguous area to a file, the file is first created in the normal fashion, using
open( ) or creat( ). The file descriptor returned during the creation of the file is then used
to make an ioctl( ) call, specifying the FIOCONTIG function. The other parameter to the
FIOCONTIG function is the size of the requested contiguous area in bytes. It is also
possible to request that the largest contiguous free area on the disk be obtained. In this
case, the special value CONTIG_MAX (-1) is used instead of an actual size.
The FAT is searched for a suitable section of the disk, and if found, it is assigned to the
file. (If there is no contiguous area on the volume large enough to satisfy the request, an
S_dosFsLib_NO_CONTIG_SPACE error is returned.) The file may then be closed or used for
further I/O operations. For example, the following will create a file and allocate 0x10000
contiguous bytes:
fd = creat ("file", O_RDWR, 0);
status = ioctl (fd, FIOCONTIG, 0x10000);
if (status != OK)
1 - 80
/* open file
/* get contiguous area
*/
*/