Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Releases: Awesome-Embedded-Learning-Studio/CFBox

V0.1.0 Release

08 May 04:46
780cf9f

Choose a tag to compare

CFBox v0.1.0 — 首个正式发布

C++23 BusyBox 替代品。109 个 applet,零外部运行时依赖,可作为 PID 1 运行。

亮点

  • 109 个 applet,覆盖 shell、coreutils、findutils、文本处理、归档压缩、进程管理和 init 系统
  • 完整 POSIX Shell——管道、重定向、控制流、变量/命令展开、glob、15 个内建命令
  • 完整 AWK 解释器——模式匹配、关联数组、printf、用户自定义函数、正则
  • Init 系统——inittab 解析、运行级别管理、服务监控与 respawn、优雅关机;已在 QEMU aarch64 上以 PID 1 验证
  • 零外部运行时依赖——自研 deflate/inflate 替代 zlib,单文件静态链接
  • 446 KB size-opt Release 构建(visibility hidden + section GC + strip)
  • 331 单元测试 + 54 集成测试,全部通过,ASan 零泄漏

Applet 列表

Shell

sh — 交互式 POSIX shell(词法/语法/执行器,7 个模块 ~2400 行)

Coreutils(60 个)

basename, cat, chgrp, chmod, chown, cksum, comm, cp, cut, date, df, dirname, du, echo, env, expand, expr, factor, false, fold, hostid, hostname, id, install, link, ln, logname, ls, md5sum, mkdir, mkfifo, mknod, mktemp, mv, nl, nproc, od, paste, printenv, printf, pwd, readlink, realpath, rm, rmdir, seq, shuf, sleep, sort, split, stat, sum, sync, tac, tee, test, touch, tr, true, truncate, tsort, tty, uname, unlink, usleep, wc, who, whoami, yes

文本处理

awk, diff, patch, ed, grep, sed

归档与压缩

tar, cpio, ar, unzip, gzip, gunzip

findutils

find, xargs

procps(15 个)

ps, kill, free, uptime, top, watch, pgrep, pkill, pidof, sysctl, pwdx, pstree, pmap, fuser, iostat

util-linux

dmesg, hexdump, more, rev, cal, renice

Init

init

基础设施

