The File System Extensions are a part of the lowest level of I/O operations in the C runtime library of DJGPP. These extensions are provided to allow for cases where Unix uses a file descriptor to access such items as serial ports, memory, and the network, but DOS does not. It allows a set of functions (called an extension) to gain control when one of these low-level functions is called on a file descriptor set up by the extension.
Each extension must provide one or two handler functions. All handler functions take the same arguments:
int function(__FSEXT_Fnumber func_number, int *rv, va_list args);
The func_number identifies which function is to be emulated.
The file <sys/fsext.h>
defines the function numbers as follows:
__FSEXT_nop
__FSEXT_open
__FSEXT_creat
__FSEXT_read
__FSEXT_write
__FSEXT_read
select
library function
(see section select) when it needs to know whether a handle used to
reference the "file" is ready for reading or writing, or has an error
condition set. The handler should return an OR'ed bit mask of the
following bits (defined on <sys/fsext.h>
):
__FSEXT_ready_read
__FSEXT_ready_write
__FSEXT_ready_error
__FSEXT_close
__FSEXT_fcntl
__FSEXT_ioctl
__FSEXT_lseek
__FSEXT_link
__FSEXT_unlink
__FSEXT_dup
__FSEXT_dup2
__FSEXT_fstat
rv points to a temporary return value pointer. If the function is emulated by the handler, the return value should be stored here, and the handler should return a nonzero value. If the handler returns zero, it is assumed to have not emulated the call, and the regular DOS I/O function will happen. The args represent the arguments passed to the original function; these point to the actual arguments on the stack, so the emulation may choose to modify them and return zero to the regular function, which will then act on the modified arguments.
A normal extension would provide these parts:
socket
for networking) or an extension
to open (such as /dev/ttyS0
to access the serial port).
read
and
write
. This is a single function in the extension that uses
the function number parameter to select an extension function.
Please note that the special Unix filenames `/dev/null' and `/dev/tty' are already mapped to the appropriate DOS names `NUL' and `CON', respectively, so you don't need to write extensions for these.
Go to the first, previous, next, last section, table of contents.