Top Description Fields Constructors Methods
org.lwjgl.system.linux

public Class FCNTL

extends Object
Class Inheritance
Imports
java.nio.*, org.lwjgl.system.*

Native bindings to <fcntl.h>.

Field Summary

Modifier and TypeField and Description
public static final int
DN_ACCESS

Enum values:

  • DN_ACCESS - A file was accessed (read(2), pread(2), readv(2), and similar).
  • DN_MODIFY - A file was modified (write(2), pwrite(2), writev(2), truncate(2), ftruncate(2), and similar).
  • DN_CREATE - A file was created (open(2), creat(2), mknod(2), mkdir(2), link(2), symlink(2), rename(2) into this directory).
  • DN_DELETE - A file was unlinked (unlink(2), rename(2) to another directory, rmdir(2)).
  • DN_RENAME - A file was renamed within this directory (rename(2)).
  • DN_ATTRIB - The attributes of a file were changed (chown(2), chmod(2), utime(2), utimensat(2), and similar).
  • DN_MULTISHOT - Don't remove notifier
public static final int
DN_ATTRIB

Enum values:

  • DN_ACCESS - A file was accessed (read(2), pread(2), readv(2), and similar).
  • DN_MODIFY - A file was modified (write(2), pwrite(2), writev(2), truncate(2), ftruncate(2), and similar).
  • DN_CREATE - A file was created (open(2), creat(2), mknod(2), mkdir(2), link(2), symlink(2), rename(2) into this directory).
  • DN_DELETE - A file was unlinked (unlink(2), rename(2) to another directory, rmdir(2)).
  • DN_RENAME - A file was renamed within this directory (rename(2)).
  • DN_ATTRIB - The attributes of a file were changed (chown(2), chmod(2), utime(2), utimensat(2), and similar).
  • DN_MULTISHOT - Don't remove notifier
public static final int
DN_CREATE

Enum values:

  • DN_ACCESS - A file was accessed (read(2), pread(2), readv(2), and similar).
  • DN_MODIFY - A file was modified (write(2), pwrite(2), writev(2), truncate(2), ftruncate(2), and similar).
  • DN_CREATE - A file was created (open(2), creat(2), mknod(2), mkdir(2), link(2), symlink(2), rename(2) into this directory).
  • DN_DELETE - A file was unlinked (unlink(2), rename(2) to another directory, rmdir(2)).
  • DN_RENAME - A file was renamed within this directory (rename(2)).
  • DN_ATTRIB - The attributes of a file were changed (chown(2), chmod(2), utime(2), utimensat(2), and similar).
  • DN_MULTISHOT - Don't remove notifier
public static final int
DN_DELETE

Enum values:

  • DN_ACCESS - A file was accessed (read(2), pread(2), readv(2), and similar).
  • DN_MODIFY - A file was modified (write(2), pwrite(2), writev(2), truncate(2), ftruncate(2), and similar).
  • DN_CREATE - A file was created (open(2), creat(2), mknod(2), mkdir(2), link(2), symlink(2), rename(2) into this directory).
  • DN_DELETE - A file was unlinked (unlink(2), rename(2) to another directory, rmdir(2)).
  • DN_RENAME - A file was renamed within this directory (rename(2)).
  • DN_ATTRIB - The attributes of a file were changed (chown(2), chmod(2), utime(2), utimensat(2), and similar).
  • DN_MULTISHOT - Don't remove notifier
public static final int
DN_MODIFY

Enum values:

  • DN_ACCESS - A file was accessed (read(2), pread(2), readv(2), and similar).
  • DN_MODIFY - A file was modified (write(2), pwrite(2), writev(2), truncate(2), ftruncate(2), and similar).
  • DN_CREATE - A file was created (open(2), creat(2), mknod(2), mkdir(2), link(2), symlink(2), rename(2) into this directory).
  • DN_DELETE - A file was unlinked (unlink(2), rename(2) to another directory, rmdir(2)).
  • DN_RENAME - A file was renamed within this directory (rename(2)).
  • DN_ATTRIB - The attributes of a file were changed (chown(2), chmod(2), utime(2), utimensat(2), and similar).
  • DN_MULTISHOT - Don't remove notifier