组件 说明
args.hpp GNU 风格长选项解析器
help.hpp 统一 --help / --version 输出
term.hpp ANSI 彩色输出(尊重 NO_COLOR
utf8.hpp Unicode 感知的字符计数与宽度
stream.hpp 流式行读取器(for_each_line
checksum.hpp CRC-32、MD5、BSD/SysV sum
compress.hpp 轻量 deflate/inflate(替代 zlib)
terminal.hpp Raw mode RAII、光标控制、备用屏幕缓冲
tui.hpp 全屏 TUI 框架(ScreenBuffer、SIGWINCH)
proc.hpp 集中式 /proc 解析器
fs_util.hpp 扩展文件系统工具
error.hpp std::expected 错误处理(CFBOX_TRY

性能优化

  • Myers O(ND) diff 算法——替代 O(mn) LCS
  • POSIX regex_t——替代 std::regex(grep/sed 加速)
  • 流式 I/O——grep/cat/wc 可处理无限输入
  • 预计算排序 key——避免比较器中重复内存分配
  • 全局 reserve()——diff/ls/timeout/unzip/find 等场景预分配
  • 72 个函数添加 noexcept / [[nodiscard]] / constexpr 标注
  • RAII 封装——unique_filescoped_regexunique_pipe(ASan 验证零泄漏)

构建与 CI

  • CMake 支持 per-applet CFBOX_ENABLE_<APPLET> 开关及预设 profile(embedded / desktop / minimal / full
  • CI 覆盖原生构建、交叉编译(armhf、aarch64)和 QEMU 启动测试
  • 体积优化:cmake -DCMAKE_BUILD_TYPE=Release -DCFBOX_SIZE_OPT=ON

已验证平台

  • x86_64(原生)
  • aarch64(QEMU,含 PID 1 init 启动)
  • armhf(QEMU)

下一步计划

  • Phase 5:vi 可视化编辑器
  • Phase 6:网络工具 + 登录管理 + 系统日志
  • Phase 7:剩余 applet + 全面 POSIX 合规验证

完整变更记录https://github.com/Awesome-Embedded-Learning-Studio/cfbox/commits/v0.1.0


English Version

CFBox v0.1.0 — First Release

C++23 BusyBox alternative. 109 applets, zero external runtime dependencies, runs as PID 1.

Highlights

  • 109 applets across shell, coreutils, findutils, text processing, archiving, compression, process management, and init
  • Full POSIX Shell — pipes, redirections, control flow, variable/command expansion, glob, 15 builtins
  • Complete AWK interpreter — patterns, associative arrays, printf, user functions, regex
  • Init system — inittab parser, runlevel management, service monitoring with respawn, clean shutdown; verified on QEMU aarch64 as PID 1
  • Zero external runtime deps — custom deflate/inflate replaces zlib; static-linked single binary
  • 446 KB size-optimized Release build (visibility hidden + section GC + strip)
  • 331 unit tests + 54 integration tests, all passing, ASan zero leaks

Applets

Shell

sh — interactive POSIX shell (lexer/parser/executor, 7 modules, ~2400 LOC)

Coreutils (60)

basename, cat, chgrp, chmod, chown, cksum, comm, cp, cut, date, df, dirname, du, echo, env, expand, expr, factor, false, fold, hostid, hostname, id, install, link, ln, logname, ls, md5sum, mkdir, mkfifo, mknod, mktemp, mv, nl, nproc, od, paste, printenv, printf, pwd, readlink, realpath, rm, rmdir, seq, shuf, sleep, sort, split, stat, sum, sync, tac, tee, test, touch, tr, true, truncate, tsort, tty, uname, unlink, usleep, wc, who, whoami, yes

Text Processing

awk, diff, patch, ed, grep, sed

Archiving & Compression

tar, cpio, ar, unzip, gzip, gunzip

findutils

find, xargs

procps (15)

ps, kill, free, uptime, top, watch, pgrep, pkill, pidof, sysctl, pwdx, pstree, pmap, fuser, iostat

util-linux

dmesg, hexdump, more, rev, cal, renice

Init

init

Infrastructure

Component Description
args.hpp GNU-style long option parser
help.hpp Unified --help / --version for all applets
term.hpp ANSI color output (respects NO_COLOR)
utf8.hpp Unicode-aware character counting & width
stream.hpp Streaming line reader (for_each_line)
checksum.hpp CRC-32, MD5, BSD/SysV sum
compress.hpp Lightweight deflate/inflate (replaces zlib)
terminal.hpp Raw mode RAII, cursor control, alternate screen
tui.hpp Full-screen TUI framework (ScreenBuffer, SIGWINCH)
proc.hpp Centralized /proc parser
fs_util.hpp Extended filesystem utilities
error.hpp std::expected error handling (CFBOX_TRY)

Optimizations

  • Myers O(ND) diff — replaced O(mn) LCS algorithm
  • POSIX regex_t — replaced std::regex in grep/sed
  • Streaming I/O — grep/cat/wc process unbounded input without buffering
  • Pre-computed sort keys — avoids repeated allocations in comparator
  • Global reserve() — diff, ls, timeout, unzip, find pre-allocate known sizes
  • 72 functions annotated with noexcept / [[nodiscard]] / constexpr
  • RAII wrappersunique_file, scoped_regex, unique_pipe (ASan-verified zero leak)

Build & CI

  • CMake with per-applet CFBOX_ENABLE_<APPLET> toggles and preset profiles (embedded / desktop / minimal / full)
  • CI covers native build, cross-compilation (armhf, aarch64), and QEMU boot tests
  • Size-optimized profile: cmake -DCMAKE_BUILD_TYPE=Release -DCFBOX_SIZE_OPT=ON

Tested On

  • x86_64 (native)
  • aarch64 (QEMU, including PID 1 init)
  • armhf (QEMU)

What's Next

  • Phase 5: vi visual editor
  • Phase 6: Networking + login management + syslog
  • Phase 7: Remaining applets + full POSIX compliance verification

Full Changelog: https://github.com/Awesome-Embedded-Learning-Studio/cfbox/commits/v0.1.0

Morty Proxy This is a proxified and sanitized view of the page, visit original site.