X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fchdir-long.c;h=3fc7ef2a841831edc83f6bf1842b31456093dbc1;hb=2354d5ead305b61c925e53bcfb73d47de7c53162;hp=a727817251394544404218f63b3c4b65d8b2e206;hpb=222b0486b7db1b09293e05512873d633440efcb3;p=gnulib.git diff --git a/lib/chdir-long.c b/lib/chdir-long.c index a72781725..3fc7ef2a8 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, 2007 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 @@ -17,28 +17,20 @@ /* written by Jim Meyering */ -#ifdef HAVE_CONFIG_H -# include -#endif +#include #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 @@ -77,13 +69,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; @@ -271,6 +260,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 libcoreutils.a" +compile-command: "gcc -DTEST_CHDIR=1 -g -O -W -Wall chdir-long.c libcoreutils.a" End: */