diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/unistd.h | 174 |
1 files changed, 109 insertions, 65 deletions
diff --git a/include/unistd.h b/include/unistd.h index 1ca923130..9ccb0e80f 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1991-2002,2003,2004,2005,2006 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 @@ -255,7 +255,7 @@ typedef __socklen_t socklen_t; /* Test for access to NAME using the real UID and real GID. */ extern int access (__const char *__name, int __type) __THROW __nonnull ((1)); -#if 0 /* def __USE_GNU */ +#if 0 /*def __USE_GNU*/ /* Test for access to NAME using the effective UID and GID (as normal file operations use). */ extern int euidaccess (__const char *__name, int __type) @@ -286,8 +286,8 @@ extern int euidaccess (__const char *__name, int __type) #ifndef __USE_FILE_OFFSET64 extern __off_t lseek (int __fd, __off_t __offset, int __whence) __THROW; #else -# ifdef __REDIRECT -extern __off64_t __REDIRECT (lseek, +# ifdef __REDIRECT_NTH +extern __off64_t __REDIRECT_NTH (lseek, (int __fd, __off64_t __offset, int __whence), lseek64); # else @@ -295,7 +295,8 @@ extern __off64_t __REDIRECT (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 +310,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 +327,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 +335,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 +355,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 +367,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 +417,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. */ +#if 0 /*def __USE_GNU*/ +/* 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 +454,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. @@ -454,16 +463,17 @@ extern char *getcwd (char *__buf, size_t __size) __THROW; extern char *get_current_dir_name (void) __THROW; #endif -#if 0 /* defined __USE_BSD || defined __USE_XOPEN_EXTENDED */ +#if 0 /*defined __USE_BSD || defined __USE_XOPEN_EXTENDED*/ /* 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; @@ -480,7 +490,7 @@ extern char **environ; extern int execve (__const char *__path, char *__const __argv[], char *__const __envp[]) __THROW __nonnull ((1)); -#if 0 /* def __USE_GNU */ +#if 0 /*def __USE_GNU*/ /* Execute the file FD refers to, overlaying the running program image. ARGV and ENVP are passed to the new program, as for `execve'. */ extern int fexecve (int __fd, char *__const __argv[], char *__const __envp[]) @@ -516,7 +526,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 @@ -556,8 +566,8 @@ extern __pid_t getppid (void) __THROW; #ifndef __FAVOR_BSD extern __pid_t getpgrp (void) __THROW; #else -# ifdef __REDIRECT -extern __pid_t __REDIRECT (getpgrp, (__pid_t __pid), __getpgid); +# ifdef __REDIRECT_NTH +extern __pid_t __REDIRECT_NTH (getpgrp, (__pid_t __pid), __getpgid); # else # define getpgrp __getpgid # endif @@ -595,8 +605,8 @@ extern int setpgrp (void) __THROW; # else /* Another name for `setpgid' (above). */ -# ifdef __REDIRECT -extern int __REDIRECT (setpgrp, (__pid_t __pid, __pid_t __pgrp), setpgid); +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (setpgrp, (__pid_t __pid, __pid_t __pgrp), setpgid); # else # define setpgrp setpgid # endif @@ -629,9 +639,9 @@ 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; -#if 0 /* def __USE_GNU */ +#if 0 /*def __USE_GNU*/ /* Return nonzero iff the calling process is in group GID. */ extern int group_member (__gid_t __gid) __THROW; #endif @@ -673,19 +683,23 @@ extern int setegid (__gid_t __gid) __THROW; #ifdef __USE_GNU /* Fetch the effective user ID, real 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 *__euid, __uid_t *__ruid, __uid_t *__suid) + __THROW; /* Fetch the effective group ID, real 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 *__egid, __gid_t *__rgid, __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); +extern int setresuid (__uid_t __euid, __uid_t __ruid, __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); +extern int setresgid (__gid_t __egid, __gid_t __rgid, __gid_t __sgid) + __THROW; #endif @@ -712,14 +726,14 @@ 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. */ extern int isatty (int __fd) __THROW; -#if 0 /* defined __USE_BSD \ - || (defined __USE_XOPEN_EXTENDED && !defined __USE_UNIX98) */ +#if 0 /*defined __USE_BSD \ + || (defined __USE_XOPEN_EXTENDED && !defined __USE_UNIX98)*/ /* Return the index into the active-logins file (utmp) for the controlling terminal. */ extern int ttyslot (void) __THROW; @@ -728,23 +742,47 @@ 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; + +#if 0 /*def __USE_GNU*/ +/* 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) __THROW __nonnull ((2, 4)) __wur; +#endif #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)); + size_t __len) __THROW __nonnull ((1, 2)) __wur; #endif /* Use BSD. */ +#if 0 /*def __USE_GNU*/ +/* 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 int 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)); +#if 0 /*def __USE_GNU*/ +/* 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)); @@ -771,7 +809,7 @@ extern char *getlogin (void); extern int getlogin_r (char *__name, size_t __name_len) __nonnull ((1)); #endif -#if 0 /* def __USE_BSD */ +#if 0 /*def __USE_BSD*/ /* Set the login name returned by `getlogin'. */ extern int setlogin (__const char *__name) __THROW __nonnull ((1)); #endif @@ -798,20 +836,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 @@ -821,7 +859,7 @@ extern int vhangup (void) __THROW; #if 0 /* 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 @@ -838,7 +876,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'. */ @@ -851,7 +889,7 @@ 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 #endif /* Use BSD || X/Open. */ @@ -859,7 +897,7 @@ extern int daemon (int __nochdir, int __noclose) __THROW; #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. */ @@ -898,19 +936,19 @@ 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 -extern int __REDIRECT (truncate, +# 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. */ @@ -919,17 +957,17 @@ extern int truncate64 (__const char *__file, __off64_t __length) /* 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 -extern int __REDIRECT (ftruncate, (int __fd, __off64_t __length), - ftruncate64); +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (ftruncate, (int __fd, __off64_t __length), + 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 #endif /* Use BSD || X/Open Unix || POSIX 2003. */ @@ -939,7 +977,7 @@ extern int ftruncate64 (int __fd, __off64_t __length) __THROW; /* 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 @@ -983,17 +1021,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. */ @@ -1043,7 +1081,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 |