3
0

TODO 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. Busybox TODO
  2. Stuff that needs to be done. All of this is fair game for 1.2.
  3. build system
  4. make -j is broken, -j1 is forced atm
  5. Make sure that the flags get pinned in e.g. Rules.mak so when expanding them
  6. later on you get the cached result without the need to re-evaluate them.
  7. ----
  8. find
  9. doesn't understand (), lots of susv3 stuff.
  10. ----
  11. sh
  12. The command shell situation is a big mess. We have three or four different
  13. shells that don't really share any code, and the "standalone shell" doesn't
  14. work all that well (especially not in a chroot environment), due to apps not
  15. being reentrant. Unifying the various shells and figuring out a configurable
  16. way of adding the minimal set of bash features a given script uses is a big
  17. job, but it would be a big improvement.
  18. Note: Rob Landley (rob@landley.net) is working on a new unified shell called
  19. bbsh, but it's a low priority...
  20. ---
  21. diff
  22. We should have a diff -u command. We have patch, we should have diff
  23. (we only need to support unified diffs though).
  24. Also, make sure we handle empty files properly:
  25. From the patch man page:
  26.    you can remove a file by sending out a context diff that compares
  27.    the file to be deleted with an empty file dated the Epoch.  The
  28.    file will be removed unless patch is conforming to POSIX and the
  29.    -E or --remove-empty-files option is not given.
  30. ---
  31. patch
  32. Should have simple fuzz factor support to apply patches at an offset which
  33. shouldn't take up too much space.
  34. And while we're at it, a new patch filename quoting format is apparently
  35. coming soon: http://marc.theaimsgroup.com/?l=git&m=112927316408690&w=2
  36. ---
  37. man
  38. It would be nice to have a man command. Not one that handles troff or
  39. anything, just one that can handle preformatted ascii man pages, possibly
  40. compressed. This could probably be a script in the extras directory that
  41. calls cat/zcat/bzcat | less
  42. (How doclifter might work into this is anybody's guess.)
  43. ---
  44. bzip2
  45. Compression-side support.
  46. ---
  47. init
  48. General cleanup.
  49. ---
  50. ar
  51. Write support?
  52. ---
  53. mdev
  54. Micro-udev.
  55. Architectural issues:
  56. bb_close() with fsync()
  57. We should have a bb_close() in place of normal close, with a CONFIG_ option
  58. to not just check the return value of close() for an error, but fsync().
  59. Close can't reliably report anything useful because if write() accepted the
  60. data then it either went out to the network or it's in cache or a pipe
  61. buffer. Either way, there's no guarantee it'll make it to its final
  62. destination before close() gets called, so there's no guarantee that any
  63. error will be reported.
  64. You need to call fsync() if you care about errors that occur after write(),
  65. but that can have a big performance impact. So make it a config option.
  66. ---
  67. Unify base64 handling.
  68. There's base64 encoding and decoding going on in:
  69. networking/wget.c:base64enc()
  70. coreutils/uudecode.c:read_base64()
  71. coreutils/uuencode.c:tbl_base64[]
  72. networking/httpd.c:decodeBase64()
  73. And probably elsewhere. That needs to be unified into libbb functions.
  74. ---
  75. Do a SUSv3 audit
  76. Look at the full Single Unix Specification version 3 (available online at
  77. "http://www.opengroup.org/onlinepubs/009695399/nfindex.html") and
  78. figure out which of our apps are compliant, and what we're missing that
  79. we might actually care about.
  80. Even better would be some kind of automated compliance test harness that
  81. exercises each command line option and the various corner cases.
  82. ---
  83. Internationalization
  84. How much internationalization should we do?
  85. The low hanging fruit is UTF-8 character set support. We should do this.
  86. (Vodz pointed out the shell's cmdedit as needing work here. What else?)
  87. We also have lots of hardwired english text messages. Consolidating this
  88. into some kind of message table not only makes translation easier, but
  89. also allows us to consolidate redundant (or close) strings.
  90. We probably don't want to be bloated with locale support. (Not unless we can
  91. cleanly export it from our underlying C library without having to concern
  92. ourselves with it directly. Perhaps a few specific things like a config
  93. option for "date" are low hanging fruit here?)
  94. What level should things happen at? How much do we care about
  95. internationalizing the text console when X11 and xterms are so much better
  96. at it? (There's some infrastructure here we don't implement: The
  97. "unicode_start" and "unicode_stop" shell scripts need "vt-is-UTF8" and a
  98. --unicode option to loadkeys. That implies a real loadkeys/dumpkeys
  99. implementation to replace loadkmap/dumpkmap. Plus messing with console font
  100. loading. Is it worth it, or do we just say "use X"?)
  101. ---
  102. Unify archivers
  103. Lots of archivers have the same general infrastructure. The directory
  104. traversal code should be factored out, and the guts of each archiver could
  105. be some setup code and a series of callbacks for "add this file",
  106. "add this directory", "add this symlink" and so on.
  107. This could clean up tar and zip, and make it cheaper to add cpio and ar
  108. write support, and possibly even cheaply add things like mkisofs or
  109. mksquashfs someday, if they become relevant.
  110. ---
  111. Text buffer support.
  112. Several existing applets (sort, vi, less...) read
  113. a whole file into memory and act on it. There might be an opportunity
  114. for shared code in there that could be moved into libbb...
  115. ---
  116. Individual compilation of applets.
  117. It would be nice if busybox had the option to compile to individual applets,
  118. for people who want an alternate implementation less bloated than the gnu
  119. utils (or simply with less political baggage), but without it being one big
  120. executable.
  121. Turning libbb into a real dll is another possibility, especially if libbb
  122. could export some of the other library interfaces we've already more or less
  123. got the code for (like zlib).
  124. ---
  125. buildroot - Make a "dogfood" option
  126. Busybox 1.1 will be capable of replacing most gnu packages for real world use,
  127. such as developing software or in a live CD. It needs wider testing.
  128. Busybox should now be able to replace bzip2, coreutils, e2fsprogs, file,
  129. findutils, gawk, grep, inetutils, less, modutils, net-tools, patch, procps,
  130. sed, shadow, sysklogd, sysvinit, tar, util-linux, and vim. The resulting
  131. system should be self-hosting (I.E. able to rebuild itself from source code).
  132. This means it would need (at least) binutils, gcc, and make, or equivalents.
  133. It would be a good "eating our own dogfood" test if buildroot had the option
  134. of using a "make allyesconfig" busybox instead of the all of the above
  135. packages. Anything that's wrong with the resulting system, we can fix. (It
  136. would be nice to be able to upgrade busybox to be able to replace bash and
  137. diffutils as well, but we're not there yet.)
  138. One example of an existing system that does this already is Firmware Linux:
  139. http://www.landley.net/code/firmware
  140. ---
  141. initramfs
  142. Busybox should have a sample initramfs build script. This depends on
  143. bbsh, mdev, and switch_root.
  144. ---
  145. Memory Allocation
  146. We have a CONFIG_BUFFER mechanism that lets us select whether to do memory
  147. allocation on the stack or the heap. Unfortunately, we're not using it much.
  148. We need to audit our memory allocations and turn a lot of malloc/free calls
  149. into RESERVE_CONFIG_BUFFER/RELEASE_CONFIG_BUFFER.
  150. For a start, see e.g. make CFLAGS_EXTRA=-Wlarger-than-64
  151. And while we're at it, many of the CONFIG_FEATURE_CLEAN_UP #ifdefs will be
  152. optimized out by the compiler in the stack allocation case (since there's no
  153. free for an alloca()), and this means that various cleanup loops that just
  154. call free might also be optimized out by the compiler if written right, so
  155. we can yank those #ifdefs too, and generally clean up the code.
  156. ---
  157. Switch CONFIG_SYMBOLS to ENABLE_SYMBOLS
  158. In busybox 1.0 and earlier, configuration was done by CONFIG_SYMBOLS
  159. that were either defined or undefined to indicate whether the symbol was
  160. selected in the .config file. They were used with #ifdefs, ala:
  161. #ifdef CONFIG_SYMBOL
  162. if (other_test) {
  163. do_code();
  164. }
  165. #endif
  166. In 1.1, we have new ENABLE_SYMBOLS which are always defined (as 0 or 1),
  167. meaning you can still use them for preprocessor tests by replacing
  168. "#ifdef CONFIG_SYMBOL" with "#if ENABLE_SYMBOL". But more importantly, we
  169. can use them as a true or false test in normal C code:
  170. if (ENABLE_SYMBOL && other_test) {
  171. do_code();
  172. }
  173. (Optimizing away if() statements that resolve to a constant value
  174. is known as "dead code elimination", an optimization so old and simple that
  175. Turbo Pascal for DOS did it twenty years ago. Even modern mini-compilers
  176. like the Tiny C Compiler (tcc) and the Small Device C Compiler (SDCC)
  177. perform dead code elimination.)
  178. Right now, busybox.h is #including both "config.h" (defining the
  179. CONFIG_SYMBOLS) and "bb_config.h" (defining the ENABLE_SYMBOLS). At some
  180. point in the future, it would be nice to wean ourselves off of the
  181. CONFIG versions. (Among other things, some defective build environments
  182. leak the Linux kernel's CONFIG_SYMBOLS into the system's standard #include
  183. files. We've experienced collisions before.)
  184. ---
  185. FEATURE_CLEAN_UP
  186. This is more an unresolved issue than a to-do item. More thought is needed.
  187. Normally we rely on exit() to free memory, close files, and unmap segments
  188. for us. This makes most calls to free(), close(), and unmap() optional in
  189. busybox applets that don't intend to run for very long, and optional stuff
  190. can be omitted to save size.
  191. The idea was raised that we could simulate fork/exit with setjmp/longjmp
  192. for _really_ brainless embedded systems, or speed up the standalone shell
  193. by not forking. Doing so would require a reliable FEATURE_CLEAN_UP.
  194. Unfortunately, this isn't as easy as it sounds.
  195. The problem is, lots of things exit(), sometimes unexpectedly (xmalloc())
  196. and sometimes reliably (bb_perror_msg_and_die() or show_usage()). This
  197. jumps out of the normal flow control and bypasses any cleanup code we
  198. put at the end of our applets.
  199. It's possible to add hooks to libbb functions like xmalloc() and bb_xopen()
  200. to add their entries to a linked list, which could be traversed and
  201. freed/closed automatically. (This would need to be able to free just the
  202. entries after a checkpoint to be usable for a forkless standalone shell.
  203. You don't want to free the shell's own resources.)
  204. Right now, FEATURE_CLEAN_UP is more or less a debugging aid, to make things
  205. like valgrind happy. It's also documentation of _what_ we're trusting
  206. exit() to clean up for us. But new infrastructure to auto-free stuff would
  207. render the existing FEATURE_CLEAN_UP code redundant.
  208. For right now, exit() handles it just fine.
  209. Minor stuff:
  210. watchdog.c could autodetect the timer duration via:
  211. if(!ioctl (fd, WDIOC_GETTIMEOUT, &tmo)) timer_duration = 1 + (tmo / 2);
  212. Unfortunately, that needs linux/watchdog.h and that contains unfiltered
  213. kernel types on some distros, which breaks the build.
  214. Code cleanup:
  215. Replace deprecated functions.
  216. bzero() -> memset()
  217. ---
  218. sigblock(), siggetmask(), sigsetmask(), sigmask() -> sigprocmask et al
  219. ---