Message-ID: <399AD0D0.18181645@softhome.net> Date: Wed, 16 Aug 2000 19:35:12 +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: FSEXT for symlink() and readlink() Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com OK, here it goes. Any comments? Laurynas Index: djgpp/include/sys/fsext.h =================================================================== RCS file: /cvs/djgpp/djgpp/include/sys/fsext.h,v retrieving revision 1.4 diff -u -r1.4 fsext.h --- fsext.h 2000/06/19 18:00:55 1.4 +++ fsext.h 2000/08/16 17:34:47 @@ -32,7 +32,9 @@ __FSEXT_dup2, __FSEXT_fstat, __FSEXT_stat, - __FSEXT_llseek + __FSEXT_llseek, + __FSEXT_readlink, + __FSEXT_symlink } __FSEXT_Fnumber; /* _ready gets passed a fd and should return a mask of these, Index: djgpp/src/libc/compat/unistd/readlink.c =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/compat/unistd/readlink.c,v retrieving revision 1.2 diff -u -r1.2 readlink.c --- readlink.c 2000/08/16 12:31:28 1.2 +++ readlink.c 2000/08/16 17:34:58 @@ -2,6 +2,7 @@ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ #include +#include #include #include #include @@ -20,6 +21,7 @@ char * data_buf; int fd; struct ffblk file_info; + int ret; /* Reject NULLs */ if (!filename || !buffer) @@ -27,6 +29,10 @@ errno = EINVAL; return -1; } + + /* Provide ability to hook symlink support */ + if (__FSEXT_call_open_handlers(__FSEXT_readlink, &ret, &filename)) + return ret; /* Does symlink file exist at all? */ if (findfirst(filename, &file_info, 0)) Index: djgpp/src/libc/compat/unistd/symlink.c =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/compat/unistd/symlink.c,v retrieving revision 1.1 diff -u -r1.1 symlink.c --- symlink.c 2000/08/14 08:51:30 1.1 +++ symlink.c 2000/08/16 17:34:59 @@ -3,6 +3,7 @@ /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ #include #include +#include #include #include #include @@ -13,8 +14,9 @@ /* Emulate symlinks for all files */ int symlink(const char *source, const char *dest) { - int symlink_file; - char real_dest[FILENAME_MAX]; + int symlink_file; + char real_dest[FILENAME_MAX]; + int ret; static char fill_buf[_SYMLINK_FILE_LEN + 1] = "This is just a text to force symlink file to " "be 510 bytes long. Do not delete it nor spaces " @@ -28,6 +30,11 @@ errno = EINVAL; return -1; } + + /* Provide ability to hook symlink support */ + if (__FSEXT_call_open_handlers(__FSEXT_symlink, &ret, &source)) + return ret; + /* The ``dest'' may have symlinks somewhere in the path itself. */ if (!__solve_symlinks(dest, real_dest)) Index: djgpp/src/libc/fsext/fsext.txh =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/fsext/fsext.txh,v retrieving revision 1.7 diff -u -r1.7 fsext.txh --- fsext.txh 2000/06/19 18:00:56 1.7 +++ fsext.txh 2000/08/16 17:35:12 @@ -28,7 +28,9 @@ @item __FSEXT_open An open handler. This is called just before the library is about to -issue the DOS OpenFile call on behalf of your program. +issue the DOS OpenFile call on behalf of your program. Do not use +this extension to eumalte symlinks. Use @code{__FSEXT_readlink} handler +instead. @item __FSEXT_creat @@ -112,6 +114,16 @@ A file fstat handler (@pxref{fstat}). The extension should fill in various status information about the emulated file. + +@item __FSEXT_readlink + +A file readlink handler (@pxref{readlink}). This extension should be +used to provide support for symlinks in some other than DJGPP format. + +@item __FSEXT_symlink + +A file symlink handler (@pxref{symlink}). This extension should create +symlinks in other than DJGPP symlink file format. @end table