Skip to content

Commit

Permalink
vfs_stdio: explicit use of lseek64/off64_t where possible (potentiall…
Browse files Browse the repository at this point in the history
…y fixing #3070)
  • Loading branch information
Oleksiy-Yakovenko committed May 4, 2024
1 parent cbd5d9b commit 95673ba
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/vfs_stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@
#include <fcntl.h>
#include <unistd.h>

#ifndef __linux__
#if !defined(__linux__)
#define O_LARGEFILE 0
#endif

#if !defined(__linux__) || !defined(__GLIBC__)
#define off64_t off_t
#define lseek64 lseek
#endif

//#define USE_STDIO
#define USE_BUFFERING

Expand Down Expand Up @@ -167,7 +172,7 @@ stdio_seek (DB_FILE *stream, int64_t offset, int whence) {
whence = SEEK_SET;
offset = ((STDIO_FILE*)stream)->offs + offset;
}
off_t res = lseek (((STDIO_FILE *)stream)->stream, offset, whence);
off64_t res = lseek64 (((STDIO_FILE *)stream)->stream, offset, whence);
if (res == -1) {
return -1;
}
Expand Down Expand Up @@ -212,8 +217,8 @@ stdio_getlength (DB_FILE *stream) {
return l;
#else
if (!f->have_size) {
off_t size = lseek (f->stream, 0, SEEK_END);
lseek (f->stream, f->offs, SEEK_SET);
off64_t size = lseek64 (f->stream, 0, SEEK_END);
lseek64 (f->stream, f->offs, SEEK_SET);
#ifdef USE_BUFFERING
f->bufremaining = 0;
#endif
Expand Down

0 comments on commit 95673ba

Please sign in to comment.