summaryrefslogtreecommitdiff
path: root/posix/unistd.h
diff options
context:
space:
mode:
Diffstat (limited to 'posix/unistd.h')
-rw-r--r--posix/unistd.h194
1 files changed, 129 insertions, 65 deletions
diff --git a/posix/unistd.h b/posix/unistd.h
index 5d42169e82..4e1e9dfaa2 100644
--- a/posix/unistd.h
+++ b/posix/unistd.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2006, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -56,7 +56,9 @@ __BEGIN_DECLS
#define _POSIX2_LOCALEDEF 200112L
/* X/Open version number to which the library conforms. It is selectable. */
-#ifdef __USE_UNIX98
+#ifdef __USE_XOPEN2K
+# define _XOPEN_VERSION 600
+#elif defined __USE_UNIX98
# define _XOPEN_VERSION 500
#else
# define _XOPEN_VERSION 4
@@ -260,8 +262,20 @@ extern int access (__const char *__name, int __type) __THROW __nonnull ((1));
(as normal file operations use). */
extern int euidaccess (__const char *__name, int __type)
__THROW __nonnull ((1));
+
+/* An alias for `euidaccess', used by some other systems. */
+extern int eaccess (__const char *__name, int __type)
+ __THROW __nonnull ((1));
#endif
+#ifdef __USE_ATFILE
+/* Test for access to FILE relative to the directory FD is open on.
+ If AT_EACCESS is set in FLAG, then use effective IDs like `eaccess',
+ otherwise use real IDs like `access'. */
+extern int faccessat (int __fd, __const char *__file, int __type, int __flag)
+ __THROW __nonnull ((2)) __wur;
+#endif /* Use GNU. */
+
/* Values for the WHENCE argument to lseek. */
#ifndef _STDIO_H /* <stdio.h> has the same definitions. */
@@ -295,7 +309,8 @@ extern __off64_t __REDIRECT_NTH (lseek,
# endif
#endif
#ifdef __USE_LARGEFILE64
-extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence) __THROW;
+extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence)
+ __THROW;
#endif
/* Close the file descriptor FD.
@@ -309,13 +324,13 @@ extern int close (int __fd);
This function is a cancellation point and therefore not marked with
__THROW. */
-extern ssize_t read (int __fd, void *__buf, size_t __nbytes);
+extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur;
/* Write N bytes of BUF to FD. Return the number written, or -1.
This function is a cancellation point and therefore not marked with
__THROW. */
-extern ssize_t write (int __fd, __const void *__buf, size_t __n);
+extern ssize_t write (int __fd, __const void *__buf, size_t __n) __wur;
#ifdef __USE_UNIX98
# ifndef __USE_FILE_OFFSET64
@@ -326,7 +341,7 @@ extern ssize_t write (int __fd, __const void *__buf, size_t __n);
This function is a cancellation point and therefore not marked with
__THROW. */
extern ssize_t pread (int __fd, void *__buf, size_t __nbytes,
- __off_t __offset);
+ __off_t __offset) __wur;
/* Write N bytes of BUF to FD at the given position OFFSET without
changing the file pointer. Return the number written, or -1.
@@ -334,15 +349,15 @@ extern ssize_t pread (int __fd, void *__buf, size_t __nbytes,
This function is a cancellation point and therefore not marked with
__THROW. */
extern ssize_t pwrite (int __fd, __const void *__buf, size_t __n,
- __off_t __offset);
+ __off_t __offset) __wur;
# else
# ifdef __REDIRECT
extern ssize_t __REDIRECT (pread, (int __fd, void *__buf, size_t __nbytes,
__off64_t __offset),
- pread64);
+ pread64) __wur;
extern ssize_t __REDIRECT (pwrite, (int __fd, __const void *__buf,
size_t __nbytes, __off64_t __offset),
- pwrite64);
+ pwrite64) __wur;
# else
# define pread pread64
# define pwrite pwrite64
@@ -354,11 +369,11 @@ extern ssize_t __REDIRECT (pwrite, (int __fd, __const void *__buf,
changing the file pointer. Return the number read, -1 for errors
or 0 for EOF. */
extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes,
- __off64_t __offset);
+ __off64_t __offset) __wur;
/* Write N bytes of BUF to FD at the given position OFFSET without
changing the file pointer. Return the number written, or -1. */
extern ssize_t pwrite64 (int __fd, __const void *__buf, size_t __n,
- __off64_t __offset);
+ __off64_t __offset) __wur;
# endif
#endif
@@ -366,7 +381,7 @@ extern ssize_t pwrite64 (int __fd, __const void *__buf, size_t __n,
If successful, two file descriptors are stored in PIPEDES;
bytes written on PIPEDES[1] can be read from PIPEDES[0].
Returns 0 if successful, -1 if not. */
-extern int pipe (int __pipedes[2]) __THROW;
+extern int pipe (int __pipedes[2]) __THROW __wur;
/* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM.
If SECONDS is zero, any currently scheduled alarm will be cancelled.
@@ -416,26 +431,34 @@ extern int pause (void);
/* Change the owner and group of FILE. */
extern int chown (__const char *__file, __uid_t __owner, __gid_t __group)
- __THROW __nonnull ((1));
+ __THROW __nonnull ((1)) __wur;
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
/* Change the owner and group of the file that FD is open on. */
-extern int fchown (int __fd, __uid_t __owner, __gid_t __group) __THROW;
+extern int fchown (int __fd, __uid_t __owner, __gid_t __group) __THROW __wur;
/* Change owner and group of FILE, if it is a symbolic
link the ownership of the symbolic link is changed. */
extern int lchown (__const char *__file, __uid_t __owner, __gid_t __group)
- __THROW __nonnull ((1));
+ __THROW __nonnull ((1)) __wur;
#endif /* Use BSD || X/Open Unix. */
+#ifdef __USE_ATFILE
+/* Change the owner and group of FILE relative to the directory FD is open
+ on. */
+extern int fchownat (int __fd, __const char *__file, __uid_t __owner,
+ __gid_t __group, int __flag)
+ __THROW __nonnull ((2)) __wur;
+#endif /* Use GNU. */
+
/* Change the process's working directory to PATH. */
-extern int chdir (__const char *__path) __THROW __nonnull ((1));
+extern int chdir (__const char *__path) __THROW __nonnull ((1)) __wur;
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
/* Change the process's working directory to the one FD is open on. */
-extern int fchdir (int __fd) __THROW;
+extern int fchdir (int __fd) __THROW __wur;
#endif
/* Get the pathname of the current working directory,
@@ -445,7 +468,7 @@ extern int fchdir (int __fd) __THROW;
an array is allocated with `malloc'; the array is SIZE
bytes long, unless SIZE == 0, in which case it is as
big as necessary. */
-extern char *getcwd (char *__buf, size_t __size) __THROW;
+extern char *getcwd (char *__buf, size_t __size) __THROW __wur;
#ifdef __USE_GNU
/* Return a malloc'd string containing the current directory name.
@@ -458,12 +481,13 @@ extern char *get_current_dir_name (void) __THROW;
/* Put the absolute pathname of the current working directory in BUF.
If successful, return BUF. If not, put an error message in
BUF and return NULL. BUF should be at least PATH_MAX bytes long. */
-extern char *getwd (char *__buf) __THROW __nonnull ((1));
+extern char *getwd (char *__buf)
+ __THROW __nonnull ((1)) __attribute_deprecated__ __wur;
#endif
/* Duplicate FD, returning a new file descriptor on the same file. */
-extern int dup (int __fd) __THROW;
+extern int dup (int __fd) __THROW __wur;
/* Duplicate FD to FD2, closing FD2 and making it open on the same file. */
extern int dup2 (int __fd, int __fd2) __THROW;
@@ -516,7 +540,7 @@ extern int execlp (__const char *__file, __const char *__arg, ...)
#if defined __USE_MISC || defined __USE_XOPEN
/* Add INC to priority of the current process. */
-extern int nice (int __inc) __THROW;
+extern int nice (int __inc) __THROW __wur;
#endif
@@ -629,7 +653,7 @@ extern __gid_t getegid (void) __THROW;
/* If SIZE is zero, return the number of supplementary groups
the calling process is in. Otherwise, fill in the group IDs
of its supplementary groups in LIST and return the number written. */
-extern int getgroups (int __size, __gid_t __list[]) __THROW;
+extern int getgroups (int __size, __gid_t __list[]) __THROW __wur;
#ifdef __USE_GNU
/* Return nonzero iff the calling process is in group GID. */
@@ -671,21 +695,25 @@ extern int setegid (__gid_t __gid) __THROW;
#endif /* Use BSD. */
#ifdef __USE_GNU
-/* Fetch the effective user ID, real user ID, and saved-set user ID,
+/* Fetch the real user ID, effective user ID, and saved-set user ID,
of the calling process. */
-extern int getresuid (__uid_t *__euid, __uid_t *__ruid, __uid_t *__suid);
+extern int getresuid (__uid_t *__ruid, __uid_t *__euid, __uid_t *__suid)
+ __THROW;
-/* Fetch the effective group ID, real group ID, and saved-set group ID,
+/* Fetch the real group ID, effective group ID, and saved-set group ID,
of the calling process. */
-extern int getresgid (__gid_t *__egid, __gid_t *__rgid, __gid_t *__sgid);
+extern int getresgid (__gid_t *__rgid, __gid_t *__egid, __gid_t *__sgid)
+ __THROW;
-/* Set the effective user ID, real user ID, and saved-set user ID,
- of the calling process to EUID, RUID, and SUID, respectively. */
-extern int setresuid (__uid_t __euid, __uid_t __ruid, __uid_t __suid);
+/* Set the real user ID, effective user ID, and saved-set user ID,
+ of the calling process to RUID, EUID, and SUID, respectively. */
+extern int setresuid (__uid_t __ruid, __uid_t __euid, __uid_t __suid)
+ __THROW;
-/* Set the effective group ID, real group ID, and saved-set group ID,
- of the calling process to EGID, RGID, and SGID, respectively. */
-extern int setresgid (__gid_t __egid, __gid_t __rgid, __gid_t __sgid);
+/* Set the real group ID, effective group ID, and saved-set group ID,
+ of the calling process to RGID, EGID, and SGID, respectively. */
+extern int setresgid (__gid_t __rgid, __gid_t __egid, __gid_t __sgid)
+ __THROW;
#endif
@@ -710,7 +738,7 @@ extern char *ttyname (int __fd) __THROW;
/* Store at most BUFLEN characters of the pathname of the terminal FD is
open on in BUF. Return 0 on success, otherwise an error number. */
extern int ttyname_r (int __fd, char *__buf, size_t __buflen)
- __THROW __nonnull ((2));
+ __THROW __nonnull ((2)) __wur;
/* Return 1 if FD is a valid descriptor associated
with a terminal, zero if not. */
@@ -726,23 +754,49 @@ extern int ttyslot (void) __THROW;
/* Make a link to FROM named TO. */
extern int link (__const char *__from, __const char *__to)
- __THROW __nonnull ((1, 2));
+ __THROW __nonnull ((1, 2)) __wur;
+
+#ifdef __USE_ATFILE
+/* Like link but relative paths in TO and FROM are interpreted relative
+ to FROMFD and TOFD respectively. */
+extern int linkat (int __fromfd, __const char *__from, int __tofd,
+ __const char *__to, int __flags)
+ __THROW __nonnull ((2, 4)) __wur;
+#endif
-#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
+#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
/* Make a symbolic link to FROM named TO. */
extern int symlink (__const char *__from, __const char *__to)
- __THROW __nonnull ((1, 2));
+ __THROW __nonnull ((1, 2)) __wur;
/* Read the contents of the symbolic link PATH into no more than
LEN bytes of BUF. The contents are not null-terminated.
Returns the number of characters read, or -1 for errors. */
-extern int readlink (__const char *__restrict __path, char *__restrict __buf,
- size_t __len) __THROW __nonnull ((1, 2));
+extern ssize_t readlink (__const char *__restrict __path,
+ char *__restrict __buf, size_t __len)
+ __THROW __nonnull ((1, 2)) __wur;
#endif /* Use BSD. */
+#ifdef __USE_ATFILE
+/* Like symlink but a relative path in TO is interpreted relative to TOFD. */
+extern int symlinkat (__const char *__from, int __tofd,
+ __const char *__to) __THROW __nonnull ((1, 3)) __wur;
+
+/* Like readlink but a relative PATH is interpreted relative to FD. */
+extern ssize_t readlinkat (int __fd, __const char *__restrict __path,
+ char *__restrict __buf, size_t __len)
+ __THROW __nonnull ((2, 3)) __wur;
+#endif
+
/* Remove the link NAME. */
extern int unlink (__const char *__name) __THROW __nonnull ((1));
+#ifdef __USE_ATFILE
+/* Remove the link NAME relative to FD. */
+extern int unlinkat (int __fd, __const char *__name, int __flag)
+ __THROW __nonnull ((2));
+#endif
+
/* Remove the directory PATH. */
extern int rmdir (__const char *__path) __THROW __nonnull ((1));
@@ -759,7 +813,7 @@ extern int tcsetpgrp (int __fd, __pid_t __pgrp_id) __THROW;
This function is a possible cancellation points and therefore not
marked with __THROW. */
extern char *getlogin (void);
-#if defined __USE_REENTRANT || defined __USE_UNIX98
+#if defined __USE_REENTRANT || defined __USE_POSIX199506
/* Return at most NAME_LEN characters of the login name of the user in NAME.
If it cannot be determined or some other error occurred, return the error
code. Otherwise return 0.
@@ -796,20 +850,20 @@ extern int gethostname (char *__name, size_t __len) __THROW __nonnull ((1));
/* Set the name of the current host to NAME, which is LEN bytes long.
This call is restricted to the super-user. */
extern int sethostname (__const char *__name, size_t __len)
- __THROW __nonnull ((1));
+ __THROW __nonnull ((1)) __wur;
/* Set the current machine's Internet number to ID.
This call is restricted to the super-user. */
-extern int sethostid (long int __id) __THROW;
+extern int sethostid (long int __id) __THROW __wur;
/* Get and set the NIS (aka YP) domain name, if any.
Called just like `gethostname' and `sethostname'.
The NIS domain name is usually the empty string when not using NIS. */
extern int getdomainname (char *__name, size_t __len)
- __THROW __nonnull ((1));
+ __THROW __nonnull ((1)) __wur;
extern int setdomainname (__const char *__name, size_t __len)
- __THROW __nonnull ((1));
+ __THROW __nonnull ((1)) __wur;
/* Revoke access permissions to all processes currently communicating
@@ -818,7 +872,7 @@ extern int setdomainname (__const char *__name, size_t __len)
extern int vhangup (void) __THROW;
/* Revoke the access of all descriptors currently open on FILE. */
-extern int revoke (__const char *__file) __THROW __nonnull ((1));
+extern int revoke (__const char *__file) __THROW __nonnull ((1)) __wur;
/* Enable statistical profiling, writing samples of the PC into at most
@@ -834,7 +888,7 @@ extern int profil (unsigned short int *__sample_buffer, size_t __size,
/* Turn accounting on if NAME is an existing file. The system will then write
a record for each process as it terminates, to this file. If NAME is NULL,
turn accounting off. This call is restricted to the super-user. */
-extern int acct (__const char *__name) __THROW __nonnull ((1));
+extern int acct (__const char *__name) __THROW;
/* Successive calls return the shells listed in `/etc/shells'. */
@@ -846,14 +900,14 @@ extern void setusershell (void) __THROW; /* Rewind and re-read the file. */
/* Put the program in the background, and dissociate from the controlling
terminal. If NOCHDIR is zero, do `chdir ("/")'. If NOCLOSE is zero,
redirects stdin, stdout, and stderr to /dev/null. */
-extern int daemon (int __nochdir, int __noclose) __THROW;
+extern int daemon (int __nochdir, int __noclose) __THROW __wur;
#endif /* Use BSD || X/Open. */
#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
/* Make PATH be the root directory (the starting point for absolute paths).
This call is restricted to the super-user. */
-extern int chroot (__const char *__path) __THROW __nonnull ((1));
+extern int chroot (__const char *__path) __THROW __nonnull ((1)) __wur;
/* Prompt with PROMPT and read a string from the terminal without echoing.
Uses /dev/tty if possible; otherwise stderr and stdin. */
@@ -884,52 +938,56 @@ extern void sync (void) __THROW;
extern int getpagesize (void) __THROW __attribute__ ((__const__));
+/* Return the maximum number of file descriptors
+ the current process could possibly have. */
+extern int getdtablesize (void) __THROW;
+
+
/* Truncate FILE to LENGTH bytes. */
# ifndef __USE_FILE_OFFSET64
extern int truncate (__const char *__file, __off_t __length)
- __THROW __nonnull ((1));
+ __THROW __nonnull ((1)) __wur;
# else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (truncate,
(__const char *__file, __off64_t __length),
- truncate64) __nonnull ((1));
+ truncate64) __nonnull ((1)) __wur;
# else
# define truncate truncate64
# endif
# endif
# ifdef __USE_LARGEFILE64
extern int truncate64 (__const char *__file, __off64_t __length)
- __THROW __nonnull ((1));
+ __THROW __nonnull ((1)) __wur;
# endif
+#endif /* Use BSD || X/Open Unix. */
+
+#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
+
/* Truncate the file FD is open on to LENGTH bytes. */
# ifndef __USE_FILE_OFFSET64
-extern int ftruncate (int __fd, __off_t __length) __THROW;
+extern int ftruncate (int __fd, __off_t __length) __THROW __wur;
# else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (ftruncate, (int __fd, __off64_t __length),
- ftruncate64);
+ ftruncate64) __wur;
# else
# define ftruncate ftruncate64
# endif
# endif
# ifdef __USE_LARGEFILE64
-extern int ftruncate64 (int __fd, __off64_t __length) __THROW;
+extern int ftruncate64 (int __fd, __off64_t __length) __THROW __wur;
# endif
-
-/* Return the maximum number of file descriptors
- the current process could possibly have. */
-extern int getdtablesize (void) __THROW;
-
-#endif /* Use BSD || X/Open Unix. */
+#endif /* Use BSD || X/Open Unix || POSIX 2003. */
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
/* Set the end of accessible data space (aka "the break") to ADDR.
Returns zero on success and -1 for errors (with errno set). */
-extern int brk (void *__addr) __THROW;
+extern int brk (void *__addr) __THROW __wur;
/* Increase or decrease the end of accessible data space by DELTA bytes.
If successful, returns the address the previous end of data space
@@ -973,17 +1031,17 @@ extern long int syscall (long int __sysno, ...) __THROW;
# define F_TEST 3 /* Test a region for other processes locks. */
# ifndef __USE_FILE_OFFSET64
-extern int lockf (int __fd, int __cmd, __off_t __len);
+extern int lockf (int __fd, int __cmd, __off_t __len) __wur;
# else
# ifdef __REDIRECT
extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len),
- lockf64);
+ lockf64) __wur;
# else
# define lockf lockf64
# endif
# endif
# ifdef __USE_LARGEFILE64
-extern int lockf64 (int __fd, int __cmd, __off64_t __len);
+extern int lockf64 (int __fd, int __cmd, __off64_t __len) __wur;
# endif
#endif /* Use misc and F_LOCK not already defined. */
@@ -1004,7 +1062,7 @@ extern int lockf64 (int __fd, int __cmd, __off64_t __len);
#if defined __USE_POSIX199309 || defined __USE_UNIX98
/* Synchronize at least the data part of a file with the underlying
media. */
-extern int fdatasync (int __fildes) __THROW;
+extern int fdatasync (int __fildes);
#endif /* Use POSIX199309 */
@@ -1033,7 +1091,13 @@ extern void swab (__const void *__restrict __from, void *__restrict __to,
It is also found in <stdio.h>. */
#ifdef __USE_XOPEN
/* Return the name of the controlling terminal. */
-extern char *ctermid (char *__s) __THROW __nonnull ((1));
+extern char *ctermid (char *__s) __THROW;
+#endif
+
+
+/* Define some macros helping to catch buffer overflows. */
+#if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus
+# include <bits/unistd.h>
#endif
__END_DECLS