vfs: semihost driver bugfix

This commit is contained in:
Andrei Gramakov 2020-04-08 15:41:12 +02:00
parent ef47839628
commit 283026a761
2 changed files with 3 additions and 3 deletions

View file

@ -223,7 +223,7 @@ static ssize_t vfs_semihost_write(void* ctx, int fd, const void * data, size_t s
if (ret == -1) {
errno = host_err;
}
return (ssize_t)ret;
return size - (ssize_t)ret; /* Write syscall returns the number of bytes NOT written */
}
static ssize_t vfs_semihost_read(void* ctx, int fd, void* data, size_t size)
@ -237,7 +237,7 @@ static ssize_t vfs_semihost_read(void* ctx, int fd, void* data, size_t size)
errno = host_err;
return ret;
}
return size - (ssize_t)ret; /* Write syscall returns the number of bytes NOT written */
return size - (ssize_t)ret; /* Read syscall returns the number of bytes NOT read */
}

View file

@ -39,7 +39,7 @@ void app_main(void)
return;
}
// Increase file buffer to perform data transfers using larger chunks.
// Every read/write triggers breakpoint, so transfering of small chunks is quite inefficient.
// Every read/write triggers breakpoint, so transferring of small chunks is quite inefficient.
setvbuf(fout, (char *)s_buf, _IOFBF, sizeof(s_buf));
// this will be printed to the file on host