Skip to content

Commit daede64

Browse files
ryanbreenRyan Breenclaude
committed
feat: rename coreutils with "b" prefix to avoid GNU collision
Rename all 14 Breenix coreutils (ls, cat, echo, etc.) to b-prefixed names (bls, bcat, becho, etc.) so they won't collide with GNU coreutils when MUSL libc is ported. Also fix bls to sort entries alphabetically. Co-Authored-By: Ryan Breen <ryanbreen@gmail.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c9ecebd commit daede64

34 files changed

+388
-332
lines changed

kernel/src/test_exec.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3000,11 +3000,11 @@ pub fn test_shell_pipe() {
30003000
}
30013001
}
30023002

3003-
/// Test the `true` coreutil
3003+
/// Test the `btrue` coreutil
30043004
///
3005-
/// Verifies that /bin/true correctly exits with code 0.
3005+
/// Verifies that /bin/btrue correctly exits with code 0.
30063006
pub fn test_true_coreutil() {
3007-
log::info!("Testing true coreutil (exit code 0)");
3007+
log::info!("Testing btrue coreutil (exit code 0)");
30083008

30093009
#[cfg(feature = "testing")]
30103010
let true_test_elf_buf = crate::userspace_test::get_test_binary("true_test");
@@ -3033,11 +3033,11 @@ pub fn test_true_coreutil() {
30333033
}
30343034
}
30353035

3036-
/// Test the `false` coreutil
3036+
/// Test the `bfalse` coreutil
30373037
///
3038-
/// Verifies that /bin/false correctly exits with code 1.
3038+
/// Verifies that /bin/bfalse correctly exits with code 1.
30393039
pub fn test_false_coreutil() {
3040-
log::info!("Testing false coreutil (exit code 1)");
3040+
log::info!("Testing bfalse coreutil (exit code 1)");
30413041

30423042
#[cfg(feature = "testing")]
30433043
let false_test_elf_buf = crate::userspace_test::get_test_binary("false_test");
@@ -3066,11 +3066,11 @@ pub fn test_false_coreutil() {
30663066
}
30673067
}
30683068

3069-
/// Test the `head` coreutil
3069+
/// Test the `bhead` coreutil
30703070
///
3071-
/// Verifies that /bin/head correctly outputs the first N lines of files.
3071+
/// Verifies that /bin/bhead correctly outputs the first N lines of files.
30723072
pub fn test_head_coreutil() {
3073-
log::info!("Testing head coreutil (first N lines)");
3073+
log::info!("Testing bhead coreutil (first N lines)");
30743074

30753075
#[cfg(feature = "testing")]
30763076
let head_test_elf_buf = crate::userspace_test::get_test_binary("head_test");
@@ -3099,11 +3099,11 @@ pub fn test_head_coreutil() {
30993099
}
31003100
}
31013101

3102-
/// Test the `tail` coreutil
3102+
/// Test the `btail` coreutil
31033103
///
3104-
/// Verifies that /bin/tail correctly outputs the last N lines of files.
3104+
/// Verifies that /bin/btail correctly outputs the last N lines of files.
31053105
pub fn test_tail_coreutil() {
3106-
log::info!("Testing tail coreutil (last N lines)");
3106+
log::info!("Testing btail coreutil (last N lines)");
31073107

31083108
#[cfg(feature = "testing")]
31093109
let tail_test_elf_buf = crate::userspace_test::get_test_binary("tail_test");
@@ -3132,11 +3132,11 @@ pub fn test_tail_coreutil() {
31323132
}
31333133
}
31343134

3135-
/// Test the `wc` coreutil
3135+
/// Test the `bwc` coreutil
31363136
///
3137-
/// Verifies that /bin/wc correctly counts lines, words, and bytes.
3137+
/// Verifies that /bin/bwc correctly counts lines, words, and bytes.
31383138
pub fn test_wc_coreutil() {
3139-
log::info!("Testing wc coreutil (line/word/byte counts)");
3139+
log::info!("Testing bwc coreutil (line/word/byte counts)");
31403140

31413141
#[cfg(feature = "testing")]
31423142
let wc_test_elf_buf = crate::userspace_test::get_test_binary("wc_test");
@@ -3165,11 +3165,11 @@ pub fn test_wc_coreutil() {
31653165
}
31663166
}
31673167

