6

编译 Android 版 lsof

 3 years ago
source link: https://blog.lilydjwg.me/2014/3/8/lsof-for-android-compiled.43363.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

编译 Android 版 lsof

本文来自依云's Blog,转载请注明。

Android 自带的那个 lsof 实际上是 toolbox 里的,功能十分单一,除了显示出所有进程的所有打开的文件外就什么都不能做,连说明也没有 :-( 于是为了 htop 用着爽一点,还是自己编译一个吧。

首先弄个 GNU 工具链。Android NDK 的没有 tcp.h 头文件,会报 TCP_LISTEN 等标识符未定义。

  • 我使用 crosstool-NG 1.19.0 编译的 gcc 4.8.1。适用于 Arch Linux x86_64。第一次编译工具链,没想到在 crosstool-NG 的帮助下一次就编译好了,所以是未作静态链接的版本,其它版本的 Linux 可能无法运行。
  • zshaolin 使用的工具链 gcc 4.4.6。它是使用 crosstool-NG 1.13.2 编译的。

编译过程。使用了静态链接,最终文件大小 741K。

path+=/ldata/txtfiles/soft/arm-lilydjwg-linux-gnueabi/bin
LSOF_CC=arm-lilydjwg-linux-gnueabi-gcc LSOF_CFGF='-DHAS_STRFTIME -DHASNORPC_H -DGLIBCV' LSOF_VERS=3.0.8 ./Configure -n linux
make
arm-lilydjwg-linux-gnueabi-gcc -o lsof -static dfile.o dmnt.o dnode.o dproc.o dsock.o dstore.o arg.o main.o misc.o node.o print.o proc.o store.o usage.o util.o -L./lib -llsof
arm-lilydjwg-linux-gnueabi-strip lsof

编译好的 lsof 可由此下载


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK