0

我打算通过 NDK 1.7 将 fuse 2.8.7 移植到 android 中,首先,我应该通过 android 工具链构建 fuse 项目,然后将其作为模块注入到 android 内核中。但不幸的是,我在编译过程中遇到了一些问题。以下是详细信息: 1:在 fuse 2.8.7 项目文件夹中,我构建了一个 shell 脚本,如下所示:

#!/bin/sh
# Compiles fftw3 for Android
export NDK_ROOT="/home/kaiwii/android_related/android-ndk-r7b"
export PATH="$NDK_ROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/:$PATH"
export SYS_ROOT="$NDK_ROOT/platforms/android-14/arch-arm/"
export CC="arm-linux-androideabi-gcc --sysroot=$SYS_ROOT"
export LD="arm-linux-androideabi-ld"
export AR="arm-linux-androideabi-ar"
export RANLIB="arm-linux-androideabi-ranlib"
export STRIP="arm-linux-androideabi-strip"

./configure --host=arm-eabi  LIBS="-lc -lgcc"

make
make install

exit 0

2、编译项目,提示如下错误:

In file included from fuse_i.h:9,
                 from fuse.c:13:
../include/fuse.h:33:25: error: sys/statvfs.h: No such file or directory
In file included from fuse_i.h:9,
                 from fuse.c:13:
../include/fuse.h:207: warning: 'struct statvfs' declared inside parameter list
../include/fuse.h:207: warning: its scope is only this definition or declaration, which is probably not what you want
../include/fuse.h:721: warning: 'struct statvfs' declared inside parameter list
In file included from fuse_i.h:10,
                 from fuse.c:13:
../include/fuse_lowlevel.h:1021: warning: 'struct statvfs' declared inside parameter list
In file included from fuse.c:13:
fuse_i.h:29: error: expected specifier-qualifier-list before 'pthread_mutex_t'
fuse_i.h:60: error: expected specifier-qualifier-list before 'pthread_mutex_t'
In file included from fuse.c:18:
../include/fuse_compat.h:32: warning: 'struct statvfs' declared inside parameter list
fuse.c:1036: warning: 'struct statvfs' declared inside parameter list
fuse.c: In function 'convert_statfs_compat':
fuse.c:1038: error: dereferencing pointer to incomplete type
fuse.c:1039: error: dereferencing pointer to incomplete type
fuse.c:1040: error: dereferencing pointer to incomplete type
fuse.c:1041: error: dereferencing pointer to incomplete type
fuse.c:1042: error: dereferencing pointer to incomplete type
fuse.c:1043: error: dereferencing pointer to incomplete type
fuse.c:1044: error: dereferencing pointer to incomplete type
fuse.c: At top level:
fuse.c:1047: warning: 'struct statvfs' declared inside parameter list
fuse.c: In function 'convert_statfs_old':
fuse.c:1049: error: dereferencing pointer to incomplete type
fuse.c:1050: error: dereferencing pointer to incomplete type
fuse.c:1051: error: dereferencing pointer to incomplete type
fuse.c:1052: error: dereferencing pointer to incomplete type
fuse.c:1053: error: dereferencing pointer to incomplete type
fuse.c:1054: error: dereferencing pointer to incomplete type
fuse.c:1055: error: dereferencing pointer to incomplete type
fuse.c: At top level:
fuse.c:1059: warning: 'struct statvfs' declared inside parameter list
fuse.c: In function 'fuse_compat_statfs':
fuse.c:1064: warning: passing argument 2 of 'fs->op.statfs' from incompatible pointer type
fuse.c:1064: note: expected 'struct statvfs *' but argument is of type 'struct statvfs *'
fuse.c:1070: warning: passing argument 2 of 'convert_statfs_old' from incompatible pointer type
fuse.c:1047: note: expected 'struct statvfs *' but argument is of type 'struct statvfs *'
fuse.c:1077: warning: passing argument 2 of 'convert_statfs_compat' from incompatible pointer type
fuse.c:1035: note: expected 'struct statvfs *' but argument is of type 'struct statvfs *'
fuse.c: At top level:
fuse.c:1376: warning: 'struct statvfs' declared inside parameter list
fuse.c:1376: error: conflicting types for 'fuse_fs_statfs'
../include/fuse.h:721: note: previous declaration of 'fuse_fs_statfs' was here
fuse.c: In function 'fuse_fs_statfs':
fuse.c:1383: warning: passing argument 3 of 'fuse_compat_statfs' from incompatible pointer type
fuse.c:1058: note: expected 'struct statvfs *' but argument is of type 'struct statvfs *'
fuse.c:1385: error: dereferencing pointer to incomplete type
fuse.c:1386: error: dereferencing pointer to incomplete type
fuse.c: In function 'fuse_lib_statfs':
fuse.c:2878: error: storage size of 'buf' isn't known
fuse.c:2878: warning: unused variable 'buf'
fuse.c: In function 'locks_insert':
fuse.c:3056: warning: comparison is always true due to limited range of data type
fuse.c: In function 'lock_to_flock':
fuse.c:3138: warning: comparison is always false due to limited range of data type
make[1]: *** [fuse.lo] Error 1
make[1]: Leaving directory `/home/kaiwii/test/fuse-2.8.7/lib'
make: *** [all-recursive] Error 1
Making install in include
make[1]: Entering directory `/home/kaiwii/test/fuse-2.8.7/include'
make[2]: Entering directory `/home/kaiwii/test/fuse-2.8.7/include'
make[2]: Nothing to be done for `install-exec-am'.
test -z "/usr/local/include/fuse" || /bin/mkdir -p "/usr/local/include/fuse"
 /usr/bin/install -c -m 644 fuse.h fuse_compat.h fuse_common.h fuse_common_compat.h fuse_lowlevel.h fuse_lowlevel_compat.h fuse_opt.h cuse_lowlevel.h '/usr/local/include/fuse'
