/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */1#ifndef _ASM_GENERIC_FCNTL_H2#define _ASM_GENERIC_FCNTL_H34#include <linux/types.h>56/*7* FMODE_EXEC is 0x208* These cannot be used by userspace O_* until internal and external open9* flags are split.10* -Eric Paris11*/1213/*14* When introducing new O_* bits, please check its uniqueness in fcntl_init().15*/1617#define O_ACCMODE 0000000318#define O_RDONLY 0000000019#define O_WRONLY 0000000120#define O_RDWR 0000000221#ifndef O_CREAT22#define O_CREAT 00000100 /* not fcntl */23#endif24#ifndef O_EXCL25#define O_EXCL 00000200 /* not fcntl */26#endif27#ifndef O_NOCTTY28#define O_NOCTTY 00000400 /* not fcntl */29#endif30#ifndef O_TRUNC31#define O_TRUNC 00001000 /* not fcntl */32#endif33#ifndef O_APPEND34#define O_APPEND 0000200035#endif36#ifndef O_NONBLOCK37#define O_NONBLOCK 0000400038#endif39#ifndef O_DSYNC40#define O_DSYNC 00010000 /* used to be O_SYNC, see below */41#endif42#ifndef FASYNC43#define FASYNC 00020000 /* fcntl, for BSD compatibility */44#endif45#ifndef O_DIRECT46#define O_DIRECT 00040000 /* direct disk access hint */47#endif48#ifndef O_LARGEFILE49#define O_LARGEFILE 0010000050#endif51#ifndef O_DIRECTORY52#define O_DIRECTORY 00200000 /* must be a directory */53#endif54#ifndef O_NOFOLLOW55#define O_NOFOLLOW 00400000 /* don't follow links */56#endif57#ifndef O_NOATIME58#define O_NOATIME 0100000059#endif60#ifndef O_CLOEXEC61#define O_CLOEXEC 02000000 /* set close_on_exec */62#endif6364/*65* Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using66* the O_SYNC flag. We continue to use the existing numerical value67* for O_DSYNC semantics now, but using the correct symbolic name for it.68* This new value is used to request true Posix O_SYNC semantics. It is69* defined in this strange way to make sure applications compiled against70* new headers get at least O_DSYNC semantics on older kernels.71*72* This has the nice side-effect that we can simply test for O_DSYNC73* wherever we do not care if O_DSYNC or O_SYNC is used.74*75* Note: __O_SYNC must never be used directly.76*/77#ifndef O_SYNC78#define __O_SYNC 0400000079#define O_SYNC (__O_SYNC|O_DSYNC)80#endif8182#ifndef O_PATH83#define O_PATH 01000000084#endif8586#ifndef __O_TMPFILE87#define __O_TMPFILE 02000000088#endif8990/* a horrid kludge trying to make sure that this will fail on old kernels */91#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)9293#ifndef O_NDELAY94#define O_NDELAY O_NONBLOCK95#endif9697#define F_DUPFD 0 /* dup */98#define F_GETFD 1 /* get close_on_exec */99#define F_SETFD 2 /* set/clear close_on_exec */100#define F_GETFL 3 /* get file->f_flags */101#define F_SETFL 4 /* set file->f_flags */102#ifndef F_GETLK103#define F_GETLK 5104#define F_SETLK 6105#define F_SETLKW 7106#endif107#ifndef F_SETOWN108#define F_SETOWN 8 /* for sockets. */109#define F_GETOWN 9 /* for sockets. */110#endif111#ifndef F_SETSIG112#define F_SETSIG 10 /* for sockets. */113#define F_GETSIG 11 /* for sockets. */114#endif115116#if __BITS_PER_LONG == 32 || defined(__KERNEL__)117#ifndef F_GETLK64118#define F_GETLK64 12 /* using 'struct flock64' */119#define F_SETLK64 13120#define F_SETLKW64 14121#endif122#endif /* __BITS_PER_LONG == 32 || defined(__KERNEL__) */123124#ifndef F_SETOWN_EX125#define F_SETOWN_EX 15126#define F_GETOWN_EX 16127#endif128129#ifndef F_GETOWNER_UIDS130#define F_GETOWNER_UIDS 17131#endif132133/*134* Open File Description Locks135*136* Usually record locks held by a process are released on *any* close and are137* not inherited across a fork().138*139* These cmd values will set locks that conflict with process-associated140* record locks, but are "owned" by the open file description, not the141* process. This means that they are inherited across fork() like BSD (flock)142* locks, and they are only released automatically when the last reference to143* the the open file against which they were acquired is put.144*/145#define F_OFD_GETLK 36146#define F_OFD_SETLK 37147#define F_OFD_SETLKW 38148149#define F_OWNER_TID 0150#define F_OWNER_PID 1151#define F_OWNER_PGRP 2152153struct f_owner_ex {154int type;155__kernel_pid_t pid;156};157158/* for F_[GET|SET]FL */159#define FD_CLOEXEC 1 /* actually anything with low bit set goes */160161/* for posix fcntl() and lockf() */162#ifndef F_RDLCK163#define F_RDLCK 0164#define F_WRLCK 1165#define F_UNLCK 2166#endif167168/* for old implementation of bsd flock () */169#ifndef F_EXLCK170#define F_EXLCK 4 /* or 3 */171#define F_SHLCK 8 /* or 4 */172#endif173174/* operations for bsd flock(), also used by the kernel implementation */175#define LOCK_SH 1 /* shared lock */176#define LOCK_EX 2 /* exclusive lock */177#define LOCK_NB 4 /* or'd with one of the above to prevent178blocking */179#define LOCK_UN 8 /* remove lock */180181/*182* LOCK_MAND support has been removed from the kernel. We leave the symbols183* here to not break legacy builds, but these should not be used in new code.184*/185#define LOCK_MAND 32 /* This is a mandatory flock ... */186#define LOCK_READ 64 /* which allows concurrent read operations */187#define LOCK_WRITE 128 /* which allows concurrent write operations */188#define LOCK_RW 192 /* which allows concurrent read & write ops */189190#define F_LINUX_SPECIFIC_BASE 1024191192#ifndef HAVE_ARCH_STRUCT_FLOCK193struct flock {194short l_type;195short l_whence;196__kernel_off_t l_start;197__kernel_off_t l_len;198__kernel_pid_t l_pid;199#ifdef __ARCH_FLOCK_EXTRA_SYSID200__ARCH_FLOCK_EXTRA_SYSID201#endif202#ifdef __ARCH_FLOCK_PAD203__ARCH_FLOCK_PAD204#endif205};206207struct flock64 {208short l_type;209short l_whence;210__kernel_loff_t l_start;211__kernel_loff_t l_len;212__kernel_pid_t l_pid;213#ifdef __ARCH_FLOCK64_PAD214__ARCH_FLOCK64_PAD215#endif216};217#endif /* HAVE_ARCH_STRUCT_FLOCK */218219#endif /* _ASM_GENERIC_FCNTL_H */220221222