diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-15 21:38:46 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-15 21:38:46 +0000 |
commit | 5cf2665928c8a445ae618d4eea618dcfaff583be (patch) | |
tree | 4cdaa88e6505f5a9cc97967952415b32a3383eff /programs/utils.c | |
parent | 802267b91d9dc1f571fa6a37df10e1b909f18aa7 (diff) | |
parent | 596ec1420a085648278e390b61ed1cadb5d08fc3 (diff) | |
download | fsverity-utils-android12-mainline-tzdata3-release.tar.gz |
Snap for 8730993 from 596ec1420a085648278e390b61ed1cadb5d08fc3 to mainline-tzdata3-releaseaml_tz3_314012070aml_tz3_314012050aml_tz3_314012010aml_tz3_313110000aml_tz3_312511020aml_tz3_312511010aml_tz3_312410020aml_tz3_312410010android12-mainline-tzdata3-releaseaml_tz3_314012010
Change-Id: I85efe739cc509903ddc7d490dbadfc75958428ee
Diffstat (limited to 'programs/utils.c')
-rw-r--r-- | programs/utils.c | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/programs/utils.c b/programs/utils.c index 116eb95..ce19b57 100644 --- a/programs/utils.c +++ b/programs/utils.c @@ -13,14 +13,10 @@ #include <errno.h> #include <fcntl.h> -#include <inttypes.h> #include <limits.h> #include <stdarg.h> #include <sys/stat.h> #include <unistd.h> -#ifdef _WIN32 -# include <windows.h> -#endif /* ========== Memory allocation ========== */ @@ -130,26 +126,6 @@ bool get_file_size(struct filedes *file, u64 *size_ret) return true; } -bool preallocate_file(struct filedes *file, u64 size) -{ - int res; - - if (size == 0) - return true; -#ifdef _WIN32 - /* Not exactly the same as posix_fallocate(), but good enough... */ - res = _chsize_s(file->fd, size); -#else - res = posix_fallocate(file->fd, 0, size); -#endif - if (res != 0) { - error_msg_errno("preallocating %" PRIu64 "-byte file '%s'", - size, file->name); - return false; - } - return true; -} - bool full_read(struct filedes *file, void *buf, size_t count) { while (count) { @@ -184,41 +160,6 @@ bool full_write(struct filedes *file, const void *buf, size_t count) return true; } -static int raw_pwrite(int fd, const void *buf, int count, u64 offset) -{ -#ifdef _WIN32 - HANDLE h = (HANDLE)_get_osfhandle(fd); - OVERLAPPED pos = { .Offset = offset, .OffsetHigh = offset >> 32 }; - DWORD written = 0; - - /* Not exactly the same as pwrite(), but good enough... */ - if (!WriteFile(h, buf, count, &written, &pos)) { - errno = EIO; - return -1; - } - return written; -#else - return pwrite(fd, buf, count, offset); -#endif -} - -bool full_pwrite(struct filedes *file, const void *buf, size_t count, - u64 offset) -{ - while (count) { - int n = raw_pwrite(file->fd, buf, min(count, INT_MAX), offset); - - if (n < 0) { - error_msg_errno("writing to '%s'", file->name); - return false; - } - buf += n; - count -= n; - offset += n; - } - return true; -} - bool filedes_close(struct filedes *file) { int res; |