public static final int
DN_MULTISHOT

Enum values:

  • DN_ACCESS - A file was accessed (read(2), pread(2), readv(2), and similar).
  • DN_MODIFY - A file was modified (write(2), pwrite(2), writev(2), truncate(2), ftruncate(2), and similar).
  • DN_CREATE - A file was created (open(2), creat(2), mknod(2), mkdir(2), link(2), symlink(2), rename(2) into this directory).
  • DN_DELETE - A file was unlinked (unlink(2), rename(2) to another directory, rmdir(2)).
  • DN_RENAME - A file was renamed within this directory (rename(2)).
  • DN_ATTRIB - The attributes of a file were changed (chown(2), chmod(2), utime(2), utimensat(2), and similar).
  • DN_MULTISHOT - Don't remove notifier
public static final int
DN_RENAME

Enum values:

  • DN_ACCESS - A file was accessed (read(2), pread(2), readv(2), and similar).
  • DN_MODIFY - A file was modified (write(2), pwrite(2), writev(2), truncate(2), ftruncate(2), and similar).
  • DN_CREATE - A file was created (open(2), creat(2), mknod(2), mkdir(2), link(2), symlink(2), rename(2) into this directory).
  • DN_DELETE - A file was unlinked (unlink(2), rename(2) to another directory, rmdir(2)).
  • DN_RENAME - A file was renamed within this directory (rename(2)).
  • DN_ATTRIB - The attributes of a file were changed (chown(2), chmod(2), utime(2), utimensat(2), and similar).
  • DN_MULTISHOT - Don't remove notifier
public static final int
F_ADD_SEALS

fcntl commands.

public static final int
F_DUPFD

fcntl commands.

public static final int
public static final int
F_EXLCK

For posix fcntl and l_type field of an Flock for lockf().

public static final int
public static final int
public static final int
F_GET_SEALS

fcntl commands.

public static final int
F_GETFD

fcntl commands.

public static final int
F_GETFL

fcntl commands.

public static final int
F_GETLEASE

fcntl commands.

public static final int
F_GETLK

fcntl commands.

public static final int
F_GETOWN

fcntl commands.

public static final int
F_GETOWN_EX

fcntl commands.

public static final int
public static final int
F_GETSIG

fcntl commands.

public static final int
F_NOTIFY

fcntl commands.

public static final int
F_OFD_GETLK

fcntl commands.

public static final int
F_OFD_SETLK

fcntl commands.

public static final int
public static final int
F_OWNER_PGRP

FOwnerEx::type values.

public static final int
F_OWNER_PID

FOwnerEx::type values.

public static final int
F_OWNER_TID

FOwnerEx::type values.

public static final int
F_RDLCK

For posix fcntl and l_type field of an Flock for lockf().

public static final int
F_SEAL_FUTURE_WRITE

