X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fchdir-long.c;h=291b58c2894723f114b7a5d2e9c35b7d15c239df;hb=31dbe6deb4fe2dbafce6c5243cdb645618417efc;hp=6c8d79f7a84da5aaf65c7225e3a2ffd89056b423;hpb=6528cac57d999d924da1a4fdf64a487361164668;p=gnulib.git diff --git a/lib/chdir-long.c b/lib/chdir-long.c index 6c8d79f7a..291b58c28 100644 --- a/lib/chdir-long.c +++ b/lib/chdir-long.c @@ -1,10 +1,10 @@ /* 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, 2008 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify + 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 - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -12,8 +12,7 @@ GNU General Public License for more details. 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. */ + along with this program. If not, see . */ /* written by Jim Meyering */ @@ -21,21 +20,16 @@ #include "chdir-long.h" +#include #include #include #include -#include #include #include #include -#include #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 @@ -74,13 +68,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; @@ -214,7 +205,6 @@ chdir_long (char *dir) #if TEST_CHDIR -# include # include "closeout.h" # include "error.h" @@ -268,6 +258,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: */