首页 > 技术知识 > 正文

Busybox生成后是按照busybox.links来生成链接也就是最后_install里面生成的所有软链接怎样去添加自定义命令并自动生成软连接呢,只需要该懂4个地方即可,假设我们要添加的命令为lsscsi,文件名为lsscsi.c添加在util-linux目录里然后按照以下4个地方做相应的修改。

以下所有的目录为相对路径相对于busybox的根目录:

第一个地方是include/usage.h是添加帮助的地方 #define lspci_full_usage “\n\n” \ “List all PCI devices” \ “\n” \ “\n -m Parseable output” \ “\n -k Show driver” \ #define lsusb_trivial_usage NOUSAGE_STR // 这个是我们的添加的的,我这里去掉了直接留空 #define lsusb_full_usage “” #define lsscsi_trivial_usage NOUSAGE_STR #define lsscsi_full_usage “” #if ENABLE_FEATURE_MAKEDEVS_LEAF #define makedevs_trivial_usage \ “NAME TYPE MAJOR MINOR FIRST LAST [s]”

第二个地方添加 include/applets.h

IF_LSPCI(APPLET(lspci, _BB_DIR_SBIN, _BB_SUID_DROP)) IF_LSSCSI(APPLET(lsscsi, _BB_DIR_SBIN, _BB_SUID_DROP)) //这里指定软连接的路径 IF_LSUSB(APPLET(lsusb, _BB_DIR_SBIN, _BB_SUID_DROP))

第3个地方添加 util-linux/Config.in

config LSPCI bool “lspci” default n help lspci is a utility for displaying information about PCI buses in the system and devices connected to them. This version uses sysfs (/sys/bus/pci/devices) only. config LSSCSI #new add bool “lsscsi” default y help lsscsi is a utility program for listing SCSI devices and hosts (HBAs) in the Linux operating system. For more information, please see docs/lsscsi.txt config LSUSB bool “lsusb” default n help

第4个地方添加util-linux/Kbuild

lib-$(CONFIG_LSPCI) += lspci.o lib-$(CONFIG_LSSCSI) += lsscsi.o //new add lib-$(CONFIG_LSUSB) += lsusb.o

猜你喜欢