diff options
| author | Khem Raj <raj.khem@gmail.com> | 2022-12-15 00:45:36 -0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-12-21 10:16:31 +0000 |
| commit | dd097f6934d640fc7399ff0f4d7217b192e388d4 (patch) | |
| tree | 05bc0bc0153e84d7e346979ce4c12f1447406998 | |
| parent | 6a6813792899f4f8147944d55ac6f4a97cf775ce (diff) | |
| download | poky-dd097f6934d640fc7399ff0f4d7217b192e388d4.tar.gz | |
erofs-utils: Convert from off64_t to off_t
Ensure largefile macros are used to determine size of off_t and not the
explict 64bit version of functions and types
(From OE-Core rev: 135e45931a0a2ea9954cb2da13ce59b0b3f569ef)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
4 files changed, 199 insertions, 2 deletions
diff --git a/meta/recipes-devtools/erofs-utils/erofs-utils/0001-configure-use-AC_SYS_LARGEFILE.patch b/meta/recipes-devtools/erofs-utils/erofs-utils/0001-configure-use-AC_SYS_LARGEFILE.patch new file mode 100644 index 0000000000..75c91f51a7 --- /dev/null +++ b/meta/recipes-devtools/erofs-utils/erofs-utils/0001-configure-use-AC_SYS_LARGEFILE.patch | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | From fef3b16dba2c5f6ad88951b80cdfbedd423e80a0 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Wed, 7 Dec 2022 20:16:52 -0800 | ||
| 4 | Subject: [PATCH v3 1/3] configure: use AC_SYS_LARGEFILE | ||
| 5 | |||
| 6 | The autoconf macro AC_SYS_LARGEFILE defines _FILE_OFFSET_BITS=64 | ||
| 7 | where necessary to ensure that off_t and all interfaces using off_t | ||
| 8 | are 64bit, even on 32bit systems. | ||
| 9 | |||
| 10 | Pass -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=66 via CFLAGS | ||
| 11 | |||
| 12 | Upstream-Status: Submitted [https://lore.kernel.org/linux-erofs/20221215064758.93821-1-raj.khem@gmail.com/T/#t] | ||
| 13 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 14 | --- | ||
| 15 | configure.ac | 5 +++++ | ||
| 16 | 1 file changed, 5 insertions(+) | ||
| 17 | |||
| 18 | diff --git a/configure.ac b/configure.ac | ||
| 19 | index a736ff0..e8bb003 100644 | ||
| 20 | --- a/configure.ac | ||
| 21 | +++ b/configure.ac | ||
| 22 | @@ -13,6 +13,8 @@ AC_CONFIG_MACRO_DIR([m4]) | ||
| 23 | AC_CONFIG_AUX_DIR(config) | ||
| 24 | AM_INIT_AUTOMAKE([foreign -Wall]) | ||
| 25 | |||
| 26 | +AC_SYS_LARGEFILE | ||
| 27 | + | ||
| 28 | # Checks for programs. | ||
| 29 | AM_PROG_AR | ||
| 30 | AC_PROG_CC | ||
| 31 | @@ -319,6 +321,9 @@ if test "x$enable_lzma" = "xyes"; then | ||
| 32 | CPPFLAGS="${saved_CPPFLAGS}" | ||
| 33 | fi | ||
| 34 | |||
| 35 | +# Enable 64-bit off_t | ||
| 36 | +CFLAGS+=" -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" | ||
| 37 | + | ||
| 38 | # Set up needed symbols, conditionals and compiler/linker flags | ||
| 39 | AM_CONDITIONAL([ENABLE_LZ4], [test "x${have_lz4}" = "xyes"]) | ||
| 40 | AM_CONDITIONAL([ENABLE_LZ4HC], [test "x${have_lz4hc}" = "xyes"]) | ||
| 41 | -- | ||
| 42 | 2.39.0 | ||
| 43 | |||
diff --git a/meta/recipes-devtools/erofs-utils/erofs-utils/0002-erofs-replace-l-stat64-by-equivalent-l-stat.patch b/meta/recipes-devtools/erofs-utils/erofs-utils/0002-erofs-replace-l-stat64-by-equivalent-l-stat.patch new file mode 100644 index 0000000000..d12bebbf87 --- /dev/null +++ b/meta/recipes-devtools/erofs-utils/erofs-utils/0002-erofs-replace-l-stat64-by-equivalent-l-stat.patch | |||
| @@ -0,0 +1,109 @@ | |||
| 1 | From 856189c324834b838f0e9cfc0d2e05f12518f264 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Wed, 7 Dec 2022 22:17:35 -0800 | ||
| 4 | Subject: [PATCH v3 2/3] erofs: replace [l]stat64 by equivalent [l]stat | ||
| 5 | |||
| 6 | Upstream-Status: Submitted [https://lore.kernel.org/linux-erofs/20221215064758.93821-2-raj.khem@gmail.com/T/#u] | ||
| 7 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 8 | --- | ||
| 9 | lib/inode.c | 10 +++++----- | ||
| 10 | lib/xattr.c | 4 ++-- | ||
| 11 | mkfs/main.c | 4 ++-- | ||
| 12 | 3 files changed, 9 insertions(+), 9 deletions(-) | ||
| 13 | |||
| 14 | diff --git a/lib/inode.c b/lib/inode.c | ||
| 15 | index f192510..38003fc 100644 | ||
| 16 | --- a/lib/inode.c | ||
| 17 | +++ b/lib/inode.c | ||
| 18 | @@ -773,7 +773,7 @@ static u32 erofs_new_encode_dev(dev_t dev) | ||
| 19 | |||
| 20 | #ifdef WITH_ANDROID | ||
| 21 | int erofs_droid_inode_fsconfig(struct erofs_inode *inode, | ||
| 22 | - struct stat64 *st, | ||
| 23 | + struct stat *st, | ||
| 24 | const char *path) | ||
| 25 | { | ||
| 26 | /* filesystem_config does not preserve file type bits */ | ||
| 27 | @@ -818,7 +818,7 @@ int erofs_droid_inode_fsconfig(struct erofs_inode *inode, | ||
| 28 | } | ||
| 29 | #else | ||
| 30 | static int erofs_droid_inode_fsconfig(struct erofs_inode *inode, | ||
| 31 | - struct stat64 *st, | ||
| 32 | + struct stat *st, | ||
| 33 | const char *path) | ||
| 34 | { | ||
| 35 | return 0; | ||
| 36 | @@ -826,7 +826,7 @@ static int erofs_droid_inode_fsconfig(struct erofs_inode *inode, | ||
| 37 | #endif | ||
| 38 | |||
| 39 | static int erofs_fill_inode(struct erofs_inode *inode, | ||
| 40 | - struct stat64 *st, | ||
| 41 | + struct stat *st, | ||
| 42 | const char *path) | ||
| 43 | { | ||
| 44 | int err = erofs_droid_inode_fsconfig(inode, st, path); | ||
| 45 | @@ -910,7 +910,7 @@ static struct erofs_inode *erofs_new_inode(void) | ||
| 46 | /* get the inode from the (source) path */ | ||
| 47 | static struct erofs_inode *erofs_iget_from_path(const char *path, bool is_src) | ||
| 48 | { | ||
| 49 | - struct stat64 st; | ||
| 50 | + struct stat st; | ||
| 51 | struct erofs_inode *inode; | ||
| 52 | int ret; | ||
| 53 | |||
| 54 | @@ -918,7 +918,7 @@ static struct erofs_inode *erofs_iget_from_path(const char *path, bool is_src) | ||
| 55 | if (!is_src) | ||
| 56 | return ERR_PTR(-EINVAL); | ||
| 57 | |||
| 58 | - ret = lstat64(path, &st); | ||
| 59 | + ret = lstat(path, &st); | ||
| 60 | if (ret) | ||
| 61 | return ERR_PTR(-errno); | ||
| 62 | |||
| 63 | diff --git a/lib/xattr.c b/lib/xattr.c | ||
| 64 | index 71ffe3e..fd0e728 100644 | ||
| 65 | --- a/lib/xattr.c | ||
| 66 | +++ b/lib/xattr.c | ||
| 67 | @@ -467,7 +467,7 @@ static int erofs_count_all_xattrs_from_path(const char *path) | ||
| 68 | { | ||
| 69 | int ret; | ||
| 70 | DIR *_dir; | ||
| 71 | - struct stat64 st; | ||
| 72 | + struct stat st; | ||
| 73 | |||
| 74 | _dir = opendir(path); | ||
| 75 | if (!_dir) { | ||
| 76 | @@ -502,7 +502,7 @@ static int erofs_count_all_xattrs_from_path(const char *path) | ||
| 77 | goto fail; | ||
| 78 | } | ||
| 79 | |||
| 80 | - ret = lstat64(buf, &st); | ||
| 81 | + ret = lstat(buf, &st); | ||
| 82 | if (ret) { | ||
| 83 | ret = -errno; | ||
| 84 | goto fail; | ||
| 85 | diff --git a/mkfs/main.c b/mkfs/main.c | ||
| 86 | index d2c9830..5279805 100644 | ||
| 87 | --- a/mkfs/main.c | ||
| 88 | +++ b/mkfs/main.c | ||
| 89 | @@ -581,7 +581,7 @@ int main(int argc, char **argv) | ||
| 90 | struct erofs_buffer_head *sb_bh; | ||
| 91 | struct erofs_inode *root_inode; | ||
| 92 | erofs_nid_t root_nid; | ||
| 93 | - struct stat64 st; | ||
| 94 | + struct stat st; | ||
| 95 | erofs_blk_t nblocks; | ||
| 96 | struct timeval t; | ||
| 97 | char uuid_str[37] = "not available"; | ||
| 98 | @@ -609,7 +609,7 @@ int main(int argc, char **argv) | ||
| 99 | return 1; | ||
| 100 | } | ||
| 101 | |||
| 102 | - err = lstat64(cfg.c_src_path, &st); | ||
| 103 | + err = lstat(cfg.c_src_path, &st); | ||
| 104 | if (err) | ||
| 105 | return 1; | ||
| 106 | if (!S_ISDIR(st.st_mode)) { | ||
| 107 | -- | ||
| 108 | 2.39.0 | ||
| 109 | |||
diff --git a/meta/recipes-devtools/erofs-utils/erofs-utils/0003-internal.h-Make-LFS-mandatory-for-all-usecases.patch b/meta/recipes-devtools/erofs-utils/erofs-utils/0003-internal.h-Make-LFS-mandatory-for-all-usecases.patch new file mode 100644 index 0000000000..97faa5d673 --- /dev/null +++ b/meta/recipes-devtools/erofs-utils/erofs-utils/0003-internal.h-Make-LFS-mandatory-for-all-usecases.patch | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | From 8f8cbc7b773da63bce8226249784ba6824635c9c Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Wed, 7 Dec 2022 20:19:27 -0800 | ||
| 4 | Subject: [PATCH v3 3/3] internal.h: Make LFS mandatory for all usecases | ||
| 5 | |||
| 6 | erosfs depend on the consistent use of a 64bit offset | ||
| 7 | type, force downstreams to use transparent LFS (_FILE_OFFSET_BITS=64), | ||
| 8 | so that it becomes impossible for them to use 32bit interfaces. | ||
| 9 | |||
| 10 | Upstream-Status: Submitted [https://lore.kernel.org/linux-erofs/20221215064758.93821-3-raj.khem@gmail.com/T/#u] | ||
| 11 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 12 | --- | ||
| 13 | include/erofs/internal.h | 5 +++++ | ||
| 14 | 1 file changed, 5 insertions(+) | ||
| 15 | |||
| 16 | diff --git a/include/erofs/internal.h b/include/erofs/internal.h | ||
| 17 | index 6a70f11..d3b2986 100644 | ||
| 18 | --- a/include/erofs/internal.h | ||
| 19 | +++ b/include/erofs/internal.h | ||
| 20 | @@ -21,6 +21,7 @@ typedef unsigned short umode_t; | ||
| 21 | |||
| 22 | #include "erofs_fs.h" | ||
| 23 | #include <fcntl.h> | ||
| 24 | +#include <sys/types.h> /* for off_t definition */ | ||
| 25 | |||
| 26 | #ifndef PATH_MAX | ||
| 27 | #define PATH_MAX 4096 /* # chars in a path name including nul */ | ||
| 28 | @@ -104,6 +105,10 @@ struct erofs_sb_info { | ||
| 29 | }; | ||
| 30 | }; | ||
| 31 | |||
| 32 | + | ||
| 33 | +/* make sure that any user of the erofs headers has atleast 64bit off_t type */ | ||
| 34 | +extern int erofs_assert_largefile[sizeof(off_t)-8]; | ||
| 35 | + | ||
| 36 | /* global sbi */ | ||
| 37 | extern struct erofs_sb_info sbi; | ||
| 38 | |||
| 39 | -- | ||
| 40 | 2.39.0 | ||
| 41 | |||
diff --git a/meta/recipes-devtools/erofs-utils/erofs-utils_1.5.bb b/meta/recipes-devtools/erofs-utils/erofs-utils_1.5.bb index b9a97b3e53..6ce5843570 100644 --- a/meta/recipes-devtools/erofs-utils/erofs-utils_1.5.bb +++ b/meta/recipes-devtools/erofs-utils/erofs-utils_1.5.bb | |||
| @@ -6,7 +6,11 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=73001d804ea1e3d84365f652242cca20" | |||
| 6 | HOMEPAGE = "https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git/tree/README" | 6 | HOMEPAGE = "https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git/tree/README" |
| 7 | 7 | ||
| 8 | SRCREV = "a2821a66b42aee5430bccee82c280e38d1e9ab29" | 8 | SRCREV = "a2821a66b42aee5430bccee82c280e38d1e9ab29" |
| 9 | SRC_URI = "git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git;branch=master" | 9 | SRC_URI = "git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git;branch=master \ |
| 10 | file://0001-configure-use-AC_SYS_LARGEFILE.patch \ | ||
| 11 | file://0002-erofs-replace-l-stat64-by-equivalent-l-stat.patch \ | ||
| 12 | file://0003-internal.h-Make-LFS-mandatory-for-all-usecases.patch \ | ||
| 13 | " | ||
| 10 | 14 | ||
| 11 | UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>(\d+(\.\d+)+))" | 15 | UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>(\d+(\.\d+)+))" |
| 12 | 16 | ||
| @@ -19,7 +23,7 @@ inherit pkgconfig autotools | |||
| 19 | PACKAGECONFIG ??= "lz4" | 23 | PACKAGECONFIG ??= "lz4" |
| 20 | PACKAGECONFIG[lz4] = "--enable-lz4,--disable-lz4,lz4" | 24 | PACKAGECONFIG[lz4] = "--enable-lz4,--disable-lz4,lz4" |
| 21 | 25 | ||
| 22 | EXTRA_OECONF = "${PACKAGECONFIG_CONFARGS} --disable-fuse" | 26 | EXTRA_OECONF = "${PACKAGECONFIG_CONFARGS} --disable-fuse --enable-largefile" |
| 23 | 27 | ||
| 24 | CFLAGS:append:powerpc64le = " -D__SANE_USERSPACE_TYPES__" | 28 | CFLAGS:append:powerpc64le = " -D__SANE_USERSPACE_TYPES__" |
| 25 | 29 | ||
