From: Jim Meyering Date: Tue, 3 Feb 2009 06:47:07 +0000 (+0100) Subject: dirfd: set errno upon failure X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=108fdd583db2979210c530ee28f4a15af0dbf8e7;p=pspp 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 index 3458e99b20..81993c502c 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 25450bd6e4..42ff4d7a0f 100644 --- a/modules/dirfd +++ b/modules/dirfd @@ -7,6 +7,7 @@ m4/dirfd.m4 Depends-on: dirent +errno extensions configure.ac: