* [PATCH v3 1/3] configure: use AC_SYS_LARGEFILE
@ 2022-12-15 6:47 Khem Raj
2022-12-15 6:47 ` [PATCH v3 2/3] erofs: replace [l]stat64 by equivalent [l]stat Khem Raj
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Khem Raj @ 2022-12-15 6:47 UTC (permalink / raw)
To: linux-erofs; +Cc: Khem Raj
The autoconf macro AC_SYS_LARGEFILE defines _FILE_OFFSET_BITS=64
where necessary to ensure that off_t and all interfaces using off_t
are 64bit, even on 32bit systems.
Pass -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=66 via CFLAGS
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
configure.ac | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/configure.ac b/configure.ac
index a736ff0..e8bb003 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,6 +13,8 @@ AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE([foreign -Wall])
+AC_SYS_LARGEFILE
+
# Checks for programs.
AM_PROG_AR
AC_PROG_CC
@@ -319,6 +321,9 @@ if test "x$enable_lzma" = "xyes"; then
CPPFLAGS="${saved_CPPFLAGS}"
fi
+# Enable 64-bit off_t
+CFLAGS+=" -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+
# Set up needed symbols, conditionals and compiler/linker flags
AM_CONDITIONAL([ENABLE_LZ4], [test "x${have_lz4}" = "xyes"])
AM_CONDITIONAL([ENABLE_LZ4HC], [test "x${have_lz4hc}" = "xyes"])
--
2.39.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/3] erofs: replace [l]stat64 by equivalent [l]stat
2022-12-15 6:47 [PATCH v3 1/3] configure: use AC_SYS_LARGEFILE Khem Raj
@ 2022-12-15 6:47 ` Khem Raj
2022-12-15 8:55 ` Gao Xiang
2022-12-15 6:47 ` [PATCH v3 3/3] internal.h: Make LFS mandatory for all usecases Khem Raj
2022-12-15 8:53 ` [PATCH v3 1/3] configure: use AC_SYS_LARGEFILE Gao Xiang
2 siblings, 1 reply; 5+ messages in thread
From: Khem Raj @ 2022-12-15 6:47 UTC (permalink / raw)
To: linux-erofs; +Cc: Khem Raj
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
lib/inode.c | 10 +++++-----
lib/xattr.c | 4 ++--
mkfs/main.c | 4 ++--
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/lib/inode.c b/lib/inode.c
index f192510..38003fc 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -773,7 +773,7 @@ static u32 erofs_new_encode_dev(dev_t dev)
#ifdef WITH_ANDROID
int erofs_droid_inode_fsconfig(struct erofs_inode *inode,
- struct stat64 *st,
+ struct stat *st,
const char *path)
{
/* filesystem_config does not preserve file type bits */
@@ -818,7 +818,7 @@ int erofs_droid_inode_fsconfig(struct erofs_inode *inode,
}
#else
static int erofs_droid_inode_fsconfig(struct erofs_inode *inode,
- struct stat64 *st,
+ struct stat *st,
const char *path)
{
return 0;
@@ -826,7 +826,7 @@ static int erofs_droid_inode_fsconfig(struct erofs_inode *inode,
#endif
static int erofs_fill_inode(struct erofs_inode *inode,
- struct stat64 *st,
+ struct stat *st,
const char *path)
{
int err = erofs_droid_inode_fsconfig(inode, st, path);
@@ -910,7 +910,7 @@ static struct erofs_inode *erofs_new_inode(void)
/* get the inode from the (source) path */
static struct erofs_inode *erofs_iget_from_path(const char *path, bool is_src)
{
- struct stat64 st;
+ struct stat st;
struct erofs_inode *inode;
int ret;
@@ -918,7 +918,7 @@ static struct erofs_inode *erofs_iget_from_path(const char *path, bool is_src)
if (!is_src)
return ERR_PTR(-EINVAL);
- ret = lstat64(path, &st);
+ ret = lstat(path, &st);
if (ret)
return ERR_PTR(-errno);
diff --git a/lib/xattr.c b/lib/xattr.c
index 71ffe3e..fd0e728 100644
--- a/lib/xattr.c
+++ b/lib/xattr.c
@@ -467,7 +467,7 @@ static int erofs_count_all_xattrs_from_path(const char *path)
{
int ret;
DIR *_dir;
- struct stat64 st;
+ struct stat st;
_dir = opendir(path);
if (!_dir) {
@@ -502,7 +502,7 @@ static int erofs_count_all_xattrs_from_path(const char *path)
goto fail;
}
- ret = lstat64(buf, &st);
+ ret = lstat(buf, &st);
if (ret) {
ret = -errno;
goto fail;
diff --git a/mkfs/main.c b/mkfs/main.c
index d2c9830..5279805 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -581,7 +581,7 @@ int main(int argc, char **argv)
struct erofs_buffer_head *sb_bh;
struct erofs_inode *root_inode;
erofs_nid_t root_nid;
- struct stat64 st;
+ struct stat st;
erofs_blk_t nblocks;
struct timeval t;
char uuid_str[37] = "not available";
@@ -609,7 +609,7 @@ int main(int argc, char **argv)
return 1;
}
- err = lstat64(cfg.c_src_path, &st);
+ err = lstat(cfg.c_src_path, &st);
if (err)
return 1;
if (!S_ISDIR(st.st_mode)) {
--
2.39.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 3/3] internal.h: Make LFS mandatory for all usecases
2022-12-15 6:47 [PATCH v3 1/3] configure: use AC_SYS_LARGEFILE Khem Raj
2022-12-15 6:47 ` [PATCH v3 2/3] erofs: replace [l]stat64 by equivalent [l]stat Khem Raj
@ 2022-12-15 6:47 ` Khem Raj
2022-12-15 8:53 ` [PATCH v3 1/3] configure: use AC_SYS_LARGEFILE Gao Xiang
2 siblings, 0 replies; 5+ messages in thread
From: Khem Raj @ 2022-12-15 6:47 UTC (permalink / raw)
To: linux-erofs; +Cc: Khem Raj
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.
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
include/erofs/internal.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/erofs/internal.h b/include/erofs/internal.h
index 6a70f11..d3b2986 100644
--- a/include/erofs/internal.h
+++ b/include/erofs/internal.h
@@ -21,6 +21,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 +105,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;
--
2.39.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 1/3] configure: use AC_SYS_LARGEFILE
2022-12-15 6:47 [PATCH v3 1/3] configure: use AC_SYS_LARGEFILE Khem Raj
2022-12-15 6:47 ` [PATCH v3 2/3] erofs: replace [l]stat64 by equivalent [l]stat Khem Raj
2022-12-15 6:47 ` [PATCH v3 3/3] internal.h: Make LFS mandatory for all usecases Khem Raj
@ 2022-12-15 8:53 ` Gao Xiang
2 siblings, 0 replies; 5+ messages in thread
From: Gao Xiang @ 2022-12-15 8:53 UTC (permalink / raw)
To: Khem Raj; +Cc: linux-erofs
Hi Khem,
On Wed, Dec 14, 2022 at 10:47:56PM -0800, Khem Raj wrote:
> The autoconf macro AC_SYS_LARGEFILE defines _FILE_OFFSET_BITS=64
> where necessary to ensure that off_t and all interfaces using off_t
> are 64bit, even on 32bit systems.
>
> Pass -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=66 via CFLAGS
^ -D_FILE_OFFSET_BITS=64?
>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
> configure.ac | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/configure.ac b/configure.ac
> index a736ff0..e8bb003 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -13,6 +13,8 @@ AC_CONFIG_MACRO_DIR([m4])
> AC_CONFIG_AUX_DIR(config)
> AM_INIT_AUTOMAKE([foreign -Wall])
>
> +AC_SYS_LARGEFILE
Do we still need this? Also it introduces --disable-largefile and which
will break the functionality to us.
Also see:
https://lore.kernel.org/linux-xfs/1480552932-614-1-git-send-email-ebiggers@google.com
Otherwise looks good to me.
Thanks,
Gao Xiang
> +
> # Checks for programs.
> AM_PROG_AR
> AC_PROG_CC
> @@ -319,6 +321,9 @@ if test "x$enable_lzma" = "xyes"; then
> CPPFLAGS="${saved_CPPFLAGS}"
> fi
>
> +# Enable 64-bit off_t
> +CFLAGS+=" -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
> +
> # Set up needed symbols, conditionals and compiler/linker flags
> AM_CONDITIONAL([ENABLE_LZ4], [test "x${have_lz4}" = "xyes"])
> AM_CONDITIONAL([ENABLE_LZ4HC], [test "x${have_lz4hc}" = "xyes"])
> --
> 2.39.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3 2/3] erofs: replace [l]stat64 by equivalent [l]stat
2022-12-15 6:47 ` [PATCH v3 2/3] erofs: replace [l]stat64 by equivalent [l]stat Khem Raj
@ 2022-12-15 8:55 ` Gao Xiang
0 siblings, 0 replies; 5+ messages in thread
From: Gao Xiang @ 2022-12-15 8:55 UTC (permalink / raw)
To: Khem Raj; +Cc: linux-erofs
On Wed, Dec 14, 2022 at 10:47:57PM -0800, Khem Raj wrote:
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Thanks,
Gao Xiang
> ---
> lib/inode.c | 10 +++++-----
> lib/xattr.c | 4 ++--
> mkfs/main.c | 4 ++--
> 3 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/lib/inode.c b/lib/inode.c
> index f192510..38003fc 100644
> --- a/lib/inode.c
> +++ b/lib/inode.c
> @@ -773,7 +773,7 @@ static u32 erofs_new_encode_dev(dev_t dev)
>
> #ifdef WITH_ANDROID
> int erofs_droid_inode_fsconfig(struct erofs_inode *inode,
> - struct stat64 *st,
> + struct stat *st,
> const char *path)
> {
> /* filesystem_config does not preserve file type bits */
> @@ -818,7 +818,7 @@ int erofs_droid_inode_fsconfig(struct erofs_inode *inode,
> }
> #else
> static int erofs_droid_inode_fsconfig(struct erofs_inode *inode,
> - struct stat64 *st,
> + struct stat *st,
> const char *path)
> {
> return 0;
> @@ -826,7 +826,7 @@ static int erofs_droid_inode_fsconfig(struct erofs_inode *inode,
> #endif
>
> static int erofs_fill_inode(struct erofs_inode *inode,
> - struct stat64 *st,
> + struct stat *st,
> const char *path)
> {
> int err = erofs_droid_inode_fsconfig(inode, st, path);
> @@ -910,7 +910,7 @@ static struct erofs_inode *erofs_new_inode(void)
> /* get the inode from the (source) path */
> static struct erofs_inode *erofs_iget_from_path(const char *path, bool is_src)
> {
> - struct stat64 st;
> + struct stat st;
> struct erofs_inode *inode;
> int ret;
>
> @@ -918,7 +918,7 @@ static struct erofs_inode *erofs_iget_from_path(const char *path, bool is_src)
> if (!is_src)
> return ERR_PTR(-EINVAL);
>
> - ret = lstat64(path, &st);
> + ret = lstat(path, &st);
> if (ret)
> return ERR_PTR(-errno);
>
> diff --git a/lib/xattr.c b/lib/xattr.c
> index 71ffe3e..fd0e728 100644
> --- a/lib/xattr.c
> +++ b/lib/xattr.c
> @@ -467,7 +467,7 @@ static int erofs_count_all_xattrs_from_path(const char *path)
> {
> int ret;
> DIR *_dir;
> - struct stat64 st;
> + struct stat st;
>
> _dir = opendir(path);
> if (!_dir) {
> @@ -502,7 +502,7 @@ static int erofs_count_all_xattrs_from_path(const char *path)
> goto fail;
> }
>
> - ret = lstat64(buf, &st);
> + ret = lstat(buf, &st);
> if (ret) {
> ret = -errno;
> goto fail;
> diff --git a/mkfs/main.c b/mkfs/main.c
> index d2c9830..5279805 100644
> --- a/mkfs/main.c
> +++ b/mkfs/main.c
> @@ -581,7 +581,7 @@ int main(int argc, char **argv)
> struct erofs_buffer_head *sb_bh;
> struct erofs_inode *root_inode;
> erofs_nid_t root_nid;
> - struct stat64 st;
> + struct stat st;
> erofs_blk_t nblocks;
> struct timeval t;
> char uuid_str[37] = "not available";
> @@ -609,7 +609,7 @@ int main(int argc, char **argv)
> return 1;
> }
>
> - err = lstat64(cfg.c_src_path, &st);
> + err = lstat(cfg.c_src_path, &st);
> if (err)
> return 1;
> if (!S_ISDIR(st.st_mode)) {
> --
> 2.39.0
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-12-15 8:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-15 6:47 [PATCH v3 1/3] configure: use AC_SYS_LARGEFILE Khem Raj
2022-12-15 6:47 ` [PATCH v3 2/3] erofs: replace [l]stat64 by equivalent [l]stat Khem Raj
2022-12-15 8:55 ` Gao Xiang
2022-12-15 6:47 ` [PATCH v3 3/3] internal.h: Make LFS mandatory for all usecases Khem Raj
2022-12-15 8:53 ` [PATCH v3 1/3] configure: use AC_SYS_LARGEFILE Gao Xiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).