Enum values:

  • F_SEAL_SEAL - If this seal is set, any further call to fcntl() with F_ADD_SEALS fails with the error EPERM.

    Therefore, this seal prevents any modifications to the set of seals itself. If the initial set of seals of a file includes F_SEAL_SEAL, then this effectively causes the set of seals to be constant and locked.

  • F_SEAL_SHRINK - If this seal is set, the file in question cannot be reduced in size.

    This affects open(2) with the O_TRUNC flag as well as truncate(2) and ftruncate(2). Those calls fail with EPERM if you try to shrink the file in question. Increasing the file size is still possible.

  • F_SEAL_GROW - If this seal is set, the size of the file in question cannot be increased.

    This affects write(2) beyond the end of the file, truncate(2), ftruncate(2), and fallocate(2). These calls fail with EPERM if you use them to increase the file size. If you keep the size or shrink it, those calls still work as expected.

  • F_SEAL_WRITE - If this seal is set, you cannot modify the contents of the file.

    Note that shrinking or growing the size of the file is still possible and allowed. Thus, this seal is normally used in combination with one of the other seals. This seal affects write(2) and fallocate(2) (only in combination with the FALLOC_FL_PUNCH_HOLE flag). Those calls fail with EPERM if this seal is set. Furthermore, trying to create new shared, writable memory-mappings via mmap(2) will also fail with EPERM.

    Using the F_ADD_SEALS operation to set the F_SEAL_WRITE seal fails with EBUSY if any writable, shared mapping exists. Such mappings must be unmapped before you can add this seal. Furthermore, if there are any asynchronous I/O operations (io_submit(2)) pending on the file, all outstanding writes will be discarded.

  • F_SEAL_FUTURE_WRITE - The effect of this seal is similar to F_SEAL_WRITE, but the contents of the file can still be modified via shared writable mappings that were created prior to the seal being set.

    Any attempt to create a new writable mapping on the file via mmap(2) will fail with EPERM. Likewise, an attempt to write to the file via write(2) will fail with EPERM.

    Using this seal, one process can create a memory buffer that it can continue to modify while sharing that buffer on a "read-only" basis with other processes.

    (since Linux 5.1)

public static final int
F_SEAL_GROW

Enum values:

  • F_SEAL_SEAL - If this seal is set, any further call to fcntl() with F_ADD_SEALS fails with the error EPERM.

    Therefore, this seal prevents any modifications to the set of seals itself. If the initial set of seals of a file includes F_SEAL_SEAL, then this effectively causes the set of seals to be constant and locked.

  • F_SEAL_SHRINK - If this seal is set, the file in question cannot be reduced in size.

    This affects open(2) with the O_TRUNC flag as well as truncate(2) and ftruncate(2). Those calls fail with EPERM if you try to shrink the file in question. Increasing the file size is still possible.

  • F_SEAL_GROW - If this seal is set, the size of the file in question cannot be increased.

    This affects write(2) beyond the end of the file, truncate(2), ftruncate(2), and fallocate(2). These calls fail with EPERM if you use them to increase the file size. If you keep the size or shrink it, those calls still work as expected.

  • F_SEAL_WRITE - If this seal is set, you cannot modify the contents of the file.

    Note that shrinking or growing the size of the file is still possible and allowed. Thus, this seal is normally used in combination with one of the other seals. This seal affects write(2) and fallocate(2) (only in combination with the FALLOC_FL_PUNCH_HOLE flag). Those calls fail with EPERM if this seal is set. Furthermore, trying to create new shared, writable memory-mappings via mmap(2) will also fail with EPERM.

    Using the F_ADD_SEALS operation to set the F_SEAL_WRITE seal fails with EBUSY if any writable, shared mapping exists. Such mappings must be unmapped before you can add this seal. Furthermore, if there are any asynchronous I/O operations (io_submit(2)) pending on the file, all outstanding writes will be discarded.

  • F_SEAL_FUTURE_WRITE - The effect of this seal is similar to F_SEAL_WRITE, but the contents of the file can still be modified via shared writable mappings that were created prior to the seal being set.

    Any attempt to create a new writable mapping on the file via mmap(2) will fail with EPERM. Likewise, an attempt to write to the file via write(2) will fail with EPERM.

    Using this seal, one process can create a memory buffer that it can continue to modify while sharing that buffer on a "read-only" basis with other processes.

    (since Linux 5.1)

public static final int
F_SEAL_SEAL

