Open System Services System Calls Reference Manual (G06.25+, H06.03+)
System Functions (a - d) creat(2)
NAME
creat - Creates a regular file in the OSS environment or rewrites an existing file
LIBRARY
G-series native Guardian processes: system library
G-series native OSS processes: system library
H-series native Guardian processes: implicit libraries
H-series OSS processes: implicit libraries
SYNOPSIS
#include <sys/types.h> /* optional except for POSIX.1 */
#include <sys/stat.h> /* optional except for POSIX.1 */
#include <fcntl.h>
int creat(
const char *path,
mode_t mode);
PARAMETERS
path Points to the pathname of the file to be created or opened for writing.
The files /lost+found, /dev, /dev/tty, and /dev/null cannot be specified for this
parameter. Attempts to create these files cause the function call to fail with
errno set to [EINVAL].
If the path parameter refers to a symbolic link, the creat() function opens the file
pointed to by the symbolic link.
mode Specifies the read, write, and execute permissions of the file and the file type
flags for the file.
This parameter is required if the file does not exist. If the file already exists, this
parameter must be specified and must have a valid value but has no effect.
The permission bits are set according to the value of this parameter modified by
the process’s file creation mask (see the umask(2) reference page). The value of
this parameter is constructed by logically ORing flags that are defined in the
sys/stat.h header file.
The file type flags are described in DESCRIPTION.
DESCRIPTION
The creat() function establishes a connection between the file indicated by the path parameter
and the returned file descriptor. The opened file descriptor is used by subsequent I/O function
calls, such as read() and write(), to access that file.
The returned file descriptor is the lowest-numbered file descriptor not previously open for that
process. A corresponding Guardian environment file number is also assigned.
The file offset, marking the current position within the file, is set to the beginning of the file. The
new file descriptor is set to remain open across the processing of any of the exec or tdm_exec set
of functions. (See the fcntl(2) reference page.)
A call to the creat() function is equivalent to this call:
open( path, O_WRONLY |O_CREAT | O_TRUNC,mode );
The creat() function cannot be used to create a FIFO special file. Use the mkfifo() function
instead.
If the file does not exist, a regular file is created with these characteristics:
527186-003 Hewlett-Packard Company 1−31