Message-ID: <39A43754.B5EA8EF9@softhome.net> Date: Wed, 23 Aug 2000 22:43:00 +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 in lstat() Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Again the same. Together with patched rename() make 'mv' play nicely. Any comments? Laurynas Index: lstat.c =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/lstat.c,v retrieving revision 1.2 diff -p -u -r1.2 lstat.c --- lstat.c 2000/08/15 17:38:40 1.2 +++ lstat.c 2000/08/23 20:36:43 @@ -118,6 +118,7 @@ #include #include #include +#include #include "xstat.h" @@ -879,6 +880,7 @@ lstat(const char *path, struct stat *sta { int e = errno; int pathlen, ret; + char real_path[FILENAME_MAX]; if (!path || !statbuf) { @@ -892,19 +894,23 @@ lstat(const char *path, struct stat *sta return -1; } + /* Handle symlinks */ + if (!__solve_dir_symlinks(path, real_path)) + return -1; + /* Fail if PATH includes wildcard characters supported by FindFirst, or if it is empty. */ - if (memchr(path, '*', pathlen) || memchr(path, '?', pathlen) - || path[0] == '\0') + if (memchr(real_path, '*', pathlen) || memchr(real_path, '?', pathlen) + || real_path[0] == '\0') { errno = ENOENT; /* since no such filename is possible */ return -1; } - if (__FSEXT_call_open_handlers(__FSEXT_stat, &ret, &path)) + if (__FSEXT_call_open_handlers(__FSEXT_stat, &ret, &real_path)) return ret; - if (stat_assist(path, statbuf) == -1) + if (stat_assist(real_path, statbuf) == -1) { return -1; /* errno set by stat_assist() */ }