Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Feb 2012 07:20:05 GMT
From:      Eric Wong <normalperson@yhbt.net>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   standards/164787: dirfd() function not available when _POSIX_C_SOURCE is defined
Message-ID:  <201202050720.q157K569080870@red.freebsd.org>
Resent-Message-ID: <201202050730.q157UADm073763@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         164787
>Category:       standards
>Synopsis:       dirfd() function not available when _POSIX_C_SOURCE is defined
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-standards
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Feb 05 07:30:09 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Eric Wong
>Release:        8.2-RELEASE
>Organization:
>Environment:
FreeBSD f82 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Thu Feb 17 02:41:51 UTC 2011     root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
dirfd(3) is now specified in POSIX.1-2008, so it should be available
when the _POSIX_C_SOURCE macro is defined to >= 200809L

However, /usr/include/dirent.h only exposes the dirfd() macro if
__BSD_VISIBLE is defined.  However, __BSD_VISIBLE appears to be false
if _POSIX_C_SOURCE is defined.

>How-To-Repeat:
/*
 * To build + link:
 *   gcc -o dirfdtest dirfdtest.c
 * having _POSIX_C_SOURCE defined will cause this to fail link
 */
#define _POSIX_C_SOURCE 200809L
#include <dirent.h>
int main(void)
{
        DIR *dir = opendir(".");

        dirfd(dir);

        return 0;
}

>Fix:
It's probably best to add dirfd() as a function to libc, allowing the opacity
of the struct _dir_desc to be preserved.

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202050720.q157K569080870>