如何在Solaris 10上成功编译lsof?

Solaris的lsof(例如Blastwave或sunfreeware)的预编译包不显示端口打开,例如使用选项“-Pni”时。 lsof的创造者的智慧是我们自己编译lsof。 tar包,configuration等与大多数可以从源代码编译的开源软件包大不相同。 我在包装内的线索很less,以了解我的构build尝试有什么问题。

我有Sun Studio 11提供C编译器。 还安装了Gcc 3.4.5

系统是sparc,所有文件系统上都带有ZFS。 OS是Solaris 10,U7。

uname -a SunOS myhostname 5.10 Generic_141444-09 sun4u sparc SUNW,Sun-Fire-280R 

源代码是4.82。 我使用默认选项和ZFS支持进行configuration。

无论是cc还是gcc,运行make时的失败都是相似的:

 gcc -Dsolaris=100000 -DHASPR_GWINDOWS -m64 -DHASIPv6 -DHASSOUXSOUA -DHAS_IPCLASSIFIER_H -DHAS_CRED_IMPL_H -DHAS_V_PATH -DHASZONES -DHAS_ZFS=1 -DZFS_VERS=15 -DHASUTMPX -DHAS_VSOCK -DHAS_STRFTIME -DLSOF_VSTR=\"5.10\" -O -c dnode.c dnode.c: In function `process_node': dnode.c:2082: error: structure has no member named `pcfs_entps' *** Error code 1 make: Fatal error: Command failed for target `dnode.o' 

我在几个月前用4.77编译了一个非ZFS系统,但我不记得如何。

lsof FAQ指出,必要的头文件不是Sun提供的,在下面引用的部分继续build议如何从Open Solaris获得它们以及可能遇到的其他问题。

17.27 Solaris 10 ZFS问题[原文]

17.27.1为什么Configure要求提供ZFS头文件的位置?

 To provide ZFS support when lsof is compiled it needs to have access to the definitions of ZFS structures used by the kernel. Those definitions are contained in header files that Sun does not distribute with Solaris 10. 

我发现这个引用的问题,从编译错误的一部分search

http://unix.derkeiler.com/Newsgroups/comp.unix.solaris/2009-07/msg00575.html

没有必要从OpenSolaris或其他地方获取任何头文件。 4.83的beta版本在我的Sparc ZFS框上工作,默认为configuration脚本。

我现在在Solaris 10上运行lsof -Pni。

当你在等待真正的答案时,你可以试试pcp来替代solaris上的lsof。 它是围绕非常有用的solaris命令文件构build的。