Message-ID: <39A146EC.9BCFF04@softhome.net> Date: Mon, 21 Aug 2000 17:12:44 +0200 From: Laurynas Biveinis X-Mailer: Mozilla 4.74 [en] (Win98; U) X-Accept-Language: lt,en MIME-Version: 1.0 To: DJGPP Workers Subject: Patch: symlinks for opendir() Content-Type: text/plain; charset=iso-8859-4 Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Adds symlink support to opendir() company. However, only directory as passed to it is resolved. Directory entries in readdir() are not resolved, as glibc does. Any comments? Laurynas Index: opendir.c =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/posix/dirent/opendir.c,v retrieving revision 1.3 diff -u -r1.3 opendir.c --- opendir.c 1998/11/15 13:48:38 1.3 +++ opendir.c 2000/08/21 15:09:45 @@ -1,8 +1,11 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include +#include +#include #include #include #include @@ -52,7 +55,13 @@ opendir(const char *name) { int length; - DIR *dir = (DIR *)malloc(sizeof(DIR)); + DIR *dir; + char name_copy[FILENAME_MAX + 1]; + + if (!__solve_symlinks(name, name_copy)) + return NULL; + + dir = (DIR *)malloc(sizeof(DIR)); if (dir == 0) return 0; dir->num_read = 0; @@ -68,7 +77,7 @@ dir->flags |= __OPENDIR_PRESERVE_CASE; /* Make absolute path */ - _fixpath(name, dir->name); + _fixpath(name_copy, dir->name); /* Ensure that directory to be accessed exists */ if (access(dir->name, D_OK))