Mercurial > hg > octave-lyh > gnulib-hg
changeset 11107:6bf33b64b03d
dirfd: set errno upon failure
* lib/dirfd.c: Include <errno.h>.
Set errno to ENOTSUP when returning -1.
* modules/dirfd (Depends-on): Add errno.
Suggested by John Kodis <kodis@comcast.net>.
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Tue, 03 Feb 2009 07:47:07 +0100 |
parents | 1cc89f3c5e6b |
children | d70f48555eb1 |
files | lib/dirfd.c modules/dirfd |
diffstat | 2 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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 <config.h> #include <dirent.h> +#include <errno.h> 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; }