blob: 306e36d068d91bf1ac243ca160596dbe0883b34e [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001From 0383fff94471278c92ef2ad5edc14abbb40a9acd Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 16 Dec 2022 18:54:55 -0800
4Subject: [PATCH] Enable 64bit off_t
5
6Ensure that off_t is always 64-bit by specifying -D_LARGEFILE_SOURCE
7-D_FILE_OFFSET_BITS=64 this will ensure that normal lseek() function is
8same as lseek64
9
10This helps compiling on latest musl where lseek64 and friends are not
11available
12
Patrick Williamsb9af8752023-01-30 13:28:01 -060013Upstream-Status: Submitted [https://github.com/Gregwar/fatcat/pull/34]
Andrew Geissler517393d2023-01-13 08:55:19 -060014Signed-off-by: Khem Raj <raj.khem@gmail.com>
15---
16 CMakeLists.txt | 2 ++
17 src/core/FatSystem.cpp | 4 ++--
18 src/core/FatSystem.h | 2 --
19 3 files changed, 4 insertions(+), 4 deletions(-)
20
21diff --git a/CMakeLists.txt b/CMakeLists.txt
22index d6a2649..4cdd1fb 100644
23--- a/CMakeLists.txt
24+++ b/CMakeLists.txt
25@@ -34,6 +34,8 @@ IF(DEFINE_WIN)
26 add_definitions(-D__WIN__)
27 ENDIF(DEFINE_WIN)
28
29+add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64)
30+
31 include_directories("${CMAKE_SOURCE_DIR}/src")
32
33 add_executable(fatcat "src/fatcat.cpp" ${ALL_SOURCES})
34diff --git a/src/core/FatSystem.cpp b/src/core/FatSystem.cpp
35index 79cda8c..1f52e82 100644
36--- a/src/core/FatSystem.cpp
37+++ b/src/core/FatSystem.cpp
38@@ -90,7 +90,7 @@ int FatSystem::readData(unsigned long long address, char *buffer, int size)
39 cerr << "! Trying to read outside the disk" << endl;
40 }
41
42- lseek64(fd, globalOffset+address, SEEK_SET);
43+ lseek(fd, globalOffset+address, SEEK_SET);
44
45 int n;
46 int pos = 0;
47@@ -112,7 +112,7 @@ int FatSystem::writeData(unsigned long long address, const char *buffer, int siz
48 throw string("Trying to write data while write mode is disabled");
49 }
50
51- lseek64(fd, globalOffset+address, SEEK_SET);
52+ lseek(fd, globalOffset+address, SEEK_SET);
53
54 int n;
55 int pos = 0;
56diff --git a/src/core/FatSystem.h b/src/core/FatSystem.h
57index cd3c914..f9f2ca3 100644
58--- a/src/core/FatSystem.h
59+++ b/src/core/FatSystem.h
60@@ -11,11 +11,9 @@
61
62 #ifdef __APPLE__
63 #define O_LARGEFILE 0
64-#define lseek64 lseek
65 #endif
66 #ifdef __WIN__
67 #define O_LARGEFILE 0
68-#define lseek64 lseek
69 #endif
70 using namespace std;
71