3168-
/// Test the `which` coreutil
3168+
/// Test the `bwhich` coreutil
31693169
///
3170-
/// Verifies that /bin/which correctly locates commands in PATH.
3170+
/// Verifies that /bin/bwhich correctly locates commands in PATH.
31713171
pub fn test_which_coreutil() {
3172-
log::info!("Testing which coreutil (command location)");
3172+
log::info!("Testing bwhich coreutil (command location)");
31733173

31743174
#[cfg(feature = "testing")]
31753175
let which_test_elf_buf = crate::userspace_test::get_test_binary("which_test");
@@ -3198,11 +3198,11 @@ pub fn test_which_coreutil() {
31983198
}
31993199
}
32003200

3201-
/// Test the `cat` coreutil
3201+
/// Test the `bcat` coreutil
32023202
///
3203-
/// Verifies that /bin/cat correctly outputs file contents.
3203+
/// Verifies that /bin/bcat correctly outputs file contents.
32043204
pub fn test_cat_coreutil() {
3205-
log::info!("Testing cat coreutil (file concatenation)");
3205+
log::info!("Testing bcat coreutil (file concatenation)");
32063206

32073207
#[cfg(feature = "testing")]
32083208
let cat_test_elf_buf = crate::userspace_test::get_test_binary("cat_test");
@@ -3231,11 +3231,11 @@ pub fn test_cat_coreutil() {
32313231
}
32323232
}
32333233

