Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
creat(2)		      System Calls Manual		      creat(2)

NAME
       creat - create a	new file or rewrite an existing	one

SYNOPSIS
DESCRIPTION
       The  system  call  creates a new	regular	file or	prepares to rewrite an
       existing	file named by the path name pointed to by path.

       If the file exists, its length is truncated to  0,  and	its  mode  and
       owner  are unchanged.  Otherwise, the file's owner ID is	set to the ef-
       fective user ID of the process.	If the set-group-ID bit	of the	parent
       directory  is  set,  the	 file's	group ID is set	to the group ID	of the
       parent directory.  Otherwise,  the  file's  group  ID  is  set  to  the
       process's  effective  group ID.	The low-order 12 bits of the file mode
       are set to the value of mode modified as	follows:

	      o	 All bits set in the process's file  mode  creation  mask  are
		 cleared (see umask(2)).

	      o	 The  "save  text  image  after	 execution" bit	of the mode is
		 cleared (see chmod(2)).

       If the system call is made in 64	bit mode, the O_LARGEFILE status  flag
       is automatically	set (see fcntl(5) or open(2)).

       Upon  successful	 completion,  the  file	descriptor is returned and the
       file is open for	writing	(only),	even if	the mode does not permit writ-
       ing.   The  file	 offset	is set to the beginning	of the file.  The file
       descriptor is set to remain open	across system  calls  (see  fcntl(2)).
       Each  process has a limit on how	many files it can open simultaneously.
       Refer to	getrlimit(2) for the open files	limit.	This is	also discussed
       in  open(2).   A	new file can be	created	with a mode that forbids writ-
       ing.

   Access Control Lists	- HFS File Systems Only
       On HFS file systems that	support	access control lists, three  base  ACL
       entries	are  created corresponding to the file access permission bits.
       An existing file's access control list is unchanged by (see  setacl(2),
       chmod(2), and acl(5)).

   Access Control Lists	- JFS File Systems Only
       On JFS file systems that	support	access control lists, optional ACL en-
       tries are created corresponding to the parent directory's  default  ACL
       entries.	  An  existing file's access control list is unchanged by (see
       acl(2), chmod(2), and aclv(5)).

RETURN VALUE
       returns the following values:

	      Successful completion.
		     n is the value of the file	descriptor.   It  is  nonnega-
		     tive.
	      Failure.
		     is	set to indicate	the error.

ERRORS
       If fails, is set	to one of the following	values.

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

	      [EACCES]	     The file does not	exist  and  the	 directory  in
			     which  the	 file is to be created does not	permit
			     writing.

	      [EACCES]	     The file exists and write permission is denied.

	      [EAGAIN]	     The file exists, enforcement mode file and	record
			     locking  is  set and there	are outstanding	record
			     locks on the file.

	      [EDQUOT]	     User's disk quota block or	inode limit  has  been
			     reached for this file system.

	      [EFAULT]	     path  points  outside the allocated address space
			     of	the process.  The reliable detection  of  this
			     error is implementation dependent.

	      [EISDIR]	     The named file is an existing directory.

	      [ELOOP]	     Too  many	symbolic  links	 were  encountered  in
			     translating the path name.

	      [EMFILE]	     More than the maximum number of file  descriptors
			     are currently open.

	      [ENAMETOOLONG] The  length  of  the  specified path name exceeds
			     bytes, or the length of a component of  the  path
			     name exceeds bytes	while is in effect.

	      [ENFILE]	     The system	file table is full.

	      [ENOENT]	     The  named	file does not exist (for example, path
			     is	null, or a component of	path does not exist).

	      [ENOSPC]	     Not enough	space on the file system.

	      [ENOTDIR]	     A component of the	path prefix is	not  a	direc-
			     tory.

	      [ENXIO]	     The  named	 file  is a character special or block
			     special file, and the device associated with this
			     special file does not exist.

	      [EOVERFLOW]    The  named	file is	a regular file and the size of
			     the file cannot be	represented  correctly	in  an
			     object of type

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

	      [ETXTBSY]	     The file is a pure	procedure (shared  text)  file
			     that is being executed.

SEE ALSO
       chmod(2),  close(2),  creat64(2), dup(2), fcntl(2), lockf(2), lseek(2),
       open(2),	 open64(2),   read(2),	 setacl(2),   truncate(2),   umask(2),
       write(2), acl(5), aclv(5).

STANDARDS CONFORMANCE
								      creat(2)

NAME | SYNOPSIS | DESCRIPTION | RETURN VALUE | ERRORS | SEE ALSO | STANDARDS CONFORMANCE

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=creat&sektion=2&manpath=HP-UX+11.22>

home | help