Enum values:

  • F_SEAL_SEAL - If this seal is set, any further call to fcntl() with F_ADD_SEALS fails with the error EPERM.

    Therefore, this seal prevents any modifications to the set of seals itself. If the initial set of seals of a file includes F_SEAL_SEAL, then this effectively causes the set of seals to be constant and locked.

  • F_SEAL_SHRINK - If this seal is set, the file in question cannot be reduced in size.

    This affects open(2) with the O_TRUNC flag as well as truncate(2) and ftruncate(2). Those calls fail with EPERM if you try to shrink the file in question. Increasing the file size is still possible.

  • F_SEAL_GROW - If this seal is set, the size of the file in question cannot be increased.

    This affects write(2) beyond the end of the file, truncate(2), ftruncate(2), and fallocate(2). These calls fail with EPERM if you use them to increase the file size. If you keep the size or shrink it, those calls still work as expected.

  • F_SEAL_WRITE - If this seal is set, you cannot modify the contents of the file.

    Note that shrinking or growing the size of the file is still possible and allowed. Thus, this seal is normally used in combination with one of the other seals. This seal affects write(2) and fallocate(2) (only in combination with the FALLOC_FL_PUNCH_HOLE flag). Those calls fail with EPERM if this seal is set. Furthermore, trying to create new shared, writable memory-mappings via mmap(2) will also fail with EPERM.

    Using the F_ADD_SEALS operation to set the F_SEAL_WRITE seal fails with EBUSY if any writable, shared mapping exists. Such mappings must be unmapped before you can add this seal. Furthermore, if there are any asynchronous I/O operations (io_submit(2)) pending on the file, all outstanding writes will be discarded.

  • F_SEAL_FUTURE_WRITE - The effect of this seal is similar to F_SEAL_WRITE, but the contents of the file can still be modified via shared writable mappings that were created prior to the seal being set.

    Any attempt to create a new writable mapping on the file via mmap(2) will fail with EPERM. Likewise, an attempt to write to the file via write(2) will fail with EPERM.

    Using this seal, one process can create a memory buffer that it can continue to modify while sharing that buffer on a "read-only" basis with other processes.

    (since Linux 5.1)

public static final int
F_SEAL_SHRINK

Enum values:

  • F_SEAL_SEAL - If this seal is set, any further call to fcntl() with F_ADD_SEALS fails with the error EPERM.

    Therefore, this seal prevents any modifications to the set of seals itself. If the initial set of seals of a file includes F_SEAL_SEAL, then this effectively causes the set of seals to be constant and locked.

  • F_SEAL_SHRINK - If this seal is set, the file in question cannot be reduced in size.

    This affects open(2) with the O_TRUNC flag as well as truncate(2) and ftruncate(2). Those calls fail with EPERM if you try to shrink the file in question. Increasing the file size is still possible.

  • F_SEAL_GROW - If this seal is set, the size of the file in question cannot be increased.

    This affects write(2) beyond the end of the file, truncate(2), ftruncate(2), and fallocate(2). These calls fail with EPERM if you use them to increase the file size. If you keep the size or shrink it, those calls still work as expected.

  • F_SEAL_WRITE - If this seal is set, you cannot modify the contents of the file.

    Note that shrinking or growing the size of the file is still possible and allowed. Thus, this seal is normally used in combination with one of the other seals. This seal affects write(2) and fallocate(2) (only in combination with the FALLOC_FL_PUNCH_HOLE flag). Those calls fail with EPERM if this seal is set. Furthermore, trying to create new shared, writable memory-mappings via mmap(2) will also fail with EPERM.

    Using the F_ADD_SEALS operation to set the F_SEAL_WRITE seal fails with EBUSY if any writable, shared mapping exists. Such mappings must be unmapped before you can add this seal. Furthermore, if there are any asynchronous I/O operations (io_submit(2)) pending on the file, all outstanding writes will be discarded.

  • F_SEAL_FUTURE_WRITE - The effect of this seal is similar to F_SEAL_WRITE, but the contents of the file can still be modified via shared writable mappings that were created prior to the seal being set.

    Any attempt to create a new writable mapping on the file via mmap(2) will fail with EPERM. Likewise, an attempt to write to the file via write(2) will fail with EPERM.

    Using this seal, one process can create a memory buffer that it can continue to modify while sharing that buffer on a "read-only" basis with other processes.

    (since Linux 5.1)

