linux/include/uapi/asm-generic/fcntl.h

/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _ASM_GENERIC_FCNTL_H
#define _ASM_GENERIC_FCNTL_H

#include <linux/types.h>

/*
 * FMODE_EXEC is 0x20
 * FMODE_NONOTIFY is 0x4000000
 * These cannot be used by userspace O_* until internal and external open
 * flags are split.
 * -Eric Paris
 */

/*
 * When introducing new O_* bits, please check its uniqueness in fcntl_init().
 */

#define O_ACCMODE
#define O_RDONLY
#define O_WRONLY
#define O_RDWR
#ifndef O_CREAT
#define O_CREAT
#endif
#ifndef O_EXCL
#define O_EXCL
#endif
#ifndef O_NOCTTY
#define O_NOCTTY
#endif
#ifndef O_TRUNC
#define O_TRUNC
#endif
#ifndef O_APPEND
#define O_APPEND
#endif
#ifndef O_NONBLOCK
#define O_NONBLOCK
#endif
#ifndef O_DSYNC
#define O_DSYNC
#endif
#ifndef FASYNC
#define FASYNC
#endif
#ifndef O_DIRECT
#define O_DIRECT
#endif
#ifndef O_LARGEFILE
#define O_LARGEFILE
#endif
#ifndef O_DIRECTORY
#define O_DIRECTORY
#endif
#ifndef O_NOFOLLOW
#define O_NOFOLLOW
#endif
#ifndef O_NOATIME
#define O_NOATIME
#endif
#ifndef O_CLOEXEC
#define O_CLOEXEC
#endif

/*
 * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using
 * the O_SYNC flag.  We continue to use the existing numerical value
 * for O_DSYNC semantics now, but using the correct symbolic name for it.
 * This new value is used to request true Posix O_SYNC semantics.  It is
 * defined in this strange way to make sure applications compiled against
 * new headers get at least O_DSYNC semantics on older kernels.
 *
 * This has the nice side-effect that we can simply test for O_DSYNC
 * wherever we do not care if O_DSYNC or O_SYNC is used.
 *
 * Note: __O_SYNC must never be used directly.
 */
#ifndef O_SYNC
#define __O_SYNC
#define O_SYNC
#endif

#ifndef O_PATH
#define O_PATH
#endif

#ifndef __O_TMPFILE
#define __O_TMPFILE
#endif

/* a horrid kludge trying to make sure that this will fail on old kernels */
#define O_TMPFILE

#ifndef O_NDELAY
#define O_NDELAY
#endif

#define F_DUPFD
#define F_GETFD
#define F_SETFD
#define F_GETFL
#define F_SETFL
#ifndef F_GETLK
#define F_GETLK
#define F_SETLK
#define F_SETLKW
#endif
#ifndef F_SETOWN
#define F_SETOWN
#define F_GETOWN
#endif
#ifndef F_SETSIG
#define F_SETSIG
#define F_GETSIG
#endif

#if __BITS_PER_LONG == 32 || defined(__KERNEL__)
#ifndef F_GETLK64
#define F_GETLK64
#define F_SETLK64
#define F_SETLKW64
#endif
#endif /* __BITS_PER_LONG == 32 || defined(__KERNEL__) */

#ifndef F_SETOWN_EX
#define F_SETOWN_EX
#define F_GETOWN_EX
#endif

#ifndef F_GETOWNER_UIDS
#define F_GETOWNER_UIDS
#endif

/*
 * Open File Description Locks
 *
 * Usually record locks held by a process are released on *any* close and are
 * not inherited across a fork().
 *
 * These cmd values will set locks that conflict with process-associated
 * record  locks, but are "owned" by the open file description, not the
 * process. This means that they are inherited across fork() like BSD (flock)
 * locks, and they are only released automatically when the last reference to
 * the the open file against which they were acquired is put.
 */
#define F_OFD_GETLK
#define F_OFD_SETLK
#define F_OFD_SETLKW

#define F_OWNER_TID
#define F_OWNER_PID
#define F_OWNER_PGRP

struct f_owner_ex {};

/* for F_[GET|SET]FL */
#define FD_CLOEXEC

/* for posix fcntl() and lockf() */
#ifndef F_RDLCK
#define F_RDLCK
#define F_WRLCK
#define F_UNLCK
#endif

/* for old implementation of bsd flock () */
#ifndef F_EXLCK
#define F_EXLCK
#define F_SHLCK
#endif

/* operations for bsd flock(), also used by the kernel implementation */
#define LOCK_SH
#define LOCK_EX
#define LOCK_NB
#define LOCK_UN

/*
 * LOCK_MAND support has been removed from the kernel. We leave the symbols
 * here to not break legacy builds, but these should not be used in new code.
 */
#define LOCK_MAND
#define LOCK_READ
#define LOCK_WRITE
#define LOCK_RW

#define F_LINUX_SPECIFIC_BASE

#ifndef HAVE_ARCH_STRUCT_FLOCK
struct flock {};

struct flock64 {};
#endif /* HAVE_ARCH_STRUCT_FLOCK */

#endif /* _ASM_GENERIC_FCNTL_H */