attribute()
PROTOTYPE
#include <posix.h>
int attribute(const char *path, uint32_t mask, uint32_t *attrib);
DESCRIPTION
attribute() reads and optionally modifies the attribute bits of the file specified by path. Paths are absolute if starting with ‘/’, otherwise they are relative to the CWD. mask controls which attribute bits are modified. The file’s current attribute bits are written to *attrib.
In bit positions where mask contains ‘1’, the file’s attribute bits are replaced with bits from *attrib. Where mask contains ‘0’ bits, the corresponding attribute bits are unchanged. When a file is created, its attribute bits are initially set to 0. All links to a file share the same attribute bits.
The caller needs execute access to every directory in the path prefix and write access to the file.
If successful, attribute() returns 0. Otherwise, it sets errno and returns -1.
ERROR CODES
| EACCES | No execute access to a directory in the path prefix or no write access to the specified file. |
| EFAULT | Either path or attrib equals NULL. |
| ENAMETOOLONG | A name in path exceeds the effective maximum file name length. |
| ENOENT | path is the empty string or includes a file that was not found. |
| ENOTDIR | One of the non-leaf path components is not a directory. |
| EROFS | The volume is read-only and mask is not 0. |
EXAMPLE
attrib = AT_REALTIME;
if (attribute(path, AT_REALTIME, &attrib))
return -1;