/*******************************************************************************
*
* stat - get file status information using a pathname (POSIX)
*
* This routine obtains various characteristics of a file (or directory).
* This routine is equivalent to fstat(), except that the of the file
* is specified, rather than an open file descriptor.
*
* The parameter is a pointer to a `stat' structure (defined
* in stat.h). This structure must have already been allocated before
* this routine is called.
*
* NOTE: When used with netDrv devices (FTP or RSH), stat() returns the size
* of the file and always sets the mode to regular; stat() does not distinguish
* between files, directories, links, etc.
*
* Upon return, the fields in the `stat' structure are updated to
* reflect the characteristics of the file.
*
* RETURNS: OK or ERROR.
*
* SEE ALSO:
* fstat(), ls()
*/
STATUS stat
(
char *name, /* name of file to check */
struct stat *pStat /* pointer to stat structure */
);
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: read-only file, hidden file, system file, volume label, directory, and archive. The VxWorks symbols for these attribute bit-flags are:
DOS_ATTR_RDONLY
File is write-protected, can not be modified or deleted.
DOS_ATTR_HIDDEN
this attribute is not used by VxWorks.
DOS_ATTR_SYSTEM
this attribute is not used by VxWorks.
DOS_ATTR_VOL_LABEL
directory entry describes a volume label, this attribute can not be set or used directly, see ioctl( ) command FIOLABELGET and FIOLABELSET below for volume label manipulation.
DOS_ATTR_DIRECTORY
directory entry is a subdirectory, this attribute can not be set directly.
DOS_ATTR_ARCHIVE
this attribute is not used by VxWorks.
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 */
See also the reference manual entry for attrib( ) and xattrib( ) for user-level utility routines which control the attributes of files or file hierarchy.