Message-ID: <39A673EA.1C62A2F@softhome.net> Date: Fri, 25 Aug 2000 15:26:02 +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 readlink() Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com This patch makes __solve_symlinks() use __internal_readlink instead of readlink(). And readlink() is made to follow symlinks in leading directories. Testsuite still passes. Any comments? Laurynas Index: djgpp/src/libc/compat/unistd/readlink.c =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/compat/unistd/readlink.c,v retrieving revision 1.4 diff -u -p -r1.4 readlink.c --- readlink.c 2000/08/20 15:46:38 1.4 +++ readlink.c 2000/08/25 13:10:33 @@ -3,12 +3,16 @@ #include #include +#include #include #include "xsymlink.h" int readlink(const char * filename, char * buffer, size_t size) { - return __internal_readlink(filename, 0, buffer, size); + char real_name[FILENAME_MAX]; + if (!__solve_dir_symlinks(filename, real_name)) + return -1; + return __internal_readlink(real_name, 0, buffer, size); } Index: djgpp/src/libc/compat/unistd/readlink.txh =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/compat/unistd/readlink.txh,v retrieving revision 1.2 diff -u -p -r1.2 readlink.txh --- readlink.txh 2000/08/17 13:05:18 1.2 +++ readlink.txh 2000/08/25 13:10:33 @@ -11,8 +11,7 @@ int readlink(const char *filename, char MSDOS doesn't support symbolic links but DJGPP emulates them. This function checks if @var{filename} is a DJGPP symlink and the file name that the links points to is copied into buffer, -up to maximum @var{size} characters. Only the last file name -is resolved. +up to maximum @var{size} characters. Portable applications should not assume that @var{buffer} is terminated with @code{'\0'}. Index: djgpp/src/libc/compat/unistd/xsymlink.c =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/compat/unistd/xsymlink.c,v retrieving revision 1.4 diff -u -p -r1.4 xsymlink.c --- xsymlink.c 2000/08/15 18:11:39 1.4 +++ xsymlink.c 2000/08/25 13:10:33 @@ -67,7 +67,7 @@ int __solve_symlinks(const char * __syml or not trivial symlink (in form 'dir/file'). */ do { - bytes_copied = readlink(resolved, fn_buf, FILENAME_MAX); + bytes_copied = __internal_readlink(resolved, 0, fn_buf, FILENAME_MAX); if (bytes_copied != -1) { done_something = 1;