public static final int
F_SEAL_WRITE

Enum values:

  • F_SEAL_SEAL - If this seal is set, any further call to fcntl() with F_ADD_SEALS fails with the error EPERM.

    Therefore, this seal prevents any modifications to the set of seals itself. If the initial set of seals of a file includes F_SEAL_SEAL, then this effectively causes the set of seals to be constant and locked.

  • F_SEAL_SHRINK - If this seal is set, the file in question cannot be reduced in size.

    This affects open(2) with the O_TRUNC flag as well as truncate(2) and ftruncate(2). Those calls fail with EPERM if you try to shrink the file in question. Increasing the file size is still possible.

  • F_SEAL_GROW - If this seal is set, the size of the file in question cannot be increased.

    This affects write(2) beyond the end of the file, truncate(2), ftruncate(2), and fallocate(2). These calls fail with EPERM if you use them to increase the file size. If you keep the size or shrink it, those calls still work as expected.

  • F_SEAL_WRITE - If this seal is set, you cannot modify the contents of the file.

    Note that shrinking or growing the size of the file is still possible and allowed. Thus, this seal is normally used in combination with one of the other seals. This seal affects write(2) and fallocate(2) (only in combination with the FALLOC_FL_PUNCH_HOLE flag). Those calls fail with EPERM if this seal is set. Furthermore, trying to create new shared, writable memory-mappings via mmap(2) will also fail with EPERM.

    Using the F_ADD_SEALS operation to set the F_SEAL_WRITE seal fails with EBUSY if any writable, shared mapping exists. Such mappings must be unmapped before you can add this seal. Furthermore, if there are any asynchronous I/O operations (io_submit(2)) pending on the file, all outstanding writes will be discarded.

  • F_SEAL_FUTURE_WRITE - The effect of this seal is similar to F_SEAL_WRITE, but the contents of the file can still be modified via shared writable mappings that were created prior to the seal being set.

    Any attempt to create a new writable mapping on the file via mmap(2) will fail with EPERM. Likewise, an attempt to write to the file via write(2) will fail with EPERM.

    Using this seal, one process can create a memory buffer that it can continue to modify while sharing that buffer on a "read-only" basis with other processes.

    (since Linux 5.1)

public static final int
public static final int
public static final int
F_SETFD

fcntl commands.

public static final int
F_SETFL

fcntl commands.

public static final int
F_SETLEASE

fcntl commands.

public static final int
F_SETLK

fcntl commands.

public static final int
F_SETLKW

fcntl commands.

public static final int
F_SETOWN

fcntl commands.

public static final int
F_SETOWN_EX

fcntl commands.

public static final int
public static final int
F_SETSIG

fcntl commands.

public static final int
F_SHLCK

For posix fcntl and l_type field of an Flock for lockf().

public static final int
F_UNLCK

For posix fcntl and l_type field of an Flock for lockf().

public static final int
F_WRLCK

For posix fcntl and l_type field of an Flock for lockf().

public static final int
public static final int
LOCK_EX

Enum values:

  • LOCK_SH - shared lock
  • LOCK_EX - exclusive lock
  • LOCK_NB - or'd with one of the above to prevent blocking
  • LOCK_UN - remove lock
  • LOCK_MAND - This is a mandatory flock...
  • LOCK_READ - which allows concurrent read operations
  • LOCK_WRITE - which allows concurrent write operations
  • LOCK_RW - which allows concurrent read & writes ops
public static final int
LOCK_MAND

