Android的toolbox及busybox,toybox

1 toolbox

看 system/core $ gitk toolbox/

toolbox应该是在5.0及5.0以前使用,14年年底后google已停止维护


2 toybox

6.0以后执行ls等基础linux命令都执行了toybox

What is Toybox
  - Fresh implementation of linux/android command line, BSD licensed.
    - Draws from Posix, LSB, LFS, toolbox, bash man page, etc.

  - why not extend toolbox/bionic instead of replace?
    - because there's nothing there
      - intentional locked down system. 1 billion unadministered broadband.
        - just enough to run dalvik. (The new ROM BASIC.)
        - Must outgrow dalvik to run native code.
      - linux containers, union mounts
        - vm vs container
          - chroot on steroids. Own pids, mounts, network routing...
          - systematic nesting of unix permissions
        - problem: LXC is not ripe yet, and vanilla ahead of android.
          - vanilla's working on this
          - LXC is just one userspace control package for kernel infrastructure
            - containers: namespaces, cgroups, mount flags...
        - Not a fan of selinux, apparmor, capability bits
          - you don't get "watertight" by plugging the holes in a collander.
          - system's hard enough to administer already, so you make it
            _more_ complicated? Micromanaging apps.
          - Ken Thompson said a file is a sequence of bytes. If you need
            extended attributes, you're doing it wrong.
        - Containers (namespaces, cgroups) are unix way to do this.
          Nest the whole system so each container has its own root.

          - This is a judgement call, I could be argued out of it by users who
            really want this stuff and can make a good case for it. But
            signifcant complexity cost. And selinux is not a substitute for
            "nothing outside dalvik to exploit" minimalism.


What does toybox implement?
- android toolbox - lives in "android core" git. - triage - container support for security - unshare - examine lxc. (Fix chroot in kernel.) - google has epic "not invented here" syndrome - install toybox, put first in $PATH. Leave toybox alone. - Eliminating need for toolbox won't eliminate safety blanket.

3 busybox

busybox在android上位于xbin,是android xbin下额外的工具,不是ls等默认指向的

The Different between android folders(bin, xbin, sbin)

http://stackoverflow.com/questions/26801895/the-different-between-android-foldersbin-xbin-sbin

1 ] /system is the main Android directory for storing immutable components generated by the build of the AOSP. This includes native binaries, native libraries, framework packages, and stock apps. It’s usually mounted read-only from a separate image from the root file system, which is itself mounted from a RAM disk image.

2 ] Android also includes many directories commonly found in any Linux system, such as /dev, /proc, /sys, /sbin, /root, /mnt, and /etc. These directories often serve similar if not identical purposes to the ones they serve on any Linux system, although they are very often trimmed down, as is the case of /sbin and /etc, and in some cases are empty, such as /root.

3 ] More than 150 command-line utilities are scattered throughout Android’s root file system./system/bin contains the majority of them, but some “extras” are in /system/xbin, and a handful are in /sbin.

4 ] /sbin dir In Linux, this would hold binaries essential to the system administrator. InAndroid, itcontains only ueventd and adbd.

5 ] /bin dir All native binaries and daemons built as part of the AOSP. All modules built with BUILD_EXE CUTABLE are here. The only exception is adbd, which has the LOCAL_MODULE_PATH set to /sbin and is therefore installed there instead.

6 ] /xbin dir “Extra” binaries generated by some of the packages that are built within the AOSP but aren’t essential to the system’s operation.

Thanks goes to Mr: Karim Yaghmour , The great ; The author of Embedded Android tutorial.

 practical example that was causing me fits: not one of the utilities nor commands I was using to remount /system as RW was working, at all. But when I used /system/bin/mount ... instead of mount ... I was able to manually remount as RW. (Presumably /system/xbin/mount is taking priority otherwise.) I got this idea from a reddit post in which the OP eventually fixed his PATH, which I still need to figure out.reddit.com/r/cyanogenmod/comments/2m9t61/…  


折腾了几天,被Android那点儿少得可怜的shell命令折磨的死去活来,终于下定了革命的决心。看一下怎么把渺小的toolbox替换成伟大的busybox吧。先大致描述一下Android系统中的shell程序部分。

shell实现分为两部分:

一、shell解释器和内置命令

源码位于system/core/sh目录下,主要完成shell命令的解释查找,对于builtins.c中包含的内置命令,直接执行,对于toolbox的扩展命令,间接调用toolbox程序完成。

二、toolbox扩展命令

主要完成扩展命令的执行,每一个扩展命令对应一个name_main函数,如ls命令,对应ls_main函数。同时,每一个扩展命令都由一个system/core/toolbox/目录下面的.c文件实现。toolbox.c会根据这个目录下面的.c文件生成tools.h头文件,并在system/core/toolbox/Android.mk文件中为每个命令生成指向toolbox的连接。toolbox的实现结构使它扩展一个命令很容易。

假设现在我们自己想手工添加一个shell命令mycommand,只要在system/core/toolbox/目录下面新建一个mycommand.c文件,并在里面实现一个mycommand_main函数,然后在system/core/toolbox/Android.mk中添加mycommand.c即可。Android.mk会自动把它编译进toolbox程序,并在编译生成的Android系统/system/bin目录下为这个命令生成一个指向toolbox的连接。

 

接下来翻译一下网上的一篇文章,借助它,可以把Android自带的toolbox替换成busybox。

 

Installing Busybox command line tools

英文原文地址:

https://gforge.ti.com/gf/project/omapandroid/wiki/?pagename=Installing+Busybox+command+line+tools

 

 

在Android系统中安装busybox命令行工具

 

本文简单地介绍了怎么把busybox安装到Android的文件系统中去。如果你想直接安装,可以从下面的地址下载我已经预编译好并在Android2.1系统上试验成功的busybox,然后直接跳过下面的安装步骤。

http://download.csdn.net/source/3093680

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值