CHFLAGS(2) | System Calls Manual | CHFLAGS(2) |
chflags
, fchflags
— set file flags
#include
<sys/stat.h>
#include <unistd.h>
int
chflags
(const
char *path, u_int
flags);
int
fchflags
(int
fd, u_int
flags);
The file whose name is given by path or referenced by the descriptor fd has its flags changed to flags.
The flags specified are formed by or'ing the following values
The “UF_IMMUTABLE”, “UF_APPEND”, “UF_OPAQUE”, and “UF_HIDDEN” flags may be set or unset by either the owner of a file or the super-user.
The “SF_ARCHIVED”, “SF_IMMUTABLE” and “SF_APPEND” flags may only be set or unset by the super-user.
The “SF_DATALESS” and
“UF_COMPRESSED” flags are internal flags and may not be set or
unset from user space. Attempting to modify them using
chflags
()
will result in undefined behaviour.
Upon successful completion, a value of 0 is returned. Otherwise, -1 is returned and the global variable errno is set to indicate the error.
chflags
() will fail if:
ENOTDIR
]ENAMETOOLONG
]{NAME_MAX}
characters, or an entire path name exceeded
{PATH_MAX}
characters.ENOENT
]EACCES
]ELOOP
]EPERM
]EROFS
]EFAULT
]EIO
]ENOTSUP
]fchflags
() will fail if:
EBADF
]EINVAL
]EPERM
]EROFS
]EIO
]ENOTSUP
]chflags(1), fflagstostr(3), lchflags(3), strtofflags(3), launchd(8)
The chflags
() and
fchflags
functions first appeared in 4.4BSD.
June 9, 1993 | macOS 14.6 |