Enum values:

  • LOCK_SH - shared lock
  • LOCK_EX - exclusive lock
  • LOCK_NB - or'd with one of the above to prevent blocking
  • LOCK_UN - remove lock
  • LOCK_MAND - This is a mandatory flock...
  • LOCK_READ - which allows concurrent read operations
  • LOCK_WRITE - which allows concurrent write operations
  • LOCK_RW - which allows concurrent read & writes ops
public static final int
LOCK_NB

Enum values:

  • LOCK_SH - shared lock
  • LOCK_EX - exclusive lock
  • LOCK_NB - or'd with one of the above to prevent blocking
  • LOCK_UN - remove lock
  • LOCK_MAND - This is a mandatory flock...
  • LOCK_READ - which allows concurrent read operations
  • LOCK_WRITE - which allows concurrent write operations
  • LOCK_RW - which allows concurrent read & writes ops
public static final int
LOCK_READ

Enum values:

  • LOCK_SH - shared lock
  • LOCK_EX - exclusive lock
  • LOCK_NB - or'd with one of the above to prevent blocking
  • LOCK_UN - remove lock
  • LOCK_MAND - This is a mandatory flock...
  • LOCK_READ - which allows concurrent read operations
  • LOCK_WRITE - which allows concurrent write operations
  • LOCK_RW - which allows concurrent read & writes ops
public static final int
LOCK_RW

Enum values:

  • LOCK_SH - shared lock
  • LOCK_EX - exclusive lock
  • LOCK_NB - or'd with one of the above to prevent blocking
  • LOCK_UN - remove lock
  • LOCK_MAND - This is a mandatory flock...
  • LOCK_READ - which allows concurrent read operations
  • LOCK_WRITE - which allows concurrent write operations
  • LOCK_RW - which allows concurrent read & writes ops
public static final int
LOCK_SH

Enum values:

  • LOCK_SH - shared lock
  • LOCK_EX - exclusive lock
  • LOCK_NB - or'd with one of the above to prevent blocking
  • LOCK_UN - remove lock
  • LOCK_MAND - This is a mandatory flock...
  • LOCK_READ - which allows concurrent read operations
  • LOCK_WRITE - which allows concurrent write operations
  • LOCK_RW - which allows concurrent read & writes ops
public static final int
LOCK_UN

Enum values:

  • LOCK_SH - shared lock
  • LOCK_EX - exclusive lock
  • LOCK_NB - or'd with one of the above to prevent blocking
  • LOCK_UN - remove lock
  • LOCK_MAND - This is a mandatory flock...
  • LOCK_READ - which allows concurrent read operations
  • LOCK_WRITE - which allows concurrent write operations
  • LOCK_RW - which allows concurrent read & writes ops
public static final int
LOCK_WRITE

Enum values:

  • LOCK_SH - shared lock
  • LOCK_EX - exclusive lock
  • LOCK_NB - or'd with one of the above to prevent blocking
  • LOCK_UN - remove lock
  • LOCK_MAND - This is a mandatory flock...
  • LOCK_READ - which allows concurrent read operations
  • LOCK_WRITE - which allows concurrent write operations
  • LOCK_RW - which allows concurrent read & writes ops
public static final int
O_ACCMODE

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_APPEND

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_ASYNC

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_CLOEXEC

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_CREAT

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_DIRECT

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_DIRECTORY

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_DSYNC

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_EXCL

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_LARGEFILE

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_NDELAY

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_NOATIME

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_NOCTTY

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_NOFOLLOW

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_NONBLOCK

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_PATH

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_RDONLY

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_RDWR

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_SYNC

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_TMPFILE

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_TRUNC

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
O_WRONLY

