diff options
author | Anton Ivanov <aivanov@brocade.com> | 2015-12-21 18:54:00 +0000 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2016-01-10 21:49:48 +0100 |
commit | 8c6157b6b30a765ec233a1be5f9446f24a5283de (patch) | |
tree | 81128a9f0252bd4075b6093cf5408eab19d45ce4 /arch/um/os-Linux | |
parent | 470a166e8c5a4da4be88545b1c4dde308abac5b2 (diff) | |
download | linux-stable-8c6157b6b30a765ec233a1be5f9446f24a5283de.tar.gz linux-stable-8c6157b6b30a765ec233a1be5f9446f24a5283de.tar.bz2 linux-stable-8c6157b6b30a765ec233a1be5f9446f24a5283de.zip |
um: Update UBD to use pread/pwrite family of functions
This decreases the number of syscalls per read/write by half.
Signed-off-by: Anton Ivanov <aivanov@brocade.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um/os-Linux')
-rw-r--r-- | arch/um/os-Linux/file.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c index 26e0164895e4..2db18cbbb0ea 100644 --- a/arch/um/os-Linux/file.c +++ b/arch/um/os-Linux/file.c @@ -264,6 +264,15 @@ int os_read_file(int fd, void *buf, int len) return n; } +int os_pread_file(int fd, void *buf, int len, unsigned long long offset) +{ + int n = pread(fd, buf, len, offset); + + if (n < 0) + return -errno; + return n; +} + int os_write_file(int fd, const void *buf, int len) { int n = write(fd, (void *) buf, len); @@ -282,6 +291,16 @@ int os_sync_file(int fd) return n; } +int os_pwrite_file(int fd, const void *buf, int len, unsigned long long offset) +{ + int n = pwrite(fd, (void *) buf, len, offset); + + if (n < 0) + return -errno; + return n; +} + + int os_file_size(const char *file, unsigned long long *size_out) { struct uml_stat buf; |