test -z "/usr/local/include" || /bin/mkdir -p "/usr/local/include"
 /usr/bin/install -c -m 644 old/fuse.h ulockmgr.h '/usr/local/include'
make[2]: Leaving directory `/home/kaiwii/test/fuse-2.8.7/include'
make[1]: Leaving directory `/home/kaiwii/test/fuse-2.8.7/include'
Making install in lib
make[1]: Entering directory `/home/kaiwii/test/fuse-2.8.7/lib'
/bin/bash ../libtool --tag=CC   --mode=compile arm-linux-androideabi-gcc --sysroot=/home/kaiwii/android_related/android-ndk-r7b/platforms/android-14/arch-arm/ -DHAVE_CONFIG_H -I. -I../include  -I../include -DFUSERMOUNT_DIR=\"/usr/local/bin\" -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DFUSE_USE_VERSION=26   -Wall -W -Wno-sign-compare -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings -g -O2 -fno-strict-aliasing -MT fuse.lo -MD -MP -MF .deps/fuse.Tpo -c -o fuse.lo fuse.c
libtool: compile:  arm-linux-androideabi-gcc --sysroot=/home/kaiwii/android_related/android-ndk-r7b/platforms/android-14/arch-arm/ -DHAVE_CONFIG_H -I. -I../include -I../include -DFUSERMOUNT_DIR=\"/usr/local/bin\" -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DFUSE_USE_VERSION=26 -Wall -W -Wno-sign-compare -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings -g -O2 -fno-strict-aliasing -MT fuse.lo -MD -MP -MF .deps/fuse.Tpo -c fuse.c -o fuse.o
In file included from fuse_i.h:9,
                 from fuse.c:13:
../include/fuse.h:33:25: error: sys/statvfs.h: No such file or directory
In file included from fuse_i.h:9,
                 from fuse.c:13:
../include/fuse.h:207: warning: 'struct statvfs' declared inside parameter list
../include/fuse.h:207: warning: its scope is only this definition or declaration, which is probably not what you want
../include/fuse.h:721: warning: 'struct statvfs' declared inside parameter list
In file included from fuse_i.h:10,
                 from fuse.c:13:
../include/fuse_lowlevel.h:1021: warning: 'struct statvfs' declared inside parameter list
In file included from fuse.c:13:
fuse_i.h:29: error: expected specifier-qualifier-list before 'pthread_mutex_t'
fuse_i.h:60: error: expected specifier-qualifier-list before 'pthread_mutex_t'
In file included from fuse.c:18:
../include/fuse_compat.h:32: warning: 'struct statvfs' declared inside parameter list
fuse.c:1036: warning: 'struct statvfs' declared inside parameter list
fuse.c: In function 'convert_statfs_compat':
fuse.c:1038: error: dereferencing pointer to incomplete type
fuse.c:1039: error: dereferencing pointer to incomplete type
fuse.c:1040: error: dereferencing pointer to incomplete type
fuse.c:1041: error: dereferencing pointer to incomplete type
fuse.c:1042: error: dereferencing pointer to incomplete type
fuse.c:1043: error: dereferencing pointer to incomplete type
fuse.c:1044: error: dereferencing pointer to incomplete type
fuse.c: At top level:
fuse.c:1047: warning: 'struct statvfs' declared inside parameter list
fuse.c: In function 'convert_statfs_old':
fuse.c:1049: error: dereferencing pointer to incomplete type
fuse.c:1050: error: dereferencing pointer to incomplete type
fuse.c:1051: error: dereferencing pointer to incomplete type
fuse.c:1052: error: dereferencing pointer to incomplete type
fuse.c:1053: error: dereferencing pointer to incomplete type
fuse.c:1054: error: dereferencing pointer to incomplete type
fuse.c:1055: error: dereferencing pointer to incomplete type
fuse.c: At top level:
fuse.c:1059: warning: 'struct statvfs' declared inside parameter list
fuse.c: In function 'fuse_compat_statfs':
fuse.c:1064: warning: passing argument 2 of 'fs->op.statfs' from incompatible pointer type
fuse.c:1064: note: expected 'struct statvfs *' but argument is of type 'struct statvfs *'
fuse.c:1070: warning: passing argument 2 of 'convert_statfs_old' from incompatible pointer type
fuse.c:1047: note: expected 'struct statvfs *' but argument is of type 'struct statvfs *'
fuse.c:1077: warning: passing argument 2 of 'convert_statfs_compat' from incompatible pointer type
fuse.c:1035: note: expected 'struct statvfs *' but argument is of type 'struct statvfs *'
fuse.c: At top level:
fuse.c:1376: warning: 'struct statvfs' declared inside parameter list
fuse.c:1376: error: conflicting types for 'fuse_fs_statfs'
../include/fuse.h:721: note: previous declaration of 'fuse_fs_statfs' was here
fuse.c: In function 'fuse_fs_statfs':
fuse.c:1383: warning: passing argument 3 of 'fuse_compat_statfs' from incompatible pointer type
fuse.c:1058: note: expected 'struct statvfs *' but argument is of type 'struct statvfs *'
fuse.c:1385: error: dereferencing pointer to incomplete type
fuse.c:1386: error: dereferencing pointer to incomplete type
fuse.c: In function 'fuse_lib_statfs':
fuse.c:2878: error: storage size of 'buf' isn't known
fuse.c:2878: warning: unused variable 'buf'
fuse.c: In function 'locks_insert':
fuse.c:3056: warning: comparison is always true due to limited range of data type
fuse.c: In function 'lock_to_flock':
fuse.c:3138: warning: comparison is always false due to limited range of data type
make[1]: *** [fuse.lo] Error 1
make[1]: Leaving directory `/home/kaiwii/test/fuse-2.8.7/lib'
make: *** [install-recursive] Error 1
4

2 回答 2

4

尝试通过以下方式替换 fuse.h 中包含的 sys/statvfs.h:

#ifndef ANDROID
#  include <sys/statvfs.h>
#else
#  include <sys/vfs.h>
#  define statvfs statfs
#endif
于 2012-09-27T14:35:03.787 回答
0

我相信您需要 android 内核头文件来构建模块,并且 NDK 绝对不包含android 内核头文件。看看安卓NDK能编译内核模块源码吗?有关为 Android 编译内核模块的更多信息的链接。但是请注意。由于信息较少(例如,哪个编译器编译了您正在构建模块的内核等),与 Linux 相比,这是一个为 Android 编译内核模块的世界。

于 2012-05-03T10:39:40.897 回答