Enum values:

  • O_ACCMODE
  • O_RDONLY
  • O_WRONLY
  • O_RDWR
  • O_APPEND - The file is opened in append mode.

    Before each write(2), the file offset is positioned at the end of the file, as if with lseek(2). O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

  • O_ASYNC - Enable signal-driven I/O: generate a signal (SIGIO by default, but this can be changed via fcntl(2)) when input or output becomes possible on this file descriptor.

    This feature is only available for terminals, pseudoterminals, sockets, and (since Linux 2.6) pipes and FIFOs. See fcntl(2) for further details.

  • O_CLOEXEC - Enable the close-on-exec flag for the new file descriptor.

    Specifying this flag permits a program to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC flag. Additionally, use of this flag is essential in some multithreaded programs since using a separate fcntl(2) F_SETFD operation to set the FD_CLOEXEC flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same time as another thread does a fork(2) plus execve(2).

  • O_CREAT - If the file does not exist it will be created.

    The owner (user ID) of the file is set to the effective user ID of the process. The group ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory (depending on file system type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

  • O_DIRECT - Try to minimize cache effects of the I/O to and from this file.

    In general this will degrade performance, but it is useful in special situations, such as when applications do their own caching. File I/O is done directly to/from user-space buffers. The O_DIRECT flag on its own makes an effort to transfer data synchronously, but does not give the guarantees of the O_SYNC flag that data and necessary metadata are transferred. To guarantee synchronous I/O, O_SYNC must be used in addition to O_DIRECT.

    A semantically similar (but deprecated) interface for block devices is described in raw(8).

  • O_DIRECTORY - If pathname is not a directory, cause the open to fail.

    This flag is Linux-specific, and was added in kernel version 2.1.126, to avoid denial-of-service problems if opendir(3) is called on a FIFO or tape device, but should not be used outside of the implementation of opendir(3).

  • O_DSYNC
  • O_EXCL - Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.

    When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.

    In general, the behavior of O_EXCL is undefined if it is used without O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be used without O_CREAT if pathname refers to a block device. If the block device is in use by the system (e.g., mounted), open() fails with the error EBUSY.

    On NFS, O_EXCL is only supported when using NFSv3 or later on kernel 2.6 or later. In NFS environments where O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race condition. Portable programs that want to perform atomic file locking using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hostname and PID), and use link(2) to make a link to the lockfile. If link(2) returns 0, the lock is successful. Otherwise, use stat(2) on the unique file to check if its link count has increased to 2, in which case the lock is also successful.

  • O_LARGEFILE - (LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened.

    The _LARGEFILE64_SOURCE macro must be defined (before including any header files) in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather than using O_LARGEFILE) is the preferred method of accessing large files on 32-bit systems (see feature_test_macros(7)).

  • O_NOATIME - Do not update the file last access time (st_atime in the inode) when the file is read(2).

    This flag is intended for use by indexing or backup programs, where its use can significantly reduce the amount of disk activity. This flag may not be effective on all file systems. One example is NFS, where the server maintains the access time.

  • O_NOCTTY - If pathname refers to a terminal device --see tty(4)-- it will not become the process's controlling terminal even if the process does not have one.
  • O_NOFOLLOW - If pathname is a symbolic link, then the open fails.

    This is a FreeBSD extension, which was added to Linux in version 2.1.126. Symbolic links in earlier components of the pathname will still be followed.

  • O_NONBLOCK - When possible, the file is opened in nonblocking mode.

    Neither the open() nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(7). For a discussion of the effect of O_NONBLOCK in conjunction with mandatory file locks and with file leases, see fcntl(2).

  • O_NDELAY
  • O_PATH
  • O_SYNC - The file is opened for synchronous I/O.

    Any write(2)s on the resulting file descriptor will block the calling process until the data has been physically written to the underlying hardware.

  • O_TMPFILE
  • O_TRUNC - If the file already exists and is a regular file and the open mode allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to length 0.

    If the file is a FIFO or terminal device file, the O_TRUNC flag is ignored. Otherwise the effect of O_TRUNC is unspecified.

public static final int
RWH_WRITE_LIFE_EXTREME

Enum values:

public static final int
RWH_WRITE_LIFE_LONG

Enum values:

