*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->IRIX man pages -> standard/creat (2)              
Title
Content
Arch
Section
 

Contents


creat(2)							      creat(2)


NAME    [Toc]    [Back]

     creat - create a new file or rewrite an existing one

SYNOPSIS    [Toc]    [Back]

     #include <sys/types.h>
     #include <sys/stat.h>
     #include <fcntl.h>

     int creat(const char *path<b>, mode_t	mode<b>);

DESCRIPTION    [Toc]    [Back]

     creat creates a new ordinary file or prepares to rewrite an existing file
     named by the path name pointed to by path.

     If	the file exists, the length is truncated to 0 and the mode and owner
     are unchanged.

     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 or	to the group ID	of the directory in which the
     file is being created.  This is determined	as follows:

	  If the underlying filesystem was mounted with	the BSD	file creation
	  semantics flag [see fstab(4)]	or the S_ISGID bit is set [see
	  chmod(2)] on the parent directory, then the group ID of the new file
	  is set to the	group ID of the	parent directory, otherwise it is set
	  to the effective group ID of the calling process.

     The mode bits of the file are based on the	value of mode, modified	as
     follows:

	  If the group ID of the new file does not match the effective group
	  ID or	one of the supplementary group IDs, the	S_ISGID	bit is
	  cleared.

	  All bits set in the process file mode	creation mask are cleared [see
	  umask(2)].

	  The ``save text image	after execution	bit'' of the mode is cleared
	  [see chmod(2)	for the	values of mode]

	  Upon successful completion, 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 exec system calls [see
	  fcntl(2)].  A	new file may be	created	with a mode that forbids
	  writing.

     The call creat(path<b>, mode<b>)	is equivalent to:






									Page 1






creat(2)							      creat(2)



	 open(path<b>, O_WRONLY | O_CREAT | O_TRUNC, mode<b>)

     creat fails if one	or more	of the following are true:

     EACCES Search permission is denied	on a component of the path prefix.

     EACCES The	file does not exist and	write permission on the	directory in
	    which the file is to be created is denied.

     EACCES The	file exists and	write permission is denied.

     EAGAIN The	file exists, mandatory file/record locking is set, and there
	    are	outstanding record locks on the	file [see chmod(2)].

     EFAULT path points	outside	the allocated address space of the process.

     EFBIG  The	file does not exist and	the file size limit of the process is
	    set	to 0 [see getrlimit(2)].

     EISDIR The	named file is an existing directory.

     EINTR  A signal was caught	during the creat system	call.

     ELOOP  Too	many symbolic links were encountered in	translating path.

     EMFILE The	process	has too	many open files	[see getrlimit(2)].

     ENAMETOOLONG
	    The	length of the path argument exceeds {PATH_MAX},	or the length
	    of a path component	exceeds	{NAME_MAX} while _POSIX_NO_TRUNC is in
	    effect.

     ENOTDIRA component	of the path prefix is not a directory.

     ENOENT A component	of the path prefix does	not exist.

     ENOENT The	path name is null.

     EROFS  The	named file resides or would reside on a	read-only file system.

     ENFILE The	system file table is full.

     ENOSPC The	file system is out of inodes.

     ETIMEDOUT
	    The	object of the write is located on a remote system which	is not
	    available [see intro(2)].

SEE ALSO    [Toc]    [Back]

      
      
     chmod(2), close(2), dup(2), fcntl(2), getrlimit(2), lseek(2), open(2),
     read(2), umask(2),	write(2), stat(5)




									Page 2






creat(2)							      creat(2)


DIAGNOSTICS    [Toc]    [Back]

     Upon successful completion	a non-negative integer,	namely the lowest
     numbered unused file descriptor, is returned.  Otherwise, a value of -1
     is	returned, no files are created or modified, and	errno is set to
     indicate the error.


									PPPPaaaaggggeeee 3333
[ Back ]
 Similar pages
Name OS Title
link Tru64 Create a hard link to an existing file on the local file system
cvs-makerepos Linux script to create non-existing configured CVS repositories
gss_duplicate_name HP-UX allow an application to create an exact duplicate of the existing internal name
cs_oid_set_isect Tru64 create an new object identifier (OID) set that is an intersection oftwo existing sets.
zeero Tru64 Zero out disks prior to rewrite.
pxfcreat IRIX Creates a new file or rewrites an existing file
dup2 OpenBSD duplicate an existing file descriptor
tunefs FreeBSD tune up an existing file system
dup2 NetBSD duplicate an existing file descriptor
dup FreeBSD duplicate an existing file descriptor
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service