mapleft的笔记 https://bbs.21ic.com/?41444 [收藏] [复制] [RSS]

日志

nuc980 etx4文件系统格式化工具 e2fsprogs 编译

已有 809 次阅读2020-2-17 15:13 |个人分类:工蚁手记|系统分类:兴趣爱好

我的板子上挂载MMC 设备需要使用EXT4 文件系统, 需要mkfs.ext4  这个工具去格式化 SD卡或者是EMMC
进入buildroot , make menuconfig
打开Target packages 下的 Filesystem and flash utilities 菜单

开启e2fsprogs 

然后就make 
checking pkg-config is at least version 0.9.0... yes
checking for blkid_get_cache in -lblkid... no
configure: error: external blkid library not found
package/pkg-generic.mk:228: recipe for target '/usr/nuc980/buildroot-2019.02.9/output/build/e2fsprogs-1.45.4/.stamp_configured' failed
make: *** [/usr/nuc980/buildroot-2019.02.9/output/build/e2fsprogs-1.45.4/.stamp_configured] Error 1

你妹的,报个configure: error: external blkid library not found 这咋整, 一番瞎搞无果过后,转到bulidroot 下的 output/bulid/e2fsprogs-1.45.4目录下

我决定手工编译干它
控制台
建立编译目录
mkdir Build
  1. cd ./Build
  2. ../configure  --host=arm-linux --prefix=$PWD CC=/usr/local/arm_linux_4.8/bin/arm-nuvoton-linux-uclibceabi-gcc

  3. /usr/local/arm_linux_4.8/ 是我的gcc工具链
然后make
make[2]: Entering directory '/usr/nuc980/buildroot-2019.02.9/output/build/e2fsprogs-1.45.4/Build/misc'
        CC ../../misc/e4defrag.c
../../misc/e4defrag.c:202:2: 错误:#error neither fallocate64 nor posix_fallocate64 available!
 #error neither fallocate64 nor posix_fallocate64 available!
  ^
Makefile:460: recipe for target 'e4defrag.o' failed
make[2]: *** [e4defrag.o] Error 1
make[2]: Leaving directory '/usr/nuc980/buildroot-2019.02.9/output/build/e2fsprogs-1.45.4/Build/misc'
Makefile:434: recipe for target 'all-progs-recursive' failed
make[1]: *** [all-progs-recursive] Error 1
make[1]: Leaving directory '/usr/nuc980/buildroot-2019.02.9/output/build/e2fsprogs-1.45.4/Build'
Makefile:367: recipe for target 'all' failed
make: *** [all] Error 2

又爆出../../misc/e4defrag.c:202:2: 错误:#error neither fallocate64 nor posix_fallocate64 available!
这个错误, google 后,找到个补丁
From: "Anthony G. Basile" <blueness@xxxxxxxxxx>

Commit 58229aaf removed the broken fallback syscall for fallocate64() on systems
where the latter is unavailable.  However, it did not provide a substitute,
so the build fails on uClibc which does not have fallocate64(), but does have
posix_fallocate64().  Since fallocate64() is called with mode=0, we can make use
of posix_fallocate64() on such systems.

See `man 2 fallocate` and `man 3 posix_fallocate`.
---
configure       |  2 +-
configure.in    |  1 +
lib/config.h.in |  3 +++
misc/e4defrag.c | 10 +++++++---
4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 6c503aa..9853bc0 100755
--- a/configure
+++ b/configure
@@ -13071,7 +13071,7 @@ if test "$ac_res" != no; then :
fi

fi
-for ac_func in          __secure_getenv         backtrace         blkid_probe_get_topology         blkid_probe_enable_partitions         chflags         fadvise64         fallocate         fallocate64         fchown         fdatasync         fstat64         ftruncate64         futimes         getcwd         getdtablesize         getmntinfo         getpwuid_r         getrlimit         getrusage         jrand48         llistxattr         llseek         lseek64         mallinfo         mbstowcs         memalign         mempcpy         mmap         msync         nanosleep         open64         pathconf         posix_fadvise         posix_fadvise64         posix_memalign         prctl         secure_getenv         setmntent         setresgid         setresuid         snprintf         srandom         stpcpy         strcasecmp         strdup         strnlen         strptime         strtoull         sync_file_range         sysconf         usleep         utime         valloc
+for ac_func in          __secure_getenv         backtrace         blkid_probe_get_topology         blkid_probe_enable_partitions         chflags         fadvise64         fallocate         fallocate64         fchown         fdatasync         fstat64         ftruncate64         futimes         getcwd         getdtablesize         getmntinfo         getpwuid_r         getrlimit         getrusage         jrand48         llistxattr         llseek         lseek64         mallinfo         mbstowcs         memalign         mempcpy         mmap         msync         nanosleep         open64         pathconf         posix_fadvise         posix_fadvise64         posix_fallocate64         posix_memalign         prctl         secure_getenv         setmntent         setresgid         setresuid         snprintf         srandom         stpcpy         strcasecmp         strdup         strnlen         strptime         strtoull         sync_file_range         sysconf         usleep         utime         valloc
do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/configure.in b/configure.in
index 67e5453..48fa099 100644
--- a/configure.in
+++ b/configure.in
@@ -1113,6 +1113,7 @@ AC_CHECK_FUNCS(m4_flatten([
        pathconf
        posix_fadvise
        posix_fadvise64
+        posix_fallocate64
        posix_memalign
        prctl
        secure_getenv
diff --git a/lib/config.h.in b/lib/config.h.in
index 12a609a..3d6796d 100644
--- a/lib/config.h.in
+++ b/lib/config.h.in
@@ -331,6 +331,9 @@
/* Define to 1 if you have the `posix_fadvise64' function. */
#undef HAVE_POSIX_FADVISE64

+/* Define to 1 if you have the `posix_fallocate64' function. */
+#undef HAVE_POSIX_FALLOCATE64
+
/* Define to 1 if you have the `posix_memalign' function. */
#undef HAVE_POSIX_MEMALIGN

diff --git a/misc/e4defrag.c b/misc/e4defrag.c
index d0eac60..ba16a76 100644
--- a/misc/e4defrag.c
+++ b/misc/e4defrag.c
@@ -197,9 +197,9 @@ static struct frag_statistic_ino        frag_rank[SHOW_FRAG_FILES];
#error sync_file_range not available!
#endif /* ! HAVE_SYNC_FILE_RANGE */

-#ifndef HAVE_FALLOCATE64
-#error fallocate64 not available!
-#endif /* ! HAVE_FALLOCATE64 */
+#if !defined(HAVE_FALLOCATE64) && !defined(HAVE_POSIX_FALLOCATE64)
+#error neither fallocate64 nor posix_fallocate64 available!
+#endif /* ! HAVE_FALLOCATE64 && ! HAVE_POSIX_FALLOCATE64 */

/*
  * get_mount_point() -        Get device's mount point.
@@ -1554,7 +1554,11 @@ static int file_defrag(const char *file, const struct stat64 *buf,
        /* Allocate space for donor inode */
        orig_group_tmp = orig_group_head;
        do {
+#ifdef HAVE_FALLOCATE64
                ret = fallocate64(donor_fd, 0,
+#else /* HAVE_POSIX_FALLOCATE64 */
+                ret = posix_fallocate64(donor_fd,
+#endif
                  (loff_t)orig_group_tmp->start->data.logical * block_size,
                  (loff_t)orig_group_tmp->len * block_size);
                if (ret < 0) {
--
1.8.5.5

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html补了后,重新make然后 make install 在Bulid 目录下的sbin中 找到需要的mkfs.ext4

QQ交流群:761781147

路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)