Skip to contentSkip to conversation

build of erofs-utils 1.8.6 fails with musl libc

PATCH Superseded Milan P. Stanić 3 participants 6 messages May 6, 2025 – May 10, 2025

lore
Share & tools
lore
#0 lore raw

Hi,

I'm maintainer of erofs-utils for Alpine linux, distribution which use musl libc instead of glibc.

Building version 1.8.6 gives error:
------------------
Making all in contrib
make[2]: Entering directory '/home/mps/aports/community/erofs-utils/src/erofs-utils-1.8.6/contrib'
cc -DHAVE_CONFIG_H -I. -I.. -DNDEBUG -Wall -I../include -Os -fstack-clash-protection -Wformat -Werror=format-security -fno-plt -MT stress-stress.o -MD -MP -MF .deps/stress-stress.Tpo -c -o stress-stress.o test -f 'stress.c' || echo './'stress.c
stress.c: In function '__getdents_f':
stress.c:274:16: error: implicit declaration of function 'readdir64'; did you mean 'readdir_r'? [-Wimplicit-function-declaration]

  274 |         while (readdir64(dir) != NULL)
      |                ^~~~~~~~~
      |                readdir_r

stress.c:274:31: warning: comparison between pointer and integer
274 | while (readdir64(dir) != NULL)
| ^~
stress.c: In function '__read_f':
stress.c:431:17: error: implicit declaration of function 'pread64'; did you mean 'pread'? [-Wimplicit-function-declaration]

  431 |         nread = pread64(fe->fd, buf, len, off);
      |                 ^~~~~~~
      |                 pread
stress.c: In function 'read_f':
stress.c:480:15: error: implicit declaration of function 'lseek64'; did you mean 'lseek'? [-Wimplicit-function-declaration]
  480 |         fsz = lseek64(fe->fd, 0, SEEK_END);
      |               ^~~~~~~
      |               lseek

make[2]: *** [Makefile:420: stress-stress.o] Error 1
make[2]: Leaving directory '/home/mps/aports/community/erofs-utils/src/erofs-utils-1.8.6/contrib' make[1]: *** [Makefile:447: all-recursive] Error 1
make[1]: Leaving directory '/home/mps/aports/community/erofs-utils/src/erofs-utils-1.8.6'
make: *** [Makefile:379: all] Error 2

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

ERROR: erofs-utils: build failed
erofs-utils: Uninstalling dependencies...

(1/19) Purging .makedepends-erofs-utils (20250506.063719)
------------------

This is because musl use readdir, pread and lseek instead of readdir64, pread64 and lseek64.
(IMO musl does this properly)

Natanael Copa <[email protected]> created patch with which I build erofs-utils successfully. I'm attaching patch to this mail.

Feel free to contact me if you more information or to try some new patches.

Signature · 1 line
Kind regards
contrib/stress.c +11 -11
index d8def6a..0593d71 100644
@@ -271,7 +271,7 @@ static int __getdents_f(unsigned int sn, struct fent *fe)
 	}
 
 	dir = fdopendir(dfd);
-	while (readdir64(dir) != NULL)
+	while (readdir(dir) != NULL)
 		continue;
 	closedir(dir);
 	return 0;
@@ -428,7 +428,7 @@ static int __read_f(unsigned int sn, struct fent *fe, uint64_t filesize)
 
 	printf("%d[%u]/%u read_f: %llu bytes @ %llu of %s\n", getpid(), procid,
 	       sn, len | 0ULL, off | 0ULL, fe->subpath);
