| CHFLAGS(2) | System Calls Manual | CHFLAGS(2) |
chflags, fchflags,
fchflagsat — 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);
int
fchflagsat(int
fd, const char
*path, u_int flags,
int flag);
The file whose name is given by path or referenced by the descriptor fd has its flags changed to flags.
The
fchflagsat()
is equivalent to
chflag()
except in the case where path specifies a relative
path. In this case the file to be changed is determined relative to the
directory associated with the file descriptor fd
instead of the current working directory. The values for the
flag are constructed by a bitwise-inclusive OR of
flags from the following list, defined in
<fcntl.h>:
AT_SYMLINK_NOFOLLOWAT_SYMLINK_NOFOLLOW_ANYAT_RESOLVE_BENEATHIf
fchflagsat()
is passed the special value AT_FDCWD in the
fd parameter, the current working directory is used.
If also flag is zero, the behavior is identical to a
call to chflags().
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]In addition to the chflags() errors,
fchflagsat() fails if:
EBADF]EINVAL]ELOOP]ENOTDIR]AT_FDCWD nor a
file descriptor associated with a directory.ENOTCAPABLE]chflags(1), fflagstostr(3), lchflags(3), strtofflags(3), launchd(8)
The chflags() and
fchflags functions first appeared in 4.4BSD.
fchflagsat() system call appeared in macOS 27.0.
| June 9, 1993 | macOS 26 |