[[PATCH v2 2/3] includes: Make LFS mandatory for all usecases

Khem Raj raj.khem at gmail.com
Sat Dec 10 13:22:06 AEDT 2022


erosfs depend on the consistent use of a 64bit offset
type, force downstreams to use transparent LFS (_FILE_OFFSET_BITS=64),
so that it becomes impossible for them to use 32bit interfaces.

include autoconf'ed config.h to get definition of _FILE_OFFSET_BITS
which was detected by configure. This header needs to be included
before any system headers are included to ensure they see the correct
definition of _FILE_OFFSET_BITS for the platform

Signed-off-by: Khem Raj <raj.khem at gmail.com>
---
 dump/main.c              | 1 +
 fsck/main.c              | 1 +
 include/erofs/internal.h | 6 ++++++
 lib/Makefile.am          | 2 +-
 mkfs/main.c              | 1 +
 5 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/dump/main.c b/dump/main.c
index 49ff2b7..1b40f2a 100644
--- a/dump/main.c
+++ b/dump/main.c
@@ -6,6 +6,7 @@
  *            Guo Xuenan <guoxuenan at huawei.com>
  */
 #define _GNU_SOURCE
+#include "config.h"
 #include <stdlib.h>
 #include <getopt.h>
 #include <time.h>
diff --git a/fsck/main.c b/fsck/main.c
index 5a2f659..82eef93 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -3,6 +3,7 @@
  * Copyright 2021 Google LLC
  * Author: Daeho Jeong <daehojeong at google.com>
  */
+#include "config.h"
 #include <stdlib.h>
 #include <getopt.h>
 #include <time.h>
diff --git a/include/erofs/internal.h b/include/erofs/internal.h
index 6a70f11..81fc07b 100644
--- a/include/erofs/internal.h
+++ b/include/erofs/internal.h
@@ -12,6 +12,7 @@ extern "C"
 {
 #endif
 
+#include <config.h>
 #include "list.h"
 #include "err.h"
 
@@ -21,6 +22,7 @@ typedef unsigned short umode_t;
 
 #include "erofs_fs.h"
 #include <fcntl.h>
+#include <sys/types.h> /* for off_t definition */
 
 #ifndef PATH_MAX
 #define PATH_MAX        4096    /* # chars in a path name including nul */
@@ -104,6 +106,10 @@ struct erofs_sb_info {
 	};
 };
 
+
+/* make sure that any user of the erofs headers has atleast 64bit off_t type */
+extern int erofs_assert_largefile[sizeof(off_t)-8];
+
 /* global sbi */
 extern struct erofs_sb_info sbi;
 
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 3fad357..88400ed 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -28,7 +28,7 @@ noinst_HEADERS += compressor.h
 liberofs_la_SOURCES = config.c io.c cache.c super.c inode.c xattr.c exclude.c \
 		      namei.c data.c compress.c compressor.c zmap.c decompress.c \
 		      compress_hints.c hashmap.c sha256.c blobchunk.c dir.c
-liberofs_la_CFLAGS = -Wall -I$(top_srcdir)/include
+liberofs_la_CFLAGS = -Wall -I$(top_builddir) -I$(top_srcdir)/include -include config.h
 if ENABLE_LZ4
 liberofs_la_CFLAGS += ${LZ4_CFLAGS}
 liberofs_la_SOURCES += compressor_lz4.c
diff --git a/mkfs/main.c b/mkfs/main.c
index d2c9830..0e601d9 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -5,6 +5,7 @@
  * Created by Li Guifu <bluce.liguifu at huawei.com>
  */
 #define _GNU_SOURCE
+#include "config.h"
 #include <time.h>
 #include <sys/time.h>
 #include <stdlib.h>
-- 
2.38.1



More information about the Linux-erofs mailing list