Mail Archives: djgpp-workers/2002/05/29/15:55:33
Hello.
Please find below a patch to build FSEXT-aware code with gcc 3.1.
Most of the breakage is due to the FSEXT functions requiring
a va_list argument, but we're passing in the address of
a parameter instead. I've solved this problem in all cases
apart from ioctl() and fcntl() by creating wrapper functions
with construct a va_list.
There's scope for making the wrapper functions common, e.g. by making
them library functions, e.g. __FSEXT_call_open_handlers2() which has
a variable number of parameters rather than taking a va_list?
ioctl() and fcntl() are hard to fix, because they take
a command parameter and a va_list, but we somehow need to include
the command parameter in the va_list we pass to the FSEXT functions.
Is there any way of inserting a parameter into a va_list. I had
a look at the C99 standard, but there seems to be no way to do.
The approach below with ioctl() is that we have two va_lists -
one including the command parameter, one without. We pass
command+others to the FSEXT. But gcc gives a warning in this case,
because the command parameter is not the last one before '...'.
But perhaps this code is more correct than the current code?
This patch is definitely a prototype.
Thanks, bye, Rich =]
Index: src/libc/ansi/stdio/remove.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/ansi/stdio/remove.c,v
retrieving revision 1.6
diff -p -u -3 -r1.6 remove.c
--- src/libc/ansi/stdio/remove.c 2001/06/09 10:56:23 1.6
+++ src/libc/ansi/stdio/remove.c 2002/05/26 17:27:19
@@ -1,9 +1,11 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1998 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 <libc/stubs.h>
#include <libc/symlink.h>
+#include <stdarg.h>
#include <io.h>
#include <stdio.h>
#include <fcntl.h>
@@ -13,6 +15,19 @@
#include <libc/dosio.h>
#include <sys/fsext.h>
+static int
+fsext_call_open_handlers_wrapper (__FSEXT_Fnumber fnum, int *rv, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, rv);
+ ret = __FSEXT_call_open_handlers(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
+
int
remove(const char *fn)
{
@@ -24,7 +39,7 @@ remove(const char *fn)
int rv;
/* see if a file system extension wants to handle this */
- if (__FSEXT_call_open_handlers(__FSEXT_unlink, &rv, &fn))
+ if (fsext_call_open_handlers_wrapper(__FSEXT_unlink, &rv, fn))
return rv;
/* Handle symlinks */
Index: src/libc/compat/ioctl/ioctl.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/ioctl/ioctl.c,v
retrieving revision 1.5
diff -p -u -3 -r1.5 ioctl.c
--- src/libc/compat/ioctl/ioctl.c 2001/08/09 03:59:13 1.5
+++ src/libc/compat/ioctl/ioctl.c 2002/05/26 17:27:40
@@ -1,3 +1,4 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/*
@@ -257,23 +258,27 @@ static int _dos_ioctl(int fd, int cmd, i
}
-static int _unix_ioctl(int fd, int cmd, va_list args)
+static int _unix_ioctl(int fd, va_list cmd_plus_args)
{
+ int cmd;
+
__FSEXT_Function *func = __FSEXT_get_function(fd);
if(func)
{
int rv;
- if (func(__FSEXT_ioctl,&rv, &fd))
+ if (func(__FSEXT_ioctl, &rv, cmd_plus_args))
return rv;
}
+ cmd = va_arg(cmd_plus_args, int);
+
switch (cmd)
{
case TIOCGWINSZ:
{
struct winsize *win;
- win = va_arg(args, struct winsize *);
+ win = va_arg(cmd_plus_args, struct winsize *);
_farsetsel(_dos_ds);
win->ws_row = _farnspeekb(0x0484) + 1;
@@ -287,7 +292,7 @@ static int _unix_ioctl(int fd, int cmd,
{
struct winsize *win;
- win = va_arg(args, struct winsize *);
+ win = va_arg(cmd_plus_args, struct winsize *);
_farsetsel(_dos_ds);
if (win->ws_row == _farnspeekb(0x484) + 1
@@ -314,15 +319,17 @@ int ioctl(int fd, int cmd, ...)
__FSEXT_Function *func = __FSEXT_get_function(fd);
int rv;
va_list args;
+ va_list cmd_plus_args; /* cmd, args, for feeding to FSEXT */
/**
** see if this is a file system extension file
**
*/
- if (func && func(__FSEXT_ioctl, &rv, &fd))
+ if (func && func(__FSEXT_ioctl, &rv, cmd_plus_args))
return rv;
va_start(args, cmd);
+ va_start(cmd_plus_args, fd);
if(__IS_UNIX_IOCTL(cmd))
{
@@ -342,7 +349,7 @@ int ioctl(int fd, int cmd, ...)
inflg,outflg,voidflg,size);
}
#endif
- return _unix_ioctl(fd, cmd, args);
+ return _unix_ioctl(fd, cmd_plus_args);
}
/* Handle a DOS request */
/* extract arguments */
@@ -354,6 +361,8 @@ int ioctl(int fd, int cmd, ...)
if (narg > 1) argdi = va_arg(args,int);
if (narg > 2) argsi = va_arg(args,int);
if (cmd & DOS_BRAINDEAD) xarg = va_arg(args,int);
+
+ va_end(cmd_plus_args);
va_end(args);
return _dos_ioctl(fd,cmd,argcx,argdx,argsi,argdi,xarg);
Index: src/libc/compat/time/select.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/time/select.c,v
retrieving revision 1.5
diff -p -u -3 -r1.5 select.c
--- src/libc/compat/time/select.c 2001/03/31 10:33:42 1.5
+++ src/libc/compat/time/select.c 2002/05/26 17:27:41
@@ -1,3 +1,4 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2001 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 */
@@ -116,6 +117,19 @@ fd_input_ready(int fd)
return regs.h.al == 0xff;
}
+static int
+fsext_func_wrapper (__FSEXT_Function *func, __FSEXT_Fnumber fnum, int *rv, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, rv);
+ ret = func(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
+
int
select(int nfds,
fd_set *readfds,
@@ -165,7 +179,7 @@ select(int nfds,
int fsext_ready = -1;
if (func)
- func(__FSEXT_ready, &fsext_ready, &i);
+ fsext_func_wrapper(func, __FSEXT_ready, &fsext_ready, i);
if (readfds && FD_ISSET (i, readfds))
{
Index: src/libc/compat/unistd/_irdlink.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/unistd/_irdlink.c,v
retrieving revision 1.4
diff -p -u -3 -r1.4 _irdlink.c
--- src/libc/compat/unistd/_irdlink.c 2002/01/09 22:00:10 1.4
+++ src/libc/compat/unistd/_irdlink.c 2002/05/26 17:27:46
@@ -1,3 +1,4 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
@@ -8,6 +9,7 @@
#include <errno.h>
#include <fcntl.h>
#include <io.h>
+#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
@@ -15,6 +17,32 @@
#include "xsymlink.h"
+static int
+fsext_call_open_handlers_wrapper (__FSEXT_Fnumber fnum, int *rv, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, rv);
+ ret = __FSEXT_call_open_handlers(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
+
+static int
+fsext_func_wrapper (__FSEXT_Function *func, __FSEXT_Fnumber fnum, int *rv, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, rv);
+ ret = func(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
+
int __internal_readlink(const char * __path, int __fhandle, char * __buf,
size_t __max)
{
@@ -37,7 +65,8 @@ int __internal_readlink(const char * __p
if (__path)
{
struct ffblk file_info;
- if (__FSEXT_call_open_handlers(__FSEXT_readlink, &ret, &__path))
+ if (fsext_call_open_handlers_wrapper(__FSEXT_readlink, &ret,
+ __path, __buf, __max))
return ret;
/* We will check if file exists by the way */
if (findfirst(__path, &file_info, 0))
@@ -53,7 +82,7 @@ int __internal_readlink(const char * __p
if (func)
{
int rv;
- if (func(__FSEXT_readlink, &rv, &__path))
+ if (fsext_func_wrapper(func, __FSEXT_readlink, &rv, __path))
return rv;
}
file_size = filelength(__fhandle);
Index: src/libc/compat/unistd/fchown.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/unistd/fchown.c,v
retrieving revision 1.1
diff -p -u -3 -r1.1 fchown.c
--- src/libc/compat/unistd/fchown.c 2002/04/13 07:43:29 1.1
+++ src/libc/compat/unistd/fchown.c 2002/05/26 17:27:47
@@ -1,8 +1,22 @@
/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
#include <libc/stubs.h>
+#include <stdarg.h>
#include <sys/fsext.h>
#include <io.h>
#include <unistd.h>
+
+static int
+fsext_func_wrapper (__FSEXT_Function *func, __FSEXT_Fnumber fnum, int *rv, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, rv);
+ ret = func(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
/* MS-DOS couldn't care less about file ownerships, so we
at least check if given handle is valid. */
@@ -13,7 +27,7 @@ int fchown(int fd, uid_t owner, gid_t gr
if (func)
{
int rv;
- if (func(__FSEXT_fchown, &rv, &fd))
+ if (fsext_func_wrapper(func, __FSEXT_fchown, &rv, fd, owner, group))
return rv;
}
return (_get_dev_info(fd) == -1) ? 1 : 0;
Index: src/libc/compat/unistd/llseek.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/unistd/llseek.c,v
retrieving revision 1.5
diff -p -u -3 -r1.5 llseek.c
--- src/libc/compat/unistd/llseek.c 2001/10/14 20:50:16 1.5
+++ src/libc/compat/unistd/llseek.c 2002/05/26 17:27:53
@@ -1,3 +1,4 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
/*
* File llseek.c.
@@ -10,6 +11,7 @@
*/
#include <libc/stubs.h>
+#include <stdarg.h>
#include <unistd.h>
#include <dpmi.h>
#include <errno.h>
@@ -17,6 +19,19 @@
#include <sys/fsext.h>
#include <libc/fd_props.h>
+static int
+fsext_func_wrapper (__FSEXT_Function *func, __FSEXT_Fnumber fnum, int *rv, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, rv);
+ ret = func(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
+
offset_t
llseek( int handle, offset_t offset, int whence )
{
@@ -27,7 +42,7 @@ llseek( int handle, offset_t offset, int
if( func )
{
int rv;
- if( func(__FSEXT_llseek, &rv, &handle) )
+ if( fsext_func_wrapper(func, __FSEXT_llseek, &rv, handle, offset, whence) )
{
return rv;
}
Index: src/libc/compat/unistd/symlink.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/unistd/symlink.c,v
retrieving revision 1.3
diff -p -u -3 -r1.3 symlink.c
--- src/libc/compat/unistd/symlink.c 2001/05/11 17:52:27 1.3
+++ src/libc/compat/unistd/symlink.c 2002/05/26 17:27:53
@@ -1,9 +1,11 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
#include <libc/stubs.h>
#include <libc/symlink.h>
#include <sys/fsext.h>
+#include <stdarg.h>
#include <errno.h>
#include <unistd.h>
#include <io.h>
@@ -12,6 +14,19 @@
#include "xsymlink.h"
+static int
+fsext_call_open_handlers_wrapper (__FSEXT_Fnumber fnum, int *rv, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, rv);
+ ret = __FSEXT_call_open_handlers(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
+
/* Emulate symlinks for all files */
int symlink(const char *source, const char *dest)
{
@@ -33,7 +48,7 @@ int symlink(const char *source, const ch
}
/* Provide ability to hook symlink support */
- if (__FSEXT_call_open_handlers(__FSEXT_symlink, &ret, &source))
+ if (fsext_call_open_handlers_wrapper(__FSEXT_symlink, &ret, source, dest))
return ret;
Index: src/libc/dos/io/_close.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/io/_close.c,v
retrieving revision 1.3
diff -p -u -3 -r1.3 _close.c
--- src/libc/dos/io/_close.c 2001/03/07 05:40:27 1.3
+++ src/libc/dos/io/_close.c 2002/05/26 17:27:58
@@ -1,5 +1,7 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+#include <stdarg.h>
#include <unistd.h>
#include <errno.h>
#include <go32.h>
@@ -10,6 +12,19 @@
#include <libc/dosio.h>
#include <libc/fd_props.h>
+static int
+fsext_func_wrapper (__FSEXT_Function *func, __FSEXT_Fnumber fnum, int *rv, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, rv);
+ ret = func(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
+
int
_close(int handle)
{
@@ -19,7 +34,7 @@ _close(int handle)
if (func)
{
int rv;
- if (func(__FSEXT_close, &rv, &handle))
+ if (fsext_func_wrapper(func, __FSEXT_close, &rv, handle))
{
/* So that we don't try to use it later!
The extension *should* do this itself! */
Index: src/libc/dos/io/_creat.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/io/_creat.c,v
retrieving revision 1.11
diff -p -u -3 -r1.11 _creat.c
--- src/libc/dos/io/_creat.c 2001/09/25 00:48:55 1.11
+++ src/libc/dos/io/_creat.c 2002/05/26 17:27:59
@@ -1,7 +1,9 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2001 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 <libc/stubs.h>
+#include <stdarg.h>
#include <fcntl.h>
#include <errno.h>
#include <go32.h>
@@ -12,6 +14,19 @@
#include <libc/dosio.h>
#include <sys/fsext.h>
+static int
+fsext_call_open_handlers_wrapper (__FSEXT_Fnumber fnum, int *rv, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, rv);
+ ret = __FSEXT_call_open_handlers(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
+
int
_creat(const char* filename, int attrib)
{
@@ -25,7 +40,7 @@ _creat(const char* filename, int attrib)
return -1;
}
- if (__FSEXT_call_open_handlers(__FSEXT_creat, &rv, &filename))
+ if (fsext_call_open_handlers_wrapper(__FSEXT_creat, &rv, filename, attrib))
return rv;
if(use_lfn) {
Index: src/libc/dos/io/_creat_n.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/io/_creat_n.c,v
retrieving revision 1.7
diff -p -u -3 -r1.7 _creat_n.c
--- src/libc/dos/io/_creat_n.c 2001/09/25 00:48:55 1.7
+++ src/libc/dos/io/_creat_n.c 2002/05/26 17:28:04
@@ -1,6 +1,8 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
#include <libc/stubs.h>
+#include <stdarg.h>
#include <fcntl.h>
#include <errno.h>
#include <go32.h>
@@ -11,6 +13,19 @@
#include <libc/dosio.h>
#include <sys/fsext.h>
+static int
+fsext_call_open_handlers_wrapper (__FSEXT_Fnumber fnum, int *rv, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, rv);
+ ret = __FSEXT_call_open_handlers(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
+
int
_creatnew(const char* filename, int attrib, int flags)
{
@@ -24,7 +39,8 @@ _creatnew(const char* filename, int attr
return -1;
}
- if (__FSEXT_call_open_handlers(__FSEXT_creat, &rv, &filename))
+ if (fsext_call_open_handlers_wrapper(__FSEXT_creat, &rv,
+ filename, attrib, flags))
return rv;
_put_path(filename);
Index: src/libc/dos/io/_open.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/io/_open.c,v
retrieving revision 1.8
diff -p -u -3 -r1.8 _open.c
--- src/libc/dos/io/_open.c 2001/09/25 00:48:55 1.8
+++ src/libc/dos/io/_open.c 2002/05/26 17:28:04
@@ -1,7 +1,9 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2001 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 <libc/stubs.h>
+#include <stdarg.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
@@ -12,6 +14,19 @@
#include <libc/dosio.h>
#include <sys/fsext.h>
+static int
+fsext_call_open_handlers_wrapper (__FSEXT_Fnumber fnum, int *rv, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, rv);
+ ret = __FSEXT_call_open_handlers(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
+
int
_open(const char* filename, int oflag)
{
@@ -25,7 +40,7 @@ _open(const char* filename, int oflag)
return -1;
}
- if (__FSEXT_call_open_handlers(__FSEXT_open, &rv, &filename))
+ if (fsext_call_open_handlers_wrapper(__FSEXT_open, &rv, filename, oflag))
return rv;
if(use_lfn && _os_trueversion == 0x532) {
Index: src/libc/dos/io/_read.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/io/_read.c,v
retrieving revision 1.1
diff -p -u -3 -r1.1 _read.c
--- src/libc/dos/io/_read.c 1995/11/25 21:48:30 1.1
+++ src/libc/dos/io/_read.c 2002/05/26 17:28:11
@@ -1,5 +1,7 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <libc/stubs.h>
+#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
@@ -10,6 +12,19 @@
#include <libc/dosio.h>
+static int
+fsext_func_wrapper (__FSEXT_Function *func, __FSEXT_Fnumber fnum, int *rv, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, rv);
+ ret = func(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
+
int
_read(int handle, void* buffer, size_t count)
{
@@ -22,7 +37,7 @@ _read(int handle, void* buffer, size_t c
if (func)
{
int rv;
- if (func(__FSEXT_read, &rv, &handle))
+ if (fsext_func_wrapper(func, __FSEXT_read, &rv, handle, buffer, count))
return rv;
}
Index: src/libc/dos/io/_write.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/io/_write.c,v
retrieving revision 1.7
diff -p -u -3 -r1.7 _write.c
--- src/libc/dos/io/_write.c 2001/05/19 18:31:35 1.7
+++ src/libc/dos/io/_write.c 2002/05/26 17:28:12
@@ -1,6 +1,8 @@
+/* Copyright (C) 2002 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 <libc/stubs.h>
+#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
@@ -14,6 +16,18 @@
#include <libc/farptrgs.h>
#include <libc/getdinfo.h>
+static int
+fsext_func_wrapper (__FSEXT_Function *func, __FSEXT_Fnumber fnum, int *rv, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, rv);
+ ret = func(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
int
_write(int handle, const void* buffer, size_t count)
@@ -22,7 +36,7 @@ _write(int handle, const void* buffer, s
if (func)
{
int rv;
- if (func(__FSEXT_write, &rv, &handle))
+ if (fsext_func_wrapper(func, __FSEXT_write, &rv, handle, buffer, count))
return rv;
}
Index: src/libc/posix/sys/stat/fstat.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/fstat.c,v
retrieving revision 1.8
diff -p -u -3 -r1.8 fstat.c
--- src/libc/posix/sys/stat/fstat.c 2001/12/01 20:22:37 1.8
+++ src/libc/posix/sys/stat/fstat.c 2002/05/26 17:28:30
@@ -1,3 +1,4 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
@@ -95,6 +96,7 @@
*/
#include <libc/stubs.h>
+#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
@@ -881,6 +883,19 @@ fstat_assist(int fhandle, struct stat *s
return -1;
}
+static int
+fsext_func_wrapper (__FSEXT_Function *func, __FSEXT_Fnumber fnum, int *rv, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, rv);
+ ret = func(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
+
/*
* Main entry point. This is a substitute for library fstat() function.
*/
@@ -900,7 +915,7 @@ fstat(int handle, struct stat *statbuf)
/* see if this is file system extension file */
func = __FSEXT_get_function(handle);
- if (func && func(__FSEXT_fstat, &rv, &handle))
+ if (func && fsext_func_wrapper(func, __FSEXT_fstat, &rv, handle, statbuf))
{
return rv;
}
Index: src/libc/posix/sys/stat/lstat.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/lstat.c,v
retrieving revision 1.11
diff -p -u -3 -r1.11 lstat.c
--- src/libc/posix/sys/stat/lstat.c 2002/01/16 04:25:15 1.11
+++ src/libc/posix/sys/stat/lstat.c 2002/05/26 17:28:35
@@ -1,3 +1,4 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
@@ -892,12 +893,18 @@ stat_assist(const char *path, struct sta
/* A wrapper around __FSEXT_call_open_handlers(), to provide its
* arguments properly.
*/
-static int fsext_wrapper(int * ret, const char * path,
- struct stat * statbuf __attribute__((unused)))
+static int
+fsext_call_open_handlers_wrapper (__FSEXT_Fnumber fnum, int *rv, ...)
{
- return __FSEXT_call_open_handlers(__FSEXT_stat, ret, &path);
-}
+ va_list args;
+ int ret;
+ va_start(args, rv);
+ ret = __FSEXT_call_open_handlers(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
/* Main entry point. This is library lstat() function.
*/
@@ -934,7 +941,7 @@ lstat(const char *path, struct stat *sta
return -1;
}
- if (fsext_wrapper(&ret, real_path, statbuf))
+ if (fsext_call_open_handlers_wrapper(__FSEXT_stat, &ret, real_path, statbuf))
return ret;
if (stat_assist(real_path, statbuf) == -1)
Index: src/libc/posix/unistd/link.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/unistd/link.c,v
retrieving revision 1.2
diff -p -u -3 -r1.2 link.c
--- src/libc/posix/unistd/link.c 1998/06/28 17:27:32 1.2
+++ src/libc/posix/unistd/link.c 2002/05/26 17:28:40
@@ -1,6 +1,8 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <libc/stubs.h>
+#include <stdarg.h>
#include <sys/stat.h> /* For stat() */
#include <fcntl.h> /* For O_RDONLY, etc. */
#include <unistd.h> /* For read(), write(), etc. */
@@ -9,6 +11,19 @@
#include <errno.h> /* For errno */
#include <sys/fsext.h>
+static int
+fsext_call_open_handlers_wrapper (__FSEXT_Fnumber fnum, int *rv, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, rv);
+ ret = __FSEXT_call_open_handlers(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
+
/* Of course, DOS can't really do a link. We just do a copy instead,
which is as close as DOS gets. Alternatively, we could always fail
and return -1. I think this is slightly better. */
@@ -33,7 +48,7 @@ link(const char *path1, const char *path
}
/* see if a file system extension implements the link */
- if (__FSEXT_call_open_handlers(__FSEXT_link, &rv, &path1))
+ if (fsext_call_open_handlers_wrapper(__FSEXT_link, &rv, path1, path2))
return rv;
/* Fail if path1 does not exist - stat() will set errno */
Index: src/libc/posix/unistd/lseek.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/unistd/lseek.c,v
retrieving revision 1.5
diff -p -u -3 -r1.5 lseek.c
--- src/libc/posix/unistd/lseek.c 2001/10/14 20:50:16 1.5
+++ src/libc/posix/unistd/lseek.c 2002/05/26 17:28:46
@@ -1,7 +1,9 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <libc/stubs.h>
+#include <stdarg.h>
#include <unistd.h>
#include <errno.h>
#include <go32.h>
@@ -10,6 +12,19 @@
#include <libc/dosio.h>
#include <libc/fd_props.h>
+static int
+fsext_func_wrapper (__FSEXT_Function *func, __FSEXT_Fnumber fnum, int *rv, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, rv);
+ ret = func(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
+
off_t
lseek(int handle, off_t offset, int whence)
{
@@ -20,7 +35,7 @@ lseek(int handle, off_t offset, int when
if (func)
{
int rv;
- if (func(__FSEXT_lseek, &rv, &handle))
+ if (fsext_func_wrapper(func, __FSEXT_lseek, &rv, handle, offset, whence))
return rv;
}
Index: src/libc/posix/unistd/write.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/unistd/write.c,v
retrieving revision 1.7
diff -p -u -3 -r1.7 write.c
--- src/libc/posix/unistd/write.c 2001/06/09 20:49:46 1.7
+++ src/libc/posix/unistd/write.c 2002/05/26 17:28:46
@@ -1,8 +1,10 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2001 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 <libc/stubs.h>
+#include <stdarg.h>
#include <unistd.h>
#include <fcntl.h>
#include <go32.h>
@@ -17,9 +19,23 @@
#define tblen _go32_info_block.size_of_transfer_buffer
+
int (*__libc_write_termios_hook)(int handle, const void *buffer, size_t count,
ssize_t *rv) = NULL;
+static int
+fsext_func_wrapper (__FSEXT_Function *func, __FSEXT_Fnumber fnum, int *rv, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, rv);
+ ret = func(fnum, rv, args);
+ va_end(args);
+
+ return(ret);
+}
+
ssize_t
write(int handle, const void* buffer, size_t count)
{
@@ -52,9 +68,10 @@ write(int handle, const void* buffer, si
return _write(handle, buf, count);
/* Let's handle FSEXT_write ! */
- if(func && /* if handler is installed, ...*/
- func(__FSEXT_write, &rv, &handle)) /* ... call extension ... */
- return rv; /* ... and exit if handled. */
+ /* if handler is installed, call extension and exit if handled. */
+ if(func &&
+ fsext_func_wrapper(func, __FSEXT_write, &rv, handle, buffer, count))
+ return rv;
if (__has_fd_properties(handle)
&& (__fd_properties[handle]->flags & FILE_DESC_ZERO_FILL_EOF_GAP))
- Raw text -