# HG changeset patch # User Jim Meyering # Date 1233643627 -3600 # Node ID 6bf33b64b03da0a90f12b66ae0aec5814da0594a # Parent 1cc89f3c5e6bacd8a70f5f35600c5b380655019c dirfd: set errno upon failure * lib/dirfd.c: Include . Set errno to ENOTSUP when returning -1. * modules/dirfd (Depends-on): Add errno. Suggested by John Kodis . diff --git a/lib/dirfd.c b/lib/dirfd.c --- a/lib/dirfd.c +++ b/lib/dirfd.c @@ -1,6 +1,6 @@ /* dirfd.c -- return the file descriptor associated with an open DIR* - Copyright (C) 2001, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2001, 2006, 2008-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,9 +20,13 @@ #include #include +#include int dirfd (DIR const *dir_p) { - return DIR_TO_FD (dir_p); + int fd = DIR_TO_FD (dir_p); + if (fd == -1) + errno = ENOTSUP; + return fd; } diff --git a/modules/dirfd b/modules/dirfd --- a/modules/dirfd +++ b/modules/dirfd @@ -7,6 +7,7 @@ Depends-on: dirent +errno extensions configure.ac: