15955282f6
- ensure es = ds = ss upon exit of each C runtime function - clear upper 16 bits of ebx before setting them to 0x0021, when invoking interrupt_ptr to simulate a RM int 0x21 - make _sys_exists use the transfer buffer (which it needs) - make _sys_rawread properly handle an end-of-file read (zero bytes read) - make argument to _sys_seterrno short --- after a failed int 0x21 call, only the lower 16 bits of eax hold the MS-DOs error code - _sys_rawlseek accepts only 3 longword arguments, not 4 (the offset is only 1 longword) - other minor fixes
46 lines
1.2 KiB
C
46 lines
1.2 KiB
C
/* $Source$
|
|
* $State$
|
|
* $Revision$
|
|
*/
|
|
|
|
#include <errno.h>
|
|
|
|
static const signed char err_map[] =
|
|
{
|
|
0, /* 0x00 no error */
|
|
EINVAL, /* 0x01 function number invalid */
|
|
ENOENT, /* 0x02 file not found */
|
|
ENOENT, /* 0x03 path not found */
|
|
EMFILE, /* 0x04 too many open files */
|
|
EACCES, /* 0x05 access denied */
|
|
EBADF, /* 0x06 invalid handle */
|
|
EFAULT, /* 0x07 mem. control block destroyed */
|
|
ENOMEM, /* 0x08 insufficient memory */
|
|
EFAULT, /* 0x09 memory block address invalid */
|
|
E2BIG, /* 0x0A environment invalid */
|
|
ENOEXEC, /* 0x0B format invalid */
|
|
EINVAL, /* 0x0C access code invalid */
|
|
EINVAL, /* 0x0D data invalid */
|
|
ENOEXEC, /* 0x0E (?) fixup overflow */
|
|
ENODEV, /* 0x0F invalid drive */
|
|
EBUSY, /* 0x10 attempt to remove curr. dir. */
|
|
EXDEV, /* 0x11 not same device */
|
|
ENOENT, /* 0x12 no more files */
|
|
EIO, /* 0x13 disk write-protected */
|
|
EIO, /* 0x14 unknown unit */
|
|
ENXIO, /* 0x15 drive not ready */
|
|
};
|
|
|
|
/*
|
|
* Map an MS-DOS 2+ system error code to an `errno' value and store that in
|
|
* `errno'. Return a longword -1.
|
|
*/
|
|
long _sys_seterrno(unsigned short dos_err)
|
|
{
|
|
if (dos_err < sizeof(err_map) / sizeof(err_map[0]))
|
|
errno = err_map[dos_err];
|
|
else
|
|
errno = EIO;
|
|
return -1;
|
|
}
|