[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fts finds no files under mingw
From: |
Jim Meyering |
Subject: |
Re: fts finds no files under mingw |
Date: |
Wed, 04 Feb 2009 14:49:48 +0100 |
address@hidden wrote:
...
> BTW, it looks like the more Posixly correct action for dirfd to take
> when no file descriptor will ever be available is to set errno to
> ENOTSUP prior to returning -1. Just something to consider.
That would indeed be an improvement.
I'm about to make this change:
I considered whether to distinguish the cases of always returning
-1 (ENOTSUP) and returning some dirent.<MEMBER> whose value happens
to be -1 (EINVAL?), but it didn't seem to be worthwhile.
>From 741ade865eee16193217bf7fa83596409e6091a9 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 3 Feb 2009 07:47:07 +0100
Subject: [PATCH] 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 <address@hidden>.
---
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 3458e99..81993c5 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 <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;
}
diff --git a/modules/dirfd b/modules/dirfd
index 25450bd..42ff4d7 100644
--- a/modules/dirfd
+++ b/modules/dirfd
@@ -7,6 +7,7 @@ m4/dirfd.m4
Depends-on:
dirent
+errno
extensions
configure.ac:
--
1.6.1.2.467.g081e7