[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#610824: libc6-dev: POSIX/SUS defines and functions require GNU specific defines



tag 610824 + fixed-upstream
severity 610824 normal
thanks

On Sat, Jan 22, 2011 at 10:26:51PM +0200, Nach wrote:
> Package: libc6-dev
> Version: 2.11.2-9
> Severity: important
> Tags: upstream
> 
> 
> Several standardized defines and functions which are part of POSIX.1-2008/SUSv4 require nonstandard GNU defines in order to function properly.
> I don't know the full range of standardized functions and defines which are affected, but I have found several.
> 
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html
> Specifies that O_DIRECTORY, O_NOFOLLOW, and O_CLOEXEC are part of the standard for open()/openat().
> 
> The manpages incorrectly states regarding some, that they are Linux-specific, when they aren't.
>        O_DIRECTORY
>               If pathname is not a directory, cause the open to fail.  This flag is Linux-specific, and was added in kernel version  2.1.126,  to  avoid
>               denial-of-service  problems  if  opendir(3)  is  called  on a FIFO or tape device, but should not be used outside of the implementation of
>               opendir(3).
> 
> <fcntl.h> ends up wrapping them as follows:
> #ifdef __USE_GNU
> # define O_DIRECT	 040000	/* Direct disk access.	*/
> # define O_DIRECTORY	0200000	/* Must be a directory.	 */
> # define O_NOFOLLOW	0400000	/* Do not follow links.	 */
> # define O_NOATIME     01000000 /* Do not set atime.  */
> # define O_CLOEXEC     02000000 /* Set close_on_exec.  */
> #endif
> 
> 3 out of those 5 should not be wrapped like that.
> 
> I found similar issues with pread() and pwrite().
> The standard http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html states they should be included with <unistd.h>, but they aren't.
> The manpages state that _POSIX_C_SOURCE >= 200809L would include them, but it doesn't seem to help.
> 
> <unistd.h> contains the following:
> #ifdef __USE_UNIX98
> # ifndef __USE_FILE_OFFSET64
> /* Read NBYTES into BUF from FD at the given position OFFSET without
>    changing the file pointer.  Return the number read, -1 for errors
>    or 0 for EOF.
> 
>    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) __wur;
> 
> /* Write N bytes of BUF to FD at the given position OFFSET without
>    changing the file pointer.  Return the number written, or -1.
> 
>    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) __wur;
> 
> 
> 
> Adding -D__USE_UNIX98 when compiling fixes the problem, but that shouldn't be needed.
> 
> This problem seems to be quite widespread. Adding -D_POSIX_C_SOURCE=200809L for example seems to no longer include many functions which should
> be included as part of POSIX.1-2008, such as the *at() functions.
> 

Both issues are fixed in the new upstream version. This new upstream
version will be uploaded shortly after the Squeeze release.

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net



Reply to: