commit: e58b59fd0397b4bf420ff7cd2d0c6fa7711126e4
parent 751dc15d36dce8349d25237fa06481f034971a97
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sun, 28 Apr 2024 01:18:48 +0200
ln-stub.c: Remove, superseeded by utils-std
Diffstat:
3 files changed, 4 insertions(+), 60 deletions(-)
diff --git a/init.sh b/init.sh
@@ -23,7 +23,7 @@ build_awk() {
}
build_stubs() {
- for i in ln ls mv
+ for i in ls mv
do
$CC $CFLAGS -o "/bin/$i" "/${i}-stub.c" || die "Failed compiling $i stub"
done
@@ -59,8 +59,7 @@ profile_export CC="$CC"
profile_export CFLAGS="$CFLAGS"
export SHELL="/bin/mksh"
-# Note: This is a hardlink, no ln -s yet
-link $SHELL /bin/sh
+ln -s $SHELL /bin/sh || die "Failed creating /bin/sh symlink"
cd /minised-1.16
$CC $CFLAGS sedcomp.c sedexec.c -o /bin/sed
diff --git a/ln-stub.c b/ln-stub.c
@@ -1,55 +0,0 @@
-#define _POSIX_C_SOURCE 200809L
-
-#include <stdio.h> // fprintf
-#include <unistd.h> // getopt, symlink, link
-#include <string.h> // strerror
-#include <errno.h>
-#include <stdbool.h>
-
-int
-main(int argc, char *argv[])
-{
- bool opt_s = false;
-
- int c = -1;
- while((c = getopt(argc, argv, ":s")) != -1)
- {
- switch(c)
- {
- case 's':
- opt_s = true;
- break;
- case '?':
- fprintf(stderr, "ln: Unknown option '-%c'\n", optopt);
- break;
- }
- }
-
- argc -= optind;
- argv += optind;
-
- if(argc != 2)
- {
- fprintf(stderr, "Usage: ln [-s] src dest\n");
- return 1;
- }
-
- if(opt_s)
- {
- if(symlink(argv[0], argv[1]) < 0)
- {
- fprintf(stderr, "ln: Failed creating symlink: %s\n", strerror(errno));
- return 1;
- }
- }
- else
- {
- if(link(argv[0], argv[1]) < 0)
- {
- fprintf(stderr, "ln: Failed creating (hard) link: %s\n", strerror(errno));
- return 1;
- }
- }
-
- return 0;
-}
diff --git a/make-initrd.sh b/make-initrd.sh
@@ -4,7 +4,7 @@
elves="mksh"
tarballs="
- utils-std-ff0b40a.tar.gz
+ utils-std-656199b.tar.gz
mk-20210330.tar.gz
bmake-20230909.tar.gz
minised-1.16.tar.gz
@@ -68,7 +68,7 @@ cp "${WORKDIR}/init.c" ./init || die "copying init"
sed -i '1i#!/bin/tcc -run' ./init || die "failed adding tcc shebang to init"
chmod 755 init || die "init chmod"
-for i in init.sh ln-stub.c ls-stub.c mv-stub.c
+for i in init.sh ls-stub.c mv-stub.c
do
cp -p "${WORKDIR}/$i" ./ || die "failed copying $i"
done