Search permission is denied for a directory in a file's path prefix
ENAMETOOLONG
Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in
effect.
ENOENT
A file or directory does not exist.
ENOTDIR
A component of the specified pathname was not a directory when a directory
was expected.
EPERM
Operation is not permitted. Process does not have the appropriate priviledges
or permissions to perform the requested operations.
EROFS
Read-only file system.
DESCRIPTION:
Set the file permission bits, the set user ID bit, and the set group ID bit
for the file named by path to mode. If the effective user ID
does not match the owner of the file and the calling process does not have
the appropriate privileges, chmod() returns -1 and sets errno to
EPERM.