2005-04-17 02:20:36 +04:00
|
|
|
#ifndef _LINUX_FCNTL_H
|
|
|
|
#define _LINUX_FCNTL_H
|
|
|
|
|
|
|
|
#include <asm/fcntl.h>
|
|
|
|
|
F_DUPFD_CLOEXEC implementation
One more small change to extend the availability of creation of file
descriptors with FD_CLOEXEC set. Adding a new command to fcntl() requires
no new system call and the overall impact on code size if minimal.
If this patch gets accepted we will also add this change to the next
revision of the POSIX spec.
To test the patch, use the following little program. Adjust the value of
F_DUPFD_CLOEXEC appropriately.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#ifndef F_DUPFD_CLOEXEC
# define F_DUPFD_CLOEXEC 12
#endif
int
main (int argc, char *argv[])
{
if (argc > 1)
{
if (fcntl (3, F_GETFD) == 0)
{
puts ("descriptor not closed");
exit (1);
}
if (errno != EBADF)
{
puts ("error not EBADF");
exit (1);
}
exit (0);
}
int fd = fcntl (STDOUT_FILENO, F_DUPFD_CLOEXEC, 0);
if (fd == -1 && errno == EINVAL)
{
puts ("F_DUPFD_CLOEXEC not supported");
return 0;
}
if (fd != 3)
{
puts ("program called with descriptors other than 0,1,2");
return 1;
}
execl ("/proc/self/exe", "/proc/self/exe", "1", NULL);
puts ("execl failed");
return 1;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Ulrich Drepper <drepper@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Cc: <linux-arch@vger.kernel.org>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-10-17 10:30:26 +04:00
|
|
|
#define F_SETLEASE (F_LINUX_SPECIFIC_BASE + 0)
|
|
|
|
#define F_GETLEASE (F_LINUX_SPECIFIC_BASE + 1)
|
2007-01-19 01:52:58 +03:00
|
|
|
|
F_DUPFD_CLOEXEC implementation
One more small change to extend the availability of creation of file
descriptors with FD_CLOEXEC set. Adding a new command to fcntl() requires
no new system call and the overall impact on code size if minimal.
If this patch gets accepted we will also add this change to the next
revision of the POSIX spec.
To test the patch, use the following little program. Adjust the value of
F_DUPFD_CLOEXEC appropriately.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#ifndef F_DUPFD_CLOEXEC
# define F_DUPFD_CLOEXEC 12
#endif
int
main (int argc, char *argv[])
{
if (argc > 1)
{
if (fcntl (3, F_GETFD) == 0)
{
puts ("descriptor not closed");
exit (1);
}
if (errno != EBADF)
{
puts ("error not EBADF");
exit (1);
}
exit (0);
}
int fd = fcntl (STDOUT_FILENO, F_DUPFD_CLOEXEC, 0);
if (fd == -1 && errno == EINVAL)
{
puts ("F_DUPFD_CLOEXEC not supported");
return 0;
}
if (fd != 3)
{
puts ("program called with descriptors other than 0,1,2");
return 1;
}
execl ("/proc/self/exe", "/proc/self/exe", "1", NULL);
puts ("execl failed");
return 1;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Ulrich Drepper <drepper@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Cc: <linux-arch@vger.kernel.org>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-10-17 10:30:26 +04:00
|
|
|
/*
|
|
|
|
* Cancel a blocking posix lock; internal use only until we expose an
|
|
|
|
* asynchronous lock api to userspace:
|
|
|
|
*/
|
|
|
|
#define F_CANCELLK (F_LINUX_SPECIFIC_BASE + 5)
|
|
|
|
|
|
|
|
/* Create a file descriptor with FD_CLOEXEC set. */
|
|
|
|
#define F_DUPFD_CLOEXEC (F_LINUX_SPECIFIC_BASE + 6)
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Request nofications on a directory.
|
|
|
|
* See below for events that may be notified.
|
|
|
|
*/
|
|
|
|
#define F_NOTIFY (F_LINUX_SPECIFIC_BASE+2)
|
|
|
|
|
2010-05-20 12:43:18 +04:00
|
|
|
/*
|
|
|
|
* Set and get of pipe page size array
|
|
|
|
*/
|
|
|
|
#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
|
|
|
|
#define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8)
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* Types of directory notifications that may be requested.
|
|
|
|
*/
|
|
|
|
#define DN_ACCESS 0x00000001 /* File accessed */
|
|
|
|
#define DN_MODIFY 0x00000002 /* File modified */
|
|
|
|
#define DN_CREATE 0x00000004 /* File created */
|
|
|
|
#define DN_DELETE 0x00000008 /* File removed */
|
|
|
|
#define DN_RENAME 0x00000010 /* File renamed */
|
|
|
|
#define DN_ATTRIB 0x00000020 /* File changed attibutes */
|
|
|
|
#define DN_MULTISHOT 0x80000000 /* Don't remove notifier */
|
|
|
|
|
2006-01-19 04:43:53 +03:00
|
|
|
#define AT_FDCWD -100 /* Special value used to indicate
|
|
|
|
openat should use the current
|
|
|
|
working directory. */
|
|
|
|
#define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. */
|
|
|
|
#define AT_REMOVEDIR 0x200 /* Remove directory instead of
|
|
|
|
unlinking file. */
|
2006-06-25 16:49:11 +04:00
|
|
|
#define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */
|
2011-01-14 21:45:31 +03:00
|
|
|
#define AT_NO_AUTOMOUNT 0x800 /* Suppress terminal automount traversal */
|
2011-03-15 01:56:51 +03:00
|
|
|
#define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname */
|
2006-01-19 04:43:53 +03:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
2005-06-23 11:09:58 +04:00
|
|
|
#ifndef force_o_largefile
|
|
|
|
#define force_o_largefile() (BITS_PER_LONG != 32)
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#if BITS_PER_LONG == 32
|
|
|
|
#define IS_GETLK32(cmd) ((cmd) == F_GETLK)
|
|
|
|
#define IS_SETLK32(cmd) ((cmd) == F_SETLK)
|
|
|
|
#define IS_SETLKW32(cmd) ((cmd) == F_SETLKW)
|
|
|
|
#define IS_GETLK64(cmd) ((cmd) == F_GETLK64)
|
|
|
|
#define IS_SETLK64(cmd) ((cmd) == F_SETLK64)
|
|
|
|
#define IS_SETLKW64(cmd) ((cmd) == F_SETLKW64)
|
|
|
|
#else
|
|
|
|
#define IS_GETLK32(cmd) (0)
|
|
|
|
#define IS_SETLK32(cmd) (0)
|
|
|
|
#define IS_SETLKW32(cmd) (0)
|
|
|
|
#define IS_GETLK64(cmd) ((cmd) == F_GETLK)
|
|
|
|
#define IS_SETLK64(cmd) ((cmd) == F_SETLK)
|
|
|
|
#define IS_SETLKW64(cmd) ((cmd) == F_SETLKW)
|
|
|
|
#endif /* BITS_PER_LONG == 32 */
|
|
|
|
|
|
|
|
#define IS_GETLK(cmd) (IS_GETLK32(cmd) || IS_GETLK64(cmd))
|
|
|
|
#define IS_SETLK(cmd) (IS_SETLK32(cmd) || IS_SETLK64(cmd))
|
|
|
|
#define IS_SETLKW(cmd) (IS_SETLKW32(cmd) || IS_SETLKW64(cmd))
|
|
|
|
|
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
|
|
|
|
#endif
|