From 108fdd583db2979210c530ee28f4a15af0dbf8e7 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 3 Feb 2009 07:47:07 +0100 Subject: [PATCH] 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 . --- lib/dirfd.c | 8 ++++++-- modules/dirfd | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/dirfd.c b/lib/dirfd.c index 3458e99b2..81993c502 100644 --- 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 index 25450bd6e..42ff4d7a0 100644 --- a/modules/dirfd +++ b/modules/dirfd @@ -7,6 +7,7 @@ m4/dirfd.m4 Depends-on: dirent +errno extensions configure.ac: -- 2.11.0