3234-
/// Test the `ls` coreutil
3234+
/// Test the `bls` coreutil
32353235
///
3236-
/// Verifies that /bin/ls correctly lists directory contents.
3236+
/// Verifies that /bin/bls correctly lists directory contents.
32373237
pub fn test_ls_coreutil() {
3238-
log::info!("Testing ls coreutil (directory listing)");
3238+
log::info!("Testing bls coreutil (directory listing)");
32393239

32403240
#[cfg(feature = "testing")]
32413241
let ls_test_elf_buf = crate::userspace_test::get_test_binary("ls_test");

scripts/create_ext2_disk.sh

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#
44
# This script creates an ext2 filesystem image (32MB x86_64, 48MB aarch64) with:
55
# - Test files for filesystem testing
6-
# - Coreutils binaries in /bin/ (cat, ls, echo, mkdir, rmdir, rm, cp, mv, false, head, tail, wc, which)
7-
# - /sbin/true for PATH order testing
6+
# - Coreutils binaries in /bin/ (bcat, bls, becho, bmkdir, brmdir, brm, bcp, bmv, bfalse, bhead, btail, bwc, bwhich)
7+
# - /sbin/btrue for PATH order testing
88
# - hello_world binary for exec testing
99
#
1010
# Requires Docker on macOS (or mke2fs on Linux).
@@ -56,8 +56,8 @@ else
5656
TESTDATA_FILE="$PROJECT_ROOT/testdata/ext2.img"
5757
fi
5858

59-
# Coreutils to install in /bin
60-
COREUTILS="cat ls echo mkdir rmdir rm cp mv true false head tail wc which"
59+
# Coreutils to install in /bin (b-prefixed Breenix coreutils)
60+
COREUTILS="bcat bls becho bmkdir brmdir brm bcp bmv btrue bfalse bhead btail bwc bwhich"
6161

6262
echo "Creating ext2 disk image..."
6363
echo " Arch: $ARCH"
@@ -108,19 +108,27 @@ if [[ "$(uname)" == "Darwin" ]]; then
108108
mkdir -p /mnt/ext2
109109
mount /work/$OUTPUT_FILENAME /mnt/ext2
110110
111-
# Create /bin and /sbin directories for coreutils
111+
# Create /bin, /sbin, and /usr/local/test/bin directories
112112
mkdir -p /mnt/ext2/bin
113113
mkdir -p /mnt/ext2/sbin
114+
mkdir -p /mnt/ext2/usr/local/test/bin
114115
115116
# Copy ALL binaries from /binaries directory
116-
# Special handling: true and telnetd go to /sbin, everything else to /bin
117+
# Routing: test binaries (*_test, test_*) -> /usr/local/test/bin
118+
# system binaries (true, telnetd, init) -> /sbin
119+
# everything else -> /bin
117120
echo "Installing all binaries..."
118121
bin_count=0
119122
sbin_count=0
123+
test_count=0
120124
for elf_file in /binaries/*.elf; do
121125
if [ -f "$elf_file" ]; then
122126
bin_name=$(basename "$elf_file" .elf)
123-
if [ "$bin_name" = "true" ] || [ "$bin_name" = "telnetd" ] || [ "$bin_name" = "init" ]; then
127+
if echo "$bin_name" | grep -qE "_test$|^test_"; then
128+
cp "$elf_file" /mnt/ext2/usr/local/test/bin/${bin_name}
129+
chmod 755 /mnt/ext2/usr/local/test/bin/${bin_name}
130+
test_count=$((test_count + 1))
131+
elif [ "$bin_name" = "btrue" ] || [ "$bin_name" = "telnetd" ] || [ "$bin_name" = "init" ]; then
124132
cp "$elf_file" /mnt/ext2/sbin/${bin_name}
125133
chmod 755 /mnt/ext2/sbin/${bin_name}
126134
sbin_count=$((sbin_count + 1))
@@ -133,6 +141,7 @@ if [[ "$(uname)" == "Darwin" ]]; then
133141
done
134142
echo " Installed $bin_count binaries in /bin"
135143
echo " Installed $sbin_count binaries in /sbin"
144+
echo " Installed $test_count test binaries in /usr/local/test/bin"
136145
137146
# Create /tmp for filesystem write tests
138147
mkdir -p /mnt/ext2/tmp
@@ -172,8 +181,10 @@ EOF
172181
echo "ext2 filesystem contents:"
173182
echo " Binaries in /bin:"
174183
ls -la /mnt/ext2/bin/ 2>/dev/null || echo " (none)"
184+
echo " Test binaries in /usr/local/test/bin:"
185+
ls -la /mnt/ext2/usr/local/test/bin/ 2>/dev/null || echo " (none)"
175186
echo " Test files:"
176-
find /mnt/ext2 -type f -not -path "/mnt/ext2/bin/*" -exec ls -la {} \;
187+
find /mnt/ext2 -type f -not -path "/mnt/ext2/bin/*" -not -path "/mnt/ext2/usr/local/test/bin/*" -exec ls -la {} \;
177188
178189
# Unmount
179190
umount /mnt/ext2
@@ -206,19 +217,27 @@ else
206217
MOUNT_DIR=$(mktemp -d)
207218
mount "$OUTPUT_FILE" "$MOUNT_DIR"
208219

209-
# Create /bin and /sbin directories
220+
# Create /bin, /sbin, and /usr/local/test/bin directories
210221
mkdir -p "$MOUNT_DIR/bin"
211222
mkdir -p "$MOUNT_DIR/sbin"
223+
mkdir -p "$MOUNT_DIR/usr/local/test/bin"
212224

213225
# Copy ALL binaries from userspace directory
214-
# Special handling: true and telnetd go to /sbin, everything else to /bin
226+
# Routing: test binaries (*_test, test_*) -> /usr/local/test/bin
227+
# system binaries (true, telnetd, init) -> /sbin
228+
# everything else -> /bin
215229
echo "Installing all binaries..."
216230
bin_count=0
217231
sbin_count=0
232+
test_count=0
218233
for elf_file in "$USERSPACE_DIR"/*.elf; do
219234
if [ -f "$elf_file" ]; then
220235
bin_name=$(basename "$elf_file" .elf)
221-
if [ "$bin_name" = "true" ] || [ "$bin_name" = "telnetd" ] || [ "$bin_name" = "init" ]; then
236+
if echo "$bin_name" | grep -qE '_test$|^test_'; then
237+
cp "$elf_file" "$MOUNT_DIR/usr/local/test/bin/${bin_name}"
238+
chmod 755 "$MOUNT_DIR/usr/local/test/bin/${bin_name}"
239+
test_count=$((test_count + 1))
240+
elif [ "$bin_name" = "btrue" ] || [ "$bin_name" = "telnetd" ] || [ "$bin_name" = "init" ]; then
222241
cp "$elf_file" "$MOUNT_DIR/sbin/${bin_name}"
223242
chmod 755 "$MOUNT_DIR/sbin/${bin_name}"
224243
sbin_count=$((sbin_count + 1))
@@ -231,6 +250,7 @@ else
231250
done
232251
echo " Installed $bin_count binaries in /bin"
233252
echo " Installed $sbin_count binaries in /sbin"
253+
echo " Installed $test_count test binaries in /usr/local/test/bin"
234254

235255
# Create /tmp for filesystem write tests
236256
mkdir -p "$MOUNT_DIR/tmp"
@@ -267,7 +287,9 @@ EOF
267287
echo ""
268288
echo "ext2 filesystem contents:"
269289
ls -la "$MOUNT_DIR/bin/"
270-
find "$MOUNT_DIR" -type f -not -path "$MOUNT_DIR/bin/*" -exec ls -la {} \;
290+
echo " Test binaries in /usr/local/test/bin:"
291+
ls -la "$MOUNT_DIR/usr/local/test/bin/" 2>/dev/null || echo " (none)"
292+
find "$MOUNT_DIR" -type f -not -path "$MOUNT_DIR/bin/*" -not -path "$MOUNT_DIR/usr/local/test/bin/*" -exec ls -la {} \;
271293

272294
# Unmount and cleanup
273295
umount "$MOUNT_DIR"
@@ -287,8 +309,9 @@ if [[ -f "$OUTPUT_FILE" ]]; then
287309
echo " Size: $SIZE"
288310
echo ""
289311
echo "Contents:"
290-
echo " /bin/* - All userspace binaries (coreutils, tests, demos)"
291-
echo " /sbin/true - exit status coreutil (for PATH testing)"
312+
echo " /bin/* - Userspace binaries (coreutils, demos)"
313+
echo " /usr/local/test/bin/* - Test binaries (*_test, test_*)"
314+
echo " /sbin/btrue - exit status coreutil (for PATH testing)"
292315
echo " /sbin/telnetd - telnet daemon"
293316
echo " /hello.txt - test file (1 line)"
294317
echo " /lines.txt - multi-line test file (15 lines) for head/tail/wc"

userspace/programs/Cargo.toml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -235,62 +235,62 @@ path = "src/cow_readonly_test.rs"
235235
name = "cow_signal_test"
236236
path = "src/cow_signal_test.rs"
237237

238-
# Phase 3: Coreutils
238+
# Phase 3: Coreutils (b-prefixed to avoid collision with GNU coreutils)
239239
[[bin]]
240-
name = "true"
241-
path = "src/true.rs"
240+
name = "btrue"
241+
path = "src/btrue.rs"
242242

243243
[[bin]]
244-
name = "false"
245-
path = "src/false.rs"
244+
name = "bfalse"
245+
path = "src/bfalse.rs"
246246

247247
[[bin]]
248-
name = "echo"
249-
path = "src/echo.rs"
248+
name = "becho"
249+
path = "src/becho.rs"
250250

251251
[[bin]]
252-
name = "cat"
253-
path = "src/cat.rs"
252+
name = "bcat"
253+
path = "src/bcat.rs"
254254

255255
[[bin]]
256-
name = "head"
257-
path = "src/head.rs"
256+
name = "bhead"
257+
path = "src/bhead.rs"
258258

259259
[[bin]]
260-
name = "tail"
261-
path = "src/tail.rs"
260+
name = "btail"
261+
path = "src/btail.rs"
262262

263263
[[bin]]
264-
name = "wc"
265-
path = "src/wc.rs"
264+
name = "bwc"
265+
path = "src/bwc.rs"
266266

267267
[[bin]]
268-
name = "which"
269-
path = "src/which.rs"
268+
name = "bwhich"
269+
path = "src/bwhich.rs"
270270

271271
[[bin]]
272-
name = "ls"
273-
path = "src/ls.rs"
272+
name = "bls"
273+
path = "src/bls.rs"
274274

275275
[[bin]]
276-
name = "mkdir"
277-
path = "src/mkdir.rs"
276+
name = "bmkdir"
277+
path = "src/bmkdir.rs"
278278

279279
[[bin]]
280-
name = "rmdir"
281-
path = "src/rmdir.rs"
280+
name = "brmdir"
281+
path = "src/brmdir.rs"
282282

283283
[[bin]]
284-
name = "rm"
285-
path = "src/rm.rs"
284+
name = "brm"
285+
path = "src/brm.rs"
286286

287287
[[bin]]
288-
name = "cp"
289-
path = "src/cp.rs"
288+
name = "bcp"
289+
path = "src/bcp.rs"
290290

291291
[[bin]]
292-
name = "mv"
293-
path = "src/mv.rs"
292+
name = "bmv"
293+
path = "src/bmv.rs"
294294

295295
[[bin]]
296296
name = "resolution"

userspace/programs/build.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -167,21 +167,21 @@ STD_BINARIES=(
167167
"cow_readonly_test"
168168
"cow_signal_test"
169169

170-
# Phase 3: Coreutils
171-
"true"
172-
"false"
173-
"echo"
174-
"cat"
175-
"head"
176-
"tail"
177-
"wc"
178-
"which"
179-
"ls"
180-
"mkdir"
181-
"rmdir"
182-
"rm"
183-
"cp"
184-
"mv"
170+
# Phase 3: Coreutils (b-prefixed)
171+
"btrue"
172+
"bfalse"
173+
"becho"
174+
"bcat"
175+
"bhead"
176+
"btail"
177+
"bwc"
178+
"bwhich"
179+
"bls"
180+
"bmkdir"
181+
"brmdir"
182+
"brm"
183+
"bcp"
184+
"bmv"
185185
"resolution"
186186

187187
# Phase 4: init_shell

0 commit comments

Comments
 (0)