X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fchdir-long.c;h=8d0f0622288465dad6af1a4947dddb8d0300f93b;hb=70da04bc5da799165778cfe83c2d6a64dcb25b83;hp=4702432a7ddcf943575ecf03b8e6d10adfedb3f2;hpb=018039820ee41e5d8a9a7352ae55bc3eb14bac3c;p=gnulib.git diff --git a/lib/chdir-long.c b/lib/chdir-long.c index 4702432a7..8d0f06222 100644 --- a/lib/chdir-long.c +++ b/lib/chdir-long.c @@ -1,5 +1,5 @@ /* provide a chdir function that tries not to fail due to ENAMETOOLONG - Copyright (C) 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006 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 @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* written by Jim Meyering */ @@ -21,22 +21,17 @@ #include "chdir-long.h" +#include #include #include #include -#include #include #include #include -#include #include "memrchr.h" #include "openat.h" -#ifndef O_DIRECTORY -# define O_DIRECTORY 0 -#endif - #ifndef PATH_MAX # error "compile this file only if your system defines PATH_MAX" #endif @@ -75,13 +70,10 @@ cdb_free (struct cd_buf const *cdb) static int cdb_advance_fd (struct cd_buf *cdb, char const *dir) { - int new_fd = openat (cdb->fd, dir, O_RDONLY | O_DIRECTORY); + int new_fd = openat (cdb->fd, dir, + O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK); if (new_fd < 0) - { - new_fd = openat (cdb->fd, dir, O_WRONLY | O_DIRECTORY); - if (new_fd < 0) - return -1; - } + return -1; cdb_free (cdb); cdb->fd = new_fd; @@ -269,6 +261,6 @@ main (int argc, char *argv[]) /* Local Variables: -compile-command: "gcc -DTEST_CHDIR=1 -DHAVE_CONFIG_H -I.. -g -O -W -Wall chdir-long.c libfetish.a" +compile-command: "gcc -DTEST_CHDIR=1 -g -O -W -Wall chdir-long.c libcoreutils.a" End: */