-	nread = pread64(fe->fd, buf, len, off);
+	nread = pread(fe->fd, buf, len, off);
 	if (nread != trimmed) {
 		fprintf(stderr, "%d[%u]/%u read_f: failed to read %llu bytes @ %llu of %s\n",
 			getpid(), procid, sn, len | 0ULL, off | 0ULL,
@@ -439,7 +439,7 @@ static int __read_f(unsigned int sn, struct fent *fe, uint64_t filesize)
 	if (fe->chkfd < 0)
 		return 0;
 
-	nread2 = pread64(fe->chkfd, chkbuf, len, off);
+	nread2 = pread(fe->chkfd, chkbuf, len, off);
 	if (nread2 <= 0) {
 		fprintf(stderr, "%d[%u]/%u read_f: failed to check %llu bytes @ %llu of %s\n",
 			getpid(), procid, sn, len | 0ULL, off | 0ULL,
@@ -477,14 +477,14 @@ static int read_f(int op, unsigned int sn)
 	if (ret)
 		return ret;
 
-	fsz = lseek64(fe->fd, 0, SEEK_END);
+	fsz = lseek(fe->fd, 0, SEEK_END);
 	if (fsz <= 0) {
 		if (!fsz) {
 			printf("%d[%u]/%u %s: zero size @ %s\n",
 			       getpid(), procid, sn, __func__, fe->subpath);
 			return 0;
 		}
-		fprintf(stderr, "%d[%u]/%u %s: lseek64 %s failed %d\n",
+		fprintf(stderr, "%d[%u]/%u %s: lseek %s failed %d\n",
 			getpid(), procid, sn, __func__, fe->subpath, errno);
 		return -errno;
 	}
@@ -504,7 +504,7 @@ static int __doscan_f(unsigned int sn, const char *op, struct fent *fe,
 	for (pos = 0; pos < filesize; pos += chunksize) {
 		ssize_t nread, nread2;
 
-		nread = pread64(fe->fd, buf, chunksize, pos);
+		nread = pread(fe->fd, buf, chunksize, pos);
 
 		if (nread <= 0)
 			return -errno;
@@ -515,7 +515,7 @@ static int __doscan_f(unsigned int sn, const char *op, struct fent *fe,
 		if (fe->chkfd < 0)
 			continue;
 
-		nread2 = pread64(fe->chkfd, chkbuf, chunksize, pos);
+		nread2 = pread(fe->chkfd, chkbuf, chunksize, pos);
 		if (nread2 <= 0)
 			return -errno;
 
@@ -547,14 +547,14 @@ static int doscan_f(int op, unsigned int sn)
 	if (ret)
 		return ret;
 
-	fsz = lseek64(fe->fd, 0, SEEK_END);
+	fsz = lseek(fe->fd, 0, SEEK_END);
 	if (fsz <= 0) {
 		if (!fsz) {
 			printf("%d[%u]/%u %s: zero size @ %s\n",
 			       getpid(), procid, sn, __func__, fe->subpath);
 			return 0;
 		}
-		fprintf(stderr, "%d[%u]/%u %s: lseek64 %s failed %d\n",
+		fprintf(stderr, "%d[%u]/%u %s: lseek %s failed %d\n",
 			getpid(), procid, sn, __func__, fe->subpath, errno);
 		return -errno;
 	}
@@ -576,7 +576,7 @@ static int doscan_aligned_f(int op, unsigned int sn)
 	ret = tryopen(sn, __func__, fe);
 	if (ret)
 		return ret;
-	fsz = lseek64(fe->fd, 0, SEEK_END);
+	fsz = lseek(fe->fd, 0, SEEK_END);
 	if (fsz <= psz) {
 		if (fsz >= 0) {
 			printf("%d[%u]/%u %s: size too small %lld @ %s\n",
@@ -584,7 +584,7 @@ static int doscan_aligned_f(int op, unsigned int sn)
 			       fe->subpath);
 			return 0;
 		}
-		fprintf(stderr, "%d[%u]/%u %s: lseek64 %s failed %d\n",
+		fprintf(stderr, "%d[%u]/%u %s: lseek %s failed %d\n",
 			getpid(), procid, sn, __func__, fe->subpath, errno);
 		return -errno;
 	}
#1 lore raw

Hi Milan,

Quoted 42 lines · Milan P. Stanić

Hi,

I'm maintainer of erofs-utils for Alpine linux, distribution which use musl libc instead of glibc.

Building version 1.8.6 gives error:
------------------
Making all in contrib
make[2]: Entering directory '/home/mps/aports/community/erofs-utils/src/erofs-utils-1.8.6/contrib'
cc -DHAVE_CONFIG_H -I. -I.. -DNDEBUG -Wall -I../include -Os -fstack-clash-protection -Wformat -Werror=format-security -fno-plt -MT stress-stress.o -MD -MP -MF .deps/stress-stress.Tpo -c -o stress-stress.o test -f 'stress.c' || echo './'stress.c
stress.c: In function '__getdents_f':
stress.c:274:16: error: implicit declaration of function 'readdir64'; did you mean 'readdir_r'? [-Wimplicit-function-declaration]

   274 |         while (readdir64(dir) != NULL)
       |                ^~~~~~~~~
       |                readdir_r

stress.c:274:31: warning: comparison between pointer and integer
274 | while (readdir64(dir) != NULL)
| ^~
stress.c: In function '__read_f':
stress.c:431:17: error: implicit declaration of function 'pread64'; did you mean 'pread'? [-Wimplicit-function-declaration]

   431 |         nread = pread64(fe->fd, buf, len, off);
       |                 ^~~~~~~
       |                 pread
stress.c: In function 'read_f':
stress.c:480:15: error: implicit declaration of function 'lseek64'; did you mean 'lseek'? [-Wimplicit-function-declaration]
   480 |         fsz = lseek64(fe->fd, 0, SEEK_END);
       |               ^~~~~~~
       |               lseek

make[2]: *** [Makefile:420: stress-stress.o] Error 1
make[2]: Leaving directory '/home/mps/aports/community/erofs-utils/src/erofs-utils-1.8.6/contrib' make[1]: *** [Makefile:447: all-recursive] Error 1
make[1]: Leaving directory '/home/mps/aports/community/erofs-utils/src/erofs-utils-1.8.6'
make: *** [Makefile:379: all] Error 2

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

ERROR: erofs-utils: build failed
erofs-utils: Uninstalling dependencies...

(1/19) Purging .makedepends-erofs-utils (20250506.063719)
------------------

This is because musl use readdir, pread and lseek instead of readdir64, pread64 and lseek64.
(IMO musl does this properly)

Quoted 5 lines

Natanael Copa <[email protected]> created patch with which I build erofs-utils successfully. I'm attaching patch to this mail.

Feel free to contact me if you more information or to try some new patches.

Thanks! I will look into that later and feedback.

Thanks,
Gao Xiang

Quoted 1 line
#2 lore raw

PATCH 1/1 erofs-utils: fix build failure with musl libc

In reply to Milan P. Stanić

because musl use readdir, pread and lseek instead of readdir64, pread64 and lseek64.

Thanks-to: Natanael Copa <[email protected]>

---
Hi,

Due to the original patch lacks of the commit message and SOB, so I revised myself.

I add "_FILE_OFFSET_BITS 64" in the top since "contrib/stress.c" can be compiled individually.

Feel free to repost a formal patch if inappropriate.

Thanks,
Gao Xiang

 contrib/stress.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
contrib/stress.c +12 -11
index d8def6a..0ef8c67 100644
@@ -4,6 +4,7 @@
  *
  * Copyright (C) 2019-2025 Gao Xiang <[email protected]>
  */
+#define _FILE_OFFSET_BITS 64
 #define _GNU_SOURCE
 #include "erofs/defs.h"
 #include <errno.h>
@@ -271,7 +272,7 @@ static int __getdents_f(unsigned int sn, struct fent *fe)
 	}
 
 	dir = fdopendir(dfd);
-	while (readdir64(dir) != NULL)
+	while (readdir(dir) != NULL)
 		continue;
 	closedir(dir);
 	return 0;
@@ -428,7 +429,7 @@ static int __read_f(unsigned int sn, struct fent *fe, uint64_t filesize)
 
 	printf("%d[%u]/%u read_f: %llu bytes @ %llu of %s\n", getpid(), procid,
 	       sn, len | 0ULL, off | 0ULL, fe->subpath);
-	nread = pread64(fe->fd, buf, len, off);
+	nread = pread(fe->fd, buf, len, off);
 	if (nread != trimmed) {
 		fprintf(stderr, "%d[%u]/%u read_f: failed to read %llu bytes @ %llu of %s\n",
 			getpid(), procid, sn, len | 0ULL, off | 0ULL,
@@ -439,7 +440,7 @@ static int __read_f(unsigned int sn, struct fent *fe, uint64_t filesize)
 	if (fe->chkfd < 0)
 		return 0;
 
-	nread2 = pread64(fe->chkfd, chkbuf, len, off);
+	nread2 = pread(fe->chkfd, chkbuf, len, off);
 	if (nread2 <= 0) {
 		fprintf(stderr, "%d[%u]/%u read_f: failed to check %llu bytes @ %llu of %s\n",
 			getpid(), procid, sn, len | 0ULL, off | 0ULL,
@@ -477,14 +478,14 @@ static int read_f(int op, unsigned int sn)
 	if (ret)
 		return ret;
 
-	fsz = lseek64(fe->fd, 0, SEEK_END);
+	fsz = lseek(fe->fd, 0, SEEK_END);
 	if (fsz <= 0) {
 		if (!fsz) {
 			printf("%d[%u]/%u %s: zero size @ %s\n",
 			       getpid(), procid, sn, __func__, fe->subpath);
 			return 0;
 		}
-		fprintf(stderr, "%d[%u]/%u %s: lseek64 %s failed %d\n",
+		fprintf(stderr, "%d[%u]/%u %s: lseek %s failed %d\n",
 			getpid(), procid, sn, __func__, fe->subpath, errno);
 		return -errno;
 	}
@@ -504,7 +505,7 @@ static int __doscan_f(unsigned int sn, const char *op, struct fent *fe,
 	for (pos = 0; pos < filesize; pos += chunksize) {
 		ssize_t nread, nread2;
 
-		nread = pread64(fe->fd, buf, chunksize, pos);
+		nread = pread(fe->fd, buf, chunksize, pos);
 
 		if (nread <= 0)
 			return -errno;
@@ -515,7 +516,7 @@ static int __doscan_f(unsigned int sn, const char *op, struct fent *fe,
 		if (fe->chkfd < 0)
 			continue;
 
-		nread2 = pread64(fe->chkfd, chkbuf, chunksize, pos);
+		nread2 = pread(fe->chkfd, chkbuf, chunksize, pos);
 		if (nread2 <= 0)
 			return -errno;
 
@@ -547,14 +548,14 @@ static int doscan_f(int op, unsigned int sn)
 	if (ret)
 		return ret;
 
-	fsz = lseek64(fe->fd, 0, SEEK_END);
+	fsz = lseek(fe->fd, 0, SEEK_END);
 	if (fsz <= 0) {
 		if (!fsz) {
 			printf("%d[%u]/%u %s: zero size @ %s\n",
 			       getpid(), procid, sn, __func__, fe->subpath);
 			return 0;
 		}
-		fprintf(stderr, "%d[%u]/%u %s: lseek64 %s failed %d\n",
+		fprintf(stderr, "%d[%u]/%u %s: lseek %s failed %d\n",
 			getpid(), procid, sn, __func__, fe->subpath, errno);
 		return -errno;
 	}
@@ -576,7 +577,7 @@ static int doscan_aligned_f(int op, unsigned int sn)
 	ret = tryopen(sn, __func__, fe);
 	if (ret)
 		return ret;
-	fsz = lseek64(fe->fd, 0, SEEK_END);
+	fsz = lseek(fe->fd, 0, SEEK_END);
 	if (fsz <= psz) {
 		if (fsz >= 0) {
 			printf("%d[%u]/%u %s: size too small %lld @ %s\n",
@@ -584,7 +585,7 @@ static int doscan_aligned_f(int op, unsigned int sn)
 			       fe->subpath);
 			return 0;
 		}
-		fprintf(stderr, "%d[%u]/%u %s: lseek64 %s failed %d\n",
+		fprintf(stderr, "%d[%u]/%u %s: lseek %s failed %d\n",
 			getpid(), procid, sn, __func__, fe->subpath, errno);
 		return -errno;
 	}
Signature · 1 line
2.43.5
#3 lore raw

PATCH v2 1/1 erofs-utils: fix build failure with musl libc

In reply to Milan P. Stanić

because musl use readdir, pread and lseek instead of readdir64, pread64 and lseek64.

Thanks-to: Natanael Copa <[email protected]>

---
(Fix wrong email address typo..)

Hi,

Due to the original patch lacks of the commit message and SOB, so I revised myself.

I add "_FILE_OFFSET_BITS 64" in the top since "contrib/stress.c" can be compiled individually.

Feel free to repost a formal patch if inappropriate.

Thanks,
Gao Xiang

 contrib/stress.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
contrib/stress.c +12 -11
index d8def6a..0ef8c67 100644
@@ -4,6 +4,7 @@
  *
  * Copyright (C) 2019-2025 Gao Xiang <[email protected]>
  */
+#define _FILE_OFFSET_BITS 64
 #define _GNU_SOURCE
 #include "erofs/defs.h"
 #include <errno.h>
@@ -271,7 +272,7 @@ static int __getdents_f(unsigned int sn, struct fent *fe)
 	}
 
 	dir = fdopendir(dfd);
-	while (readdir64(dir) != NULL)
+	while (readdir(dir) != NULL)
 		continue;
 	closedir(dir);
 	return 0;
@@ -428,7 +429,7 @@ static int __read_f(unsigned int sn, struct fent *fe, uint64_t filesize)
 
 	printf("%d[%u]/%u read_f: %llu bytes @ %llu of %s\n", getpid(), procid,
 	       sn, len | 0ULL, off | 0ULL, fe->subpath);
-	nread = pread64(fe->fd, buf, len, off);
+	nread = pread(fe->fd, buf, len, off);
 	if (nread != trimmed) {
 		fprintf(stderr, "%d[%u]/%u read_f: failed to read %llu bytes @ %llu of %s\n",
 			getpid(), procid, sn, len | 0ULL, off | 0ULL,
@@ -439,7 +440,7 @@ static int __read_f(unsigned int sn, struct fent *fe, uint64_t filesize)
 	if (fe->chkfd < 0)
 		return 0;
 
-	nread2 = pread64(fe->chkfd, chkbuf, len, off);
+	nread2 = pread(fe->chkfd, chkbuf, len, off);
 	if (nread2 <= 0) {
 		fprintf(stderr, "%d[%u]/%u read_f: failed to check %llu bytes @ %llu of %s\n",
 			getpid(), procid, sn, len | 0ULL, off | 0ULL,
@@ -477,14 +478,14 @@ static int read_f(int op, unsigned int sn)
 	if (ret)
 		return ret;
 
-	fsz = lseek64(fe->fd, 0, SEEK_END);
+	fsz = lseek(fe->fd, 0, SEEK_END);
 	if (fsz <= 0) {
 		if (!fsz) {
 			printf("%d[%u]/%u %s: zero size @ %s\n",
 			       getpid(), procid, sn, __func__, fe->subpath);
 			return 0;
 		}
-		fprintf(stderr, "%d[%u]/%u %s: lseek64 %s failed %d\n",
+		fprintf(stderr, "%d[%u]/%u %s: lseek %s failed %d\n",
 			getpid(), procid, sn, __func__, fe->subpath, errno);
 		return -errno;
 	}
@@ -504,7 +505,7 @@ static int __doscan_f(unsigned int sn, const char *op, struct fent *fe,
 	for (pos = 0; pos < filesize; pos += chunksize) {
 		ssize_t nread, nread2;
 
-		nread = pread64(fe->fd, buf, chunksize, pos);
+		nread = pread(fe->fd, buf, chunksize, pos);
 
 		if (nread <= 0)
 			return -errno;
@@ -515,7 +516,7 @@ static int __doscan_f(unsigned int sn, const char *op, struct fent *fe,
 		if (fe->chkfd < 0)
 			continue;
 
-		nread2 = pread64(fe->chkfd, chkbuf, chunksize, pos);
+		nread2 = pread(fe->chkfd, chkbuf, chunksize, pos);
 		if (nread2 <= 0)
 			return -errno;
 
@@ -547,14 +548,14 @@ static int doscan_f(int op, unsigned int sn)
 	if (ret)
 		return ret;
 
-	fsz = lseek64(fe->fd, 0, SEEK_END);
+	fsz = lseek(fe->fd, 0, SEEK_END);
 	if (fsz <= 0) {
 		if (!fsz) {
 			printf("%d[%u]/%u %s: zero size @ %s\n",
 			       getpid(), procid, sn, __func__, fe->subpath);
 			return 0;
 		}
-		fprintf(stderr, "%d[%u]/%u %s: lseek64 %s failed %d\n",
+		fprintf(stderr, "%d[%u]/%u %s: lseek %s failed %d\n",
 			getpid(), procid, sn, __func__, fe->subpath, errno);
 		return -errno;
 	}
@@ -576,7 +577,7 @@ static int doscan_aligned_f(int op, unsigned int sn)
 	ret = tryopen(sn, __func__, fe);
 	if (ret)
 		return ret;
-	fsz = lseek64(fe->fd, 0, SEEK_END);
+	fsz = lseek(fe->fd, 0, SEEK_END);
 	if (fsz <= psz) {
 		if (fsz >= 0) {
 			printf("%d[%u]/%u %s: size too small %lld @ %s\n",
@@ -584,7 +585,7 @@ static int doscan_aligned_f(int op, unsigned int sn)
 			       fe->subpath);
 			return 0;
 		}
-		fprintf(stderr, "%d[%u]/%u %s: lseek64 %s failed %d\n",
+		fprintf(stderr, "%d[%u]/%u %s: lseek %s failed %d\n",
 			getpid(), procid, sn, __func__, fe->subpath, errno);
 		return -errno;
 	}
Signature · 1 line
2.43.5
#4 lore raw

Re: [PATCH v2] erofs-utils: fix build failure with musl libc

Quoted 5 lines · On Wed, 7 May 2025 21:25:48 +0800 Gao Xiang <[email protected]>…

because musl use readdir, pread and lseek instead of readdir64, pread64 and lseek64.

Thanks-to: Natanael Copa <[email protected]>

Quoted 8 lines

---
(Fix wrong email address typo..)

Hi,

Due to the original patch lacks of the commit message and SOB, so I revised myself.

Ok with me.

Quoted 3 lines

I add "_FILE_OFFSET_BITS 64" in the top since "contrib/stress.c" can be compiled individually.

This looks correct.

Thank you!

Quoted 117 lines

Feel free to repost a formal patch if inappropriate.

Thanks,
Gao Xiang

 contrib/stress.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
contrib/stress.c +12 -11
index d8def6a..0ef8c67 100644
@@ -4,6 +4,7 @@
  *
  * Copyright (C) 2019-2025 Gao Xiang <[email protected]>
  */
+#define _FILE_OFFSET_BITS 64
 #define _GNU_SOURCE
 #include "erofs/defs.h"
 #include <errno.h>
@@ -271,7 +272,7 @@ static int __getdents_f(unsigned int sn, struct fent *fe)
 	}
 
 	dir = fdopendir(dfd);
-	while (readdir64(dir) != NULL)
+	while (readdir(dir) != NULL)
 		continue;
 	closedir(dir);
 	return 0;
@@ -428,7 +429,7 @@ static int __read_f(unsigned int sn, struct fent *fe, uint64_t filesize)
 
 	printf("%d[%u]/%u read_f: %llu bytes @ %llu of %s\n", getpid(), procid,
 	       sn, len | 0ULL, off | 0ULL, fe->subpath);
-	nread = pread64(fe->fd, buf, len, off);
+	nread = pread(fe->fd, buf, len, off);
 	if (nread != trimmed) {
 		fprintf(stderr, "%d[%u]/%u read_f: failed to read %llu bytes @ %llu of %s\n",
 			getpid(), procid, sn, len | 0ULL, off | 0ULL,
@@ -439,7 +440,7 @@ static int __read_f(unsigned int sn, struct fent *fe, uint64_t filesize)
 	if (fe->chkfd < 0)
 		return 0;
 
-	nread2 = pread64(fe->chkfd, chkbuf, len, off);
+	nread2 = pread(fe->chkfd, chkbuf, len, off);
 	if (nread2 <= 0) {
 		fprintf(stderr, "%d[%u]/%u read_f: failed to check %llu bytes @ %llu of %s\n",
 			getpid(), procid, sn, len | 0ULL, off | 0ULL,
@@ -477,14 +478,14 @@ static int read_f(int op, unsigned int sn)
 	if (ret)
 		return ret;
 
-	fsz = lseek64(fe->fd, 0, SEEK_END);
+	fsz = lseek(fe->fd, 0, SEEK_END);
 	if (fsz <= 0) {
 		if (!fsz) {
 			printf("%d[%u]/%u %s: zero size @ %s\n",
 			       getpid(), procid, sn, __func__, fe->subpath);
 			return 0;
 		}
-		fprintf(stderr, "%d[%u]/%u %s: lseek64 %s failed %d\n",
+		fprintf(stderr, "%d[%u]/%u %s: lseek %s failed %d\n",
 			getpid(), procid, sn, __func__, fe->subpath, errno);
 		return -errno;
 	}
@@ -504,7 +505,7 @@ static int __doscan_f(unsigned int sn, const char *op, struct fent *fe,
 	for (pos = 0; pos < filesize; pos += chunksize) {
 		ssize_t nread, nread2;
 
-		nread = pread64(fe->fd, buf, chunksize, pos);
+		nread = pread(fe->fd, buf, chunksize, pos);
 
 		if (nread <= 0)
 			return -errno;
@@ -515,7 +516,7 @@ static int __doscan_f(unsigned int sn, const char *op, struct fent *fe,
 		if (fe->chkfd < 0)
 			continue;
 
-		nread2 = pread64(fe->chkfd, chkbuf, chunksize, pos);
+		nread2 = pread(fe->chkfd, chkbuf, chunksize, pos);
 		if (nread2 <= 0)
 			return -errno;
 
@@ -547,14 +548,14 @@ static int doscan_f(int op, unsigned int sn)
 	if (ret)
 		return ret;
 
-	fsz = lseek64(fe->fd, 0, SEEK_END);
+	fsz = lseek(fe->fd, 0, SEEK_END);
 	if (fsz <= 0) {
 		if (!fsz) {
 			printf("%d[%u]/%u %s: zero size @ %s\n",
 			       getpid(), procid, sn, __func__, fe->subpath);
 			return 0;
 		}
-		fprintf(stderr, "%d[%u]/%u %s: lseek64 %s failed %d\n",
+		fprintf(stderr, "%d[%u]/%u %s: lseek %s failed %d\n",
 			getpid(), procid, sn, __func__, fe->subpath, errno);
 		return -errno;
 	}
@@ -576,7 +577,7 @@ static int doscan_aligned_f(int op, unsigned int sn)
 	ret = tryopen(sn, __func__, fe);
 	if (ret)
 		return ret;
-	fsz = lseek64(fe->fd, 0, SEEK_END);
+	fsz = lseek(fe->fd, 0, SEEK_END);
 	if (fsz <= psz) {
 		if (fsz >= 0) {
 			printf("%d[%u]/%u %s: size too small %lld @ %s\n",
@@ -584,7 +585,7 @@ static int doscan_aligned_f(int op, unsigned int sn)
 			       fe->subpath);
 			return 0;
 		}
-		fprintf(stderr, "%d[%u]/%u %s: lseek64 %s failed %d\n",
+		fprintf(stderr, "%d[%u]/%u %s: lseek %s failed %d\n",
 			getpid(), procid, sn, __func__, fe->subpath, errno);
 		return -errno;
 	}
#5 lore raw

Re: [PATCH v2] erofs-utils: fix build failure with musl libc

Quoted 12 lines · Natanael Copa
Quoted 9 lines · On Wed, 7 May 2025 21:25:48 +0800 Gao Xiang <[email protected]>…

because musl use readdir, pread and lseek instead of readdir64, pread64 and lseek64.

Thanks-to: Natanael Copa <[email protected]>

---
(Fix wrong email address typo..)

Quoted 6 lines
Quoted 4 lines

Hi,

Due to the original patch lacks of the commit message and SOB, so I revised myself.

Ok with me.

Also ok with me.

Quoted 126 lines
Quoted 2 lines

I add "_FILE_OFFSET_BITS 64" in the top since "contrib/stress.c" can be compiled individually.

This looks correct.

Thank you!

Quoted 117 lines

Feel free to repost a formal patch if inappropriate.

Thanks,
Gao Xiang

 contrib/stress.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
contrib/stress.c +12 -11
index d8def6a..0ef8c67 100644
@@ -4,6 +4,7 @@
  *
  * Copyright (C) 2019-2025 Gao Xiang <[email protected]>
  */
+#define _FILE_OFFSET_BITS 64
 #define _GNU_SOURCE
 #include "erofs/defs.h"
 #include <errno.h>
@@ -271,7 +272,7 @@ static int __getdents_f(unsigned int sn, struct fent *fe)
 	}
 
 	dir = fdopendir(dfd);
-	while (readdir64(dir) != NULL)
+	while (readdir(dir) != NULL)
 		continue;
 	closedir(dir);
 	return 0;
@@ -428,7 +429,7 @@ static int __read_f(unsigned int sn, struct fent *fe, uint64_t filesize)
 
 	printf("%d[%u]/%u read_f: %llu bytes @ %llu of %s\n", getpid(), procid,
 	       sn, len | 0ULL, off | 0ULL, fe->subpath);
-	nread = pread64(fe->fd, buf, len, off);
+	nread = pread(fe->fd, buf, len, off);
 	if (nread != trimmed) {
 		fprintf(stderr, "%d[%u]/%u read_f: failed to read %llu bytes @ %llu of %s\n",
 			getpid(), procid, sn, len | 0ULL, off | 0ULL,
@@ -439,7 +440,7 @@ static int __read_f(unsigned int sn, struct fent *fe, uint64_t filesize)
 	if (fe->chkfd < 0)
 		return 0;
 
-	nread2 = pread64(fe->chkfd, chkbuf, len, off);
+	nread2 = pread(fe->chkfd, chkbuf, len, off);
 	if (nread2 <= 0) {
 		fprintf(stderr, "%d[%u]/%u read_f: failed to check %llu bytes @ %llu of %s\n",
 			getpid(), procid, sn, len | 0ULL, off | 0ULL,
@@ -477,14 +478,14 @@ static int read_f(int op, unsigned int sn)
 	if (ret)
 		return ret;
 
-	fsz = lseek64(fe->fd, 0, SEEK_END);
+	fsz = lseek(fe->fd, 0, SEEK_END);
 	if (fsz <= 0) {
 		if (!fsz) {
 			printf("%d[%u]/%u %s: zero size @ %s\n",
 			       getpid(), procid, sn, __func__, fe->subpath);
 			return 0;
 		}
-		fprintf(stderr, "%d[%u]/%u %s: lseek64 %s failed %d\n",
+		fprintf(stderr, "%d[%u]/%u %s: lseek %s failed %d\n",
 			getpid(), procid, sn, __func__, fe->subpath, errno);
 		return -errno;
 	}
@@ -504,7 +505,7 @@ static int __doscan_f(unsigned int sn, const char *op, struct fent *fe,
 	for (pos = 0; pos < filesize; pos += chunksize) {
 		ssize_t nread, nread2;
 
-		nread = pread64(fe->fd, buf, chunksize, pos);
+		nread = pread(fe->fd, buf, chunksize, pos);
 
 		if (nread <= 0)
 			return -errno;
@@ -515,7 +516,7 @@ static int __doscan_f(unsigned int sn, const char *op, struct fent *fe,
 		if (fe->chkfd < 0)
 			continue;
 
-		nread2 = pread64(fe->chkfd, chkbuf, chunksize, pos);
+		nread2 = pread(fe->chkfd, chkbuf, chunksize, pos);
 		if (nread2 <= 0)
 			return -errno;
 
@@ -547,14 +548,14 @@ static int doscan_f(int op, unsigned int sn)
 	if (ret)
 		return ret;
 
-	fsz = lseek64(fe->fd, 0, SEEK_END);
+	fsz = lseek(fe->fd, 0, SEEK_END);
 	if (fsz <= 0) {
 		if (!fsz) {
 			printf("%d[%u]/%u %s: zero size @ %s\n",
 			       getpid(), procid, sn, __func__, fe->subpath);
 			return 0;
 		}
-		fprintf(stderr, "%d[%u]/%u %s: lseek64 %s failed %d\n",
+		fprintf(stderr, "%d[%u]/%u %s: lseek %s failed %d\n",
 			getpid(), procid, sn, __func__, fe->subpath, errno);
 		return -errno;
 	}
@@ -576,7 +577,7 @@ static int doscan_aligned_f(int op, unsigned int sn)
 	ret = tryopen(sn, __func__, fe);
 	if (ret)
 		return ret;
-	fsz = lseek64(fe->fd, 0, SEEK_END);
+	fsz = lseek(fe->fd, 0, SEEK_END);
 	if (fsz <= psz) {
 		if (fsz >= 0) {
 			printf("%d[%u]/%u %s: size too small %lld @ %s\n",
@@ -584,7 +585,7 @@ static int doscan_aligned_f(int op, unsigned int sn)
 			       fe->subpath);
 			return 0;
 		}
-		fprintf(stderr, "%d[%u]/%u %s: lseek64 %s failed %d\n",
+		fprintf(stderr, "%d[%u]/%u %s: lseek %s failed %d\n",
 			getpid(), procid, sn, __func__, fe->subpath, errno);
 		return -errno;
 	}