[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



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.

-- System Information:
Debian Release: 6.0
  APT prefers unstable
  APT policy: (700, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libc6-dev depends on:
ii  libc-dev-bin                  2.11.2-9   Embedded GNU C Library: Developmen
ii  libc6                         2.11.2-9   Embedded GNU C Library: Shared lib
ii  linux-libc-dev                2.6.32-30  Linux support headers for userspac

Versions of packages libc6-dev recommends:
ii  gcc [c-compiler]              4:4.4.5-2  The GNU C compiler
ii  gcc-4.3 [c-compiler]          4.3.5-4    The GNU C compiler
ii  gcc-4.4 [c-compiler]          4.4.5-10   The GNU C compiler
ii  gcc-4.5 [c-compiler]          4.5.2-1    The GNU C compiler

Versions of packages libc6-dev suggests:
pn  glibc-doc                     <none>     (no description available)
ii  manpages-dev                  3.27-1     Manual pages about using GNU/Linux

-- no debconf information



Reply to: