Subversion Repositories Kolibri OS

Rev

Rev 4921 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #include <sys/types.h>
  2. #include <errno.h>
  3. #include <sys/kos_io.h>
  4.  
  5. int write_file(const char *path,const void *buff,
  6.                size_t offset, size_t count, size_t *writes)
  7. {
  8.     int retval;
  9.     __asm__ __volatile__(
  10.     "pushl $0 \n\t"
  11.     "pushl $0 \n\t"
  12.     "movl %%eax, 1(%%esp) \n\t"
  13.     "pushl %%ebx \n\t"
  14.     "pushl %%edx \n\t"
  15.     "pushl $0 \n\t"
  16.     "pushl %%ecx \n\t"
  17.     "pushl $3 \n\t"
  18.     "movl %%esp, %%ebx \n\t"
  19.     "mov $70, %%eax \n\t"
  20.     "int $0x40 \n\t"
  21.     "testl %%esi, %%esi \n\t"
  22.     "jz 1f \n\t"
  23.     "movl %%ebx, (%%esi) \n\t"
  24. "1:"
  25.     "addl $28, %%esp \n\t"
  26.     :"=a" (retval)
  27.     :"a"(path),"b"(buff),"c"(offset),"d"(count),"S"(writes));
  28.     if(retval == 0)
  29.         return 0;
  30.     else if (retval == 8)
  31.         return ENOSPC;
  32.     return -1;
  33. };
  34.