public static final int
RWH_WRITE_LIFE_MEDIUM

Enum values:

public static final int
RWH_WRITE_LIFE_NONE

Enum values:

public static final int
RWH_WRITE_LIFE_NOT_SET

Enum values:

public static final int
RWH_WRITE_LIFE_SHORT

Enum values:

public static final int
S_IFBLK

File types encoded in type mode_t.

public static final int
S_IFCHR

File types encoded in type mode_t.

public static final int
S_IFDIR

File types encoded in type mode_t.

public static final int
S_IFIFO

File types encoded in type mode_t.

public static final int
S_IFLNK

File types encoded in type mode_t.

public static final int
S_IFMT

File types encoded in type mode_t.

public static final int
S_IFREG

File types encoded in type mode_t.

public static final int
S_IFSOCK

File types encoded in type mode_t.

public static final int
S_IRGRP

File mode bits encoded in type mode_t.

public static final int
S_IROTH

File mode bits encoded in type mode_t.

public static final int
S_IRUSR

File mode bits encoded in type mode_t.

public static final int
S_IRWXG

File mode bits encoded in type mode_t.

public static final int
S_IRWXO

File mode bits encoded in type mode_t.

public static final int
S_IRWXU

File mode bits encoded in type mode_t.

public static final int
S_ISGID

File mode bits encoded in type mode_t.

public static final int
S_ISUID

File mode bits encoded in type mode_t.

public static final int
S_ISVTX

File mode bits encoded in type mode_t.

public static final int
S_IWGRP

File mode bits encoded in type mode_t.

public static final int
S_IWOTH

File mode bits encoded in type mode_t.

public static final int
S_IWUSR

File mode bits encoded in type mode_t.

public static final int
S_IXGRP

File mode bits encoded in type mode_t.

public static final int
S_IXOTH

File mode bits encoded in type mode_t.

public static final int
S_IXUSR

File mode bits encoded in type mode_t.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static int
creat(ByteBuffer pathname, int mode)

Equivalent to open() with flags equal to O_CREAT|O_WRONLY|O_TRUNC.

public static int
creat(CharSequence pathname, int mode)

Equivalent to open() with flags equal to O_CREAT|O_WRONLY|O_TRUNC.

public static native int
public static int
public static int
public static native int
ncreat(long pathname, int mode)

Unsafe version of: creat

public static native int
nfcntli(int fd, int cmd, int arg)

Unsafe version of: fcntli

public static native int
nfcntlp(int fd, int cmd, long arg)

Unsafe version of: fcntlp

public static native int
nopen(long pathname, int flags, int mode)

Unsafe version of: open

public static native int
nopenat(int dirfd, long pathname, int flags, int mode)

Unsafe version of: openat

public static int

Returns:

the new file descriptor, or -1 if an error occurred (in which case, errno is set appropriately).
open
(ByteBuffer pathname, int flags, int mode)

Given a pathname for a file, open() returns a file descriptor, a small, nonnegative integer for use in subsequent system calls (read(2), write(2), lseek(2), fcntl(2), etc.).

public static int

Returns:

the new file descriptor, or -1 if an error occurred (in which case, errno is set appropriately).
open
(CharSequence pathname, int flags, int mode)

Given a pathname for a file, open() returns a file descriptor, a small, nonnegative integer for use in subsequent system calls (read(2), write(2), lseek(2), fcntl(2), etc.).

public static int

Returns:

a new file descriptor on success. On error, -1 is returned and errno is set to indicate the error.
openat
(int dirfd, ByteBuffer pathname, int flags, int mode)

The openat() system call operates in exactly the same way as open(2), except for the differences described in this manual page.

public static int

Returns:

a new file descriptor on success. On error, -1 is returned and errno is set to indicate the error.
openat
(int dirfd, CharSequence pathname, int flags, int mode)

The openat() system call operates in exactly the same way as open(2), except for the differences described in this manual page.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait