SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int creat(const char *pathname, mode_t mode);
int creat64(const char *pathname, mode_t mode);
DESCRIPTION
The
creat(pathname, mode);
is equivalent to:
open(pathname, O_WRONLY | O_CREAT | O_TRUNC, mode);
If the file exists, the length is truncated to 0 and the mode and owner are unchanged.
The
If the file does not exist, the file's owner ID is set to the effective
user ID of the process. The group ID of the file is set to the effective group
ID of the process. The access permission bits of the file mode
are set to the value of mode, with all bits set in the
process's file mode creation mask cleared (see
On success, a write-only file
descriptor is returned and the file is open for writing, even if
the mode does not permit writing. The file pointer is set to the
beginning of the file. The file descriptor is set to remain open
across
PARAMETERS
- pathname
-
Points to the path name of the file to create.
- mode
-
Specifies the permission modes associated with the created file.
RETURN VALUES
If successful,
- EACCES
-
Search permission is denied on a component of the pathname prefix. Or the file does not exist and the directory in which the file is to be created does not permit writing. Or the file exists and write permission is denied.
- EAGAIN
-
The file exists and write permission is denied.
- EFAULT
-
pathname points outside the allocated address space of the process.
- EINTR
-
A signal interrupted the call.
- EISDIR
-
The named file is an existing directory.
- EMFILE
-
The process has too many open files.
- ENAMETOOLONG
-
The length of the path name parameter exceeds PATH_MAX or the length of a path name component exceeds NAME_MAX.
- ENFILE
-
The system file table is full.
- ENOENT
-
A component of the pathname prefix does not exist, or pathname is null.
- ENOTDIR
-
A component of the path name prefix is not a directory.
- EROFS
-
The named file resides or would reside on a read-only file system.
CONFORMANCE
POSIX.1 (1996), with exceptions.
MULTITHREAD SAFETY LEVEL
Async-signal-safe.
PORTING ISSUES
Refer to Security and File Management in the Windows Concepts chapter of the PTC MKS Toolkit UNIX to Windows Porting Guide for a detailed discussion of file security and file handling issues.
AVAILABILITY
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
- Miscellaneous:
- lf64, struct stat
PTC MKS Toolkit 10.4 Documentation Build 39.