newlib: fixed error handling in write()

git-svn-id: svn://kolibrios.org@6330 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2016-03-13 00:52:58 +00:00
parent f29da4d0ec
commit b141c63200
3 changed files with 30 additions and 23 deletions

View File

@ -40,9 +40,10 @@ int _EXFUN(toascii, (int __c));
#define _B 0200
#ifndef _MB_CAPABLE
_CONST
extern _CONST __IMPORT char *__ctype_ptr__;
#else
extern __IMPORT char *__ctype_ptr__;
#endif
extern __IMPORT char *__ctype_ptr__;
#ifndef __cplusplus
/* These macros are intentionally written in a manner that will trigger

View File

@ -1,28 +1,33 @@
#include <sys/types.h>
#include <errno.h>
#include <sys/kos_io.h>
int write_file(const char *path,const void *buff,
size_t offset, size_t count, size_t *writes)
{
int retval;
__asm__ __volatile__(
"pushl $0 \n\t"
"pushl $0 \n\t"
"movl %%eax, 1(%%esp) \n\t"
"pushl %%ebx \n\t"
"pushl %%edx \n\t"
"pushl $0 \n\t"
"pushl %%ecx \n\t"
"pushl $3 \n\t"
"movl %%esp, %%ebx \n\t"
"mov $70, %%eax \n\t"
"int $0x40 \n\t"
"testl %%esi, %%esi \n\t"
"jz 1f \n\t"
"movl %%ebx, (%%esi) \n\t"
int retval;
__asm__ __volatile__(
"pushl $0 \n\t"
"pushl $0 \n\t"
"movl %%eax, 1(%%esp) \n\t"
"pushl %%ebx \n\t"
"pushl %%edx \n\t"
"pushl $0 \n\t"
"pushl %%ecx \n\t"
"pushl $3 \n\t"
"movl %%esp, %%ebx \n\t"
"mov $70, %%eax \n\t"
"int $0x40 \n\t"
"testl %%esi, %%esi \n\t"
"jz 1f \n\t"
"movl %%ebx, (%%esi) \n\t"
"1:"
"addl $28, %%esp \n\t"
:"=a" (retval)
:"a"(path),"b"(buff),"c"(offset),"d"(count),"S"(writes));
return retval;
"addl $28, %%esp \n\t"
:"=a" (retval)
:"a"(path),"b"(buff),"c"(offset),"d"(count),"S"(writes));
if(retval == 0)
return 0;
else if (retval == 8)
return ENOSPC;
return -1;
};

View File

@ -86,9 +86,10 @@ static int os_write(int handle, const void *buffer, unsigned len, unsigned *amt
ioh->offset+= *amt;
if( *amt != len )
if( *amt && *amt != len )
{
rc = ENOSPC;
errno = rc;
}
return( rc );