[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

iniramfs: smal bunch of small changes, getting rid of busybox STANDALONE_SHELL



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello.

I'm trying to get rid of the ugly hack in busybox, which is
activated by CONFIG_STANDALONE_SHELL in busybox configuration.

What it does is: when you run its shell, ash, and run a command,
such as dd or ls, and this command is provided by this busybox
binary too, busybox executes itself to run this command, instead
of trying to search it in $PATH as it's usually done.

So effectively, all busybox commands becomes "shell builtins"
like cd and echo (which is a built-in in most shells nowadays).

This "standalone shell" mode helps when you're working in some
rescue environment where you want as less filesystem access as
possible, so that just one (probably statically linked) executable
is enough for everything.  But such a usage case is very, well,
special.  In all other cases, such behavour is unexpected and
confusing at best, and there's no good way to control which
implementation of commands will be used if both busybox and
an external binary provides the same command.

So I'm trying to get rid of CONFIG_STANDALONE_SHELL in busybox,
and initramfs is the only user of this feature currently.

The plan is to introduce (sym)links in initramfs pointing to
busybox for all applets it provides, instead of just one
executable which when executes itself.

The patchset that follows is a bunch of very small changes for
initramfs hooks that does the following:

[001]  don't move klibc's sh.shared to sh, link instead
  this is a tiny "optional" change, for consistency, so
  to say: when using symlinks it becomes more obvious which
  implementation is being used.  Moreover, by not moving the
  original sh.shared we keep it even in case we'll use
  something else in the future.

[002]  don't warn about md-root need busybox: it doesn't anymore
  unrelated cleanup patch but it is in the same place I'll
  touch later: we believed mdadm needs busybox in initramfs,
  but it has been fixed long ago

[003]  don't copy busybox to sh, use proper name and symlink

[004]  rename hooks/busybox to hooks/zz-busybox to reorder it to be last hook
  this is in order to ensure that busybox hook will be run last,
  in order to "fill the gaps", -- to create links to busybox only
  for those commands which don't already exist in initramfs.

[005] create links in initramfs to busybox with other names if not already exist
  the final thing

The whole thing is also available in a git repository,
git://git.corpit.ru/initramfs-tools.git in create-links-to-busybox
branch.

This series is based on maks/mkinitramfs_cp branch of initramfs
git repository on alioth, since it requires commit 11e9453a29cbc1
"mkinitramfs: copy over on build instead of using symlink tree",
because it uses symlinks heavily.

This is just one possible approach.  Another approach will be
to move whole hooks/busybox into busybox package, just like
hooks/klibc actually, -- I'm not sure what kernel team prefers.

Thanks!

/mjt
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iJwEAQECAAYFAk2EjNIACgkQUlPFrXTwyDiUWgQA0nWrEU7ryNkA/RltD3aLBKDz
7U9rcME69OkaQy+1KsP4jnFjyJ/OBU1IBxdGbUeSaBzax8ZKgqnx5xnRsC9cnxB5
N8ZGR9tTPdYPXSOxwv0AtLhUVW47OVz7X/kvHIPuYcXVy3MUH3wFx0+NPtWdeNUc
Ga/Vv0k8HwAq1+8pVxI=
=h3jX
-----END PGP SIGNATURE-----


Reply to: