summaryrefslogtreecommitdiffstats
path: root/sys/sys/fcntl.h
Commit message (Collapse)AuthorAgeFilesLines
* When cleaning up from failed adv locking and checking for write, dokib2016-01-171-0/+2
| | | | | | | | | | | | | | | | | not call VOP_CLOSE() manually. Instead, delegate the close to fo_close() performed as part of the fdrop() on the file failed to open. For this, finish constructing file on error, in particular, set f_vnode and f_ops. Forcibly resetting f_ops to badfileops disabled additional cleanups performed by fo_close() for some file types, in this case it was noted that cdevpriv data was corrupted. Since fo_close() call must be enabled for some file types, it makes more sense to enable it for all files opened through vn_open_cred(). In collaboration with: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* Make it possible for the cdevsw d_close() driver method to detect lastkib2015-12-221-0/+5
| | | | | | | | | | | | | | | | close and close due to revoke(2)-like operation. A new FLASTCLOSE flag indicates that this is last close. FREVOKE is set for revokes, and FNONBLOCK is also set, same as is already done for VOP_CLOSE() call from vgonel(). The flags reuse user open(2) flags which are never stored in f_flag, to not consume bit space in the ABI visible way. Assert this with the static check. Requested and reviewed by: bde Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* Support file verification in MAC.rodrigc2015-04-221-0/+4
| | | | | | | | | | | | | | * Add VCREAT flag to indicate when a new file is being created * Add VVERIFY to indicate verification is required * Both VCREAT and VVERIFY are only passed on the MAC method vnode_check_open and are removed from the accmode after * Add O_VERIFY flag to rtld open of objects * Add 'v' flag to __sflags to set O_VERIFY flag. Submitted by: Steve Kiernan <stevek@juniper.net> Obtained from: Juniper Networks, Inc. GitHub Pull Request: https://github.com/freebsd/freebsd/pull/27 Relnotes: yes
* fcntl.h: Make visible various POSIX.1-2008 features.jilles2014-04-171-9/+7
| | | | | | | | | Also, remove #if __BSD_VISIBLE where it is redundant. When __BSD_VISIBLE is defined to 1, __POSIX_VISIBLE, __XSI_VISIBLE and __ISO_C_VISIBLE are also defined to the newest supported version. PR: 188173 Reviewed by: pluknet
* Fix fcntl F_GETFL F_SETFL for files opened execute-only (O_EXEC).jilles2013-08-251-2/+2
| | | | | | | | | The FFLAGS and OFLAGS now work correctly also for files opened with O_EXEC. Except possibly fuse, the other users pass values without O_EXEC set. fuse appears to assume O_EXEC is handled correctly. Although F_SETFL may not be commonly used for execute-only file descriptors, F_GETFL may be useful to find the access mode.
* Add F_DUP2FD_CLOEXEC. Apparently Solaris 11 already did this.kib2012-07-271-0/+3
| | | | | | Submitted by: Jukka A. Ukkonen <jau iki fi> PR: standards/169962 MFC after: 1 week
* (Incomplete) fixes for symbols visibility issues and style in fcntl.h.kib2012-07-211-5/+12
| | | | | | | | | | | | | | | | | Append '__' prefix to the tag of struct oflock, and put it under BSD namespace. Structure is needed both by libc and kernel, thus cannot be hidden under #ifdef _KERNEL. Move a set of non-standard F_* and O_* constants into BSD namespace. SUSv4 explicitely allows implemenation to pollute F_* and O_* names after fcntl.h is included, but it costs us nothing to adhere to the specification if exact POSIX compliance level is requested by user code. Change some spaces after #define to tabs. Noted by and discussed with: bde MFC after: 1 week
* Implement F_DUPFD_CLOEXEC command for fcntl(2), specified by SUSv4.kib2012-07-191-0/+3
| | | | | | PR: standards/169962 Submitted by: Jukka A. Ukkonen <jau iki fi> MFC after: 1 week
* Add the posix_fadvise(2) system call. It is somewhat similar tojhb2011-11-041-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | madvise(2) except that it operates on a file descriptor instead of a memory region. It is currently only supported on regular files. Just as with madvise(2), the advice given to posix_fadvise(2) can be divided into two types. The first type provide hints about data access patterns and are used in the file read and write routines to modify the I/O flags passed down to VOP_READ() and VOP_WRITE(). These modes are thus filesystem independent. Note that to ease implementation (and since this API is only advisory anyway), only a single non-normal range is allowed per file descriptor. The second type of hints are used to hint to the OS that data will or will not be used. These hints are implemented via a new VOP_ADVISE(). A default implementation is provided which does nothing for the WILLNEED request and attempts to move any clean pages to the cache page queue for the DONTNEED request. This latter case required two other changes. First, a new V_CLEANONLY flag was added to vinvalbuf(). This requests vinvalbuf() to only flush clean buffers for the vnode from the buffer cache and to not remove any backing pages from the vnode. This is used to ensure clean pages are not wired into the buffer cache before attempting to move them to the cache page queue. The second change adds a new vm_object_page_cache() method. This method is somewhat similar to vm_object_page_remove() except that instead of freeing each page in the specified range, it attempts to move clean pages to the cache queue if possible. To preserve the ABI of struct file, the f_cdevpriv pointer is now reused in a union to point to the currently active advice region if one is present for regular files. Reviewed by: jilles, kib, arch@ Approved by: re (kib) MFC after: 1 month
* Sort function prototypes.jhb2011-10-271-3/+3
|
* Add the posix_fallocate(2) syscall. The default implementation inmdf2011-04-181-1/+4
| | | | | | | | | | | | | | vop_stdallocate() is filesystem agnostic and will run as slow as a read/write loop in userspace; however, it serves to correctly implement the functionality for filesystems that do not implement a VOP_ALLOCATE. Note that __FreeBSD_version was already bumped today to 900036 for any ports which would like to use this function. Also reserve space in the syscall table for posix_fadvise(2). Reviewed by: -arch (previous version)
* Add O_CLOEXEC flag to open(2) and fhopen(2).kib2011-03-251-1/+3
| | | | | | | | The new function fallocf(9), that is renamed falloc(9) with added flag argument, is provided to facilitate the merge to stable branch. Reviewed by: jhb MFC after: 1 week
* Add two new fcntls to enable/disable read-ahead:delphij2009-09-281-2/+7
| | | | | | | | | | | | | | | | | | | | - F_READAHEAD: specify the amount for sequential access. The amount is specified in bytes and is rounded up to nearest block size. - F_RDAHEAD: Darwin compatible version that use 128KB as the sequential access size. A third argument of zero disables the read-ahead behavior. Please note that the read-ahead amount is also constrainted by sysctl variable, vfs.read_max, which may need to be raised in order to better utilize this feature. Thanks Igor Sysoev for proposing the feature and submitting the original version, and kib@ for his valuable comments. Submitted by: Igor Sysoev <is rambler-co ru> Reviewed by: kib@ MFC after: 1 month
* Move definitions of AT_* constants from the middle of the open(2) flagskib2009-06-221-17/+18
| | | | | | enumeration. Noted by: bde
* Add openat to the POSIX.1-2008 namespace.das2009-03-041-0/+2
|
* Add missing POSIX 1003.1-2008 open(2) flag; O_TTY_INIT.ed2009-02-281-0/+5
| | | | | | | On FreeBSD, this is the default behaviour. According to the spec, we may give this flag a value of zero, but I'd rather not do this. If we define it to a non-zero value, we can always change default behaviour without changing the ABI. This is very unlikely to happen, though.
* Re-implement the client side of rpc.lockd in the kernel. This implementationdfr2008-06-261-0/+1
| | | | | | | | | | | | provides the correct semantics for flock(2) style locks which are used by the lockf(1) command line tool and the pidfile(3) library. It also implements recovery from server restarts and ensures that dirty cache blocks are written to the server before obtaining locks (allowing multiple clients to use file locking to safely share data). Sponsored by: Isilon Systems PR: 94256 MFC after: 2 weeks
* Add the libc glue and headers definitions for the *at() syscalls.kib2008-03-311-0/+1
| | | | | | | Based on the submission by rdivacky, sponsored by Google Summer of Code 2007 Reviewed by: rwatson, rdivacky Tested by: pho
* Add the constant definition needed by the implementation of thekib2008-03-311-1/+27
| | | | | | | | | openat() and the related syscalls. Based on the submission by rdivacky, sponsored by Google Summer of Code 2007 Reviewed by: rwatson, rdivacky Tested by: pho
* Add the new kernel-mode NFS Lock Manager. To use it instead of thedfr2008-03-261-3/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | user-mode lock manager, build a kernel with the NFSLOCKD option and add '-k' to 'rpc_lockd_flags' in rc.conf. Highlights include: * Thread-safe kernel RPC client - many threads can use the same RPC client handle safely with replies being de-multiplexed at the socket upcall (typically driven directly by the NIC interrupt) and handed off to whichever thread matches the reply. For UDP sockets, many RPC clients can share the same socket. This allows the use of a single privileged UDP port number to talk to an arbitrary number of remote hosts. * Single-threaded kernel RPC server. Adding support for multi-threaded server would be relatively straightforward and would follow approximately the Solaris KPI. A single thread should be sufficient for the NLM since it should rarely block in normal operation. * Kernel mode NLM server supporting cancel requests and granted callbacks. I've tested the NLM server reasonably extensively - it passes both my own tests and the NFS Connectathon locking tests running on Solaris, Mac OS X and Ubuntu Linux. * Userland NLM client supported. While the NLM server doesn't have support for the local NFS client's locking needs, it does have to field async replies and granted callbacks from remote NLMs that the local client has contacted. We relay these replies to the userland rpc.lockd over a local domain RPC socket. * Robust deadlock detection for the local lock manager. In particular it will detect deadlocks caused by a lock request that covers more than one blocking request. As required by the NLM protocol, all deadlock detection happens synchronously - a user is guaranteed that if a lock request isn't rejected immediately, the lock will eventually be granted. The old system allowed for a 'deferred deadlock' condition where a blocked lock request could wake up and find that some other deadlock-causing lock owner had beaten them to the lock. * Since both local and remote locks are managed by the same kernel locking code, local and remote processes can safely use file locks for mutual exclusion. Local processes have no fairness advantage compared to remote processes when contending to lock a region that has just been unlocked - the local lock manager enforces a strict first-come first-served model for both local and remote lockers. Sponsored by: Isilon Systems PR: 95247 107555 115524 116679 MFC after: 2 weeks
* Introduce a new F_DUP2FD command to fcntl(2), for compatibility withantoine2008-03-081-0/+1
| | | | | | | | | | | | Solaris and AIX. fcntl(fd, F_DUP2FD, arg) and dup2(fd, arg) are functionnaly equivalent. Document it. Add some regression tests (identical to the dup2(2) regression tests). PR: 120233 Submitted by: Jukka Ukkonen Approved by: rwaston (mentor) MFC after: 1 month
* Add a new file descriptor type for IPC shared memory objects and use it tojhb2008-01-081-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | implement shm_open(2) and shm_unlink(2) in the kernel: - Each shared memory file descriptor is associated with a swap-backed vm object which provides the backing store. Each descriptor starts off with a size of zero, but the size can be altered via ftruncate(2). The shared memory file descriptors also support fstat(2). read(2), write(2), ioctl(2), select(2), poll(2), and kevent(2) are not supported on shared memory file descriptors. - shm_open(2) and shm_unlink(2) are now implemented as system calls that manage shared memory file descriptors. The virtual namespace that maps pathnames to shared memory file descriptors is implemented as a hash table where the hash key is generated via the 32-bit Fowler/Noll/Vo hash of the pathname. - As an extension, the constant 'SHM_ANON' may be specified in place of the path argument to shm_open(2). In this case, an unnamed shared memory file descriptor will be created similar to the IPC_PRIVATE key for shmget(2). Note that the shared memory object can still be shared among processes by sharing the file descriptor via fork(2) or sendmsg(2), but it is unnamed. This effectively serves to implement the getmemfd() idea bandied about the lists several times over the years. - The backing store for shared memory file descriptors are garbage collected when they are not referenced by any open file descriptors or the shm_open(2) virtual namespace. Submitted by: dillon, peter (previous versions) Submitted by: rwatson (I based this on his version) Reviewed by: alc (suggested converting getmemfd() to shm_open())
* Remove advertising clause from University of California Regent's license,imp2004-04-071-4/+0
| | | | | | per letter dated July 22, 1999. Approved by: core
* Move FMARK and FDEFER til sys/file.h where they belong.phk2003-06-201-3/+0
| | | | Order the fields in struct file in sections after their scope.
* o Add typedefs for mode_t, off_t, pid_t rather than includingmike2002-09-171-13/+37
| | | | | | | | <sys/types.h>. o Use the relatively new visibility primitives for conditionals. o Make O_SYNC an alias for O_FSYNC. o Mark the F* names as deprecated. o Add some comments to note missing POSIX requirements or options.
* Remove __Palfred2002-03-191-4/+4
|
* SMP Lock struct file, filedesc and the global file list.alfred2002-01-131-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Seigo Tanimura (tanimura) posted the initial delta. I've polished it quite a bit reducing the need for locking and adapting it for KSE. Locks: 1 mutex in each filedesc protects all the fields. protects "struct file" initialization, while a struct file is being changed from &badfileops -> &pipeops or something the filedesc should be locked. 1 mutex in each struct file protects the refcount fields. doesn't protect anything else. the flags used for garbage collection have been moved to f_gcflag which was the FILLER short, this doesn't need locking because the garbage collection is a single threaded container. could likely be made to use a pool mutex. 1 sx lock for the global filelist. struct file * fhold(struct file *fp); /* increments reference count on a file */ struct file * fhold_locked(struct file *fp); /* like fhold but expects file to locked */ struct file * ffind_hold(struct thread *, int fd); /* finds the struct file in thread, adds one reference and returns it unlocked */ struct file * ffind_lock(struct thread *, int fd); /* ffind_hold, but returns file locked */ I still have to smp-safe the fget cruft, I'll get to that asap.
* This patch implements O_DIRECT about 80% of the way. It takes a patchsetdillon2001-05-241-2/+5
| | | | | | | | | | | | | | | | Tor created a while ago, removes the raw I/O piece (that has cache coherency problems), and adds a buffer cache / VM freeing piece. Essentially this patch causes O_DIRECT I/O to not be left in the cache, but does not prevent it from going through the cache, hence the 80%. For the last 20% we need a method by which the I/O can be issued directly to buffer supplied by the user process and bypass the buffer cache entirely, but still maintain cache coherency. I also have the code working under -stable but the changes made to sys/file.h may not be MFCable, so an MFC is not on the table yet. Submitted by: tegge, dillon
* Implement POSIX.1b shared memory objects. In this implementation,wollman2000-04-221-2/+18
| | | | | | | | shared memory objects are regular files; the shm_open(3) routine uses fcntl(2) to set a flag on the descriptor which tells mmap(2) to automatically apply MAP_NOSYNC. Not objected to by: bde, dillon, dufault, jasone
* Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"peter1999-12-291-6/+6
| | | | | | is an application space macro and the applications are supposed to be free to use it as they please (but cannot). This is consistant with the other BSD's who made this change quite some time ago. More commits to come.
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Implement a new open(2) flag: O_NOFOLLOW. This will instruct openpeter1998-04-061-1/+2
| | | | | | | | | | | to not follow symlinks, but to open a handle on the link itself(!). As strange as this might sound, it has several useful applications safe race-free ways of opening files in hostile areas (eg: /tmp, a mode 1777 /var/mail, etc). It also would allow things like fchown() to work on the link rather than having to implement a new syscall specifically for that task. Reviewed by: phk
* Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are notpeter1997-02-221-1/+1
| | | | ready for it yet.
* Make the long-awaited change from $Id$ to $FreeBSD$jkh1997-01-141-1/+1
| | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
* Made O_NOCTTY distinct from the other flags (it clashed with O_RDONLY).bde1996-11-291-3/+3
| | | | Found by: NIST-PCTS
* Fix a bunch of spelling errors in the comment fields ofmpp1996-01-301-2/+2
| | | | a bunch of system include files.
* Added $Id$dg1994-08-021-0/+1
|
* BSD 4.4 Lite Kernel Sourcesrgrimes1994-05-241-0/+190
OpenPOWER on IntegriCloud