Address code review feedback: fix C/C++ typo, remove unused constant, add cleanup traps

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-28 15:06:43 +00:00
parent ae278dc384
commit 3f6ac65241
3 changed files with 32 additions and 8 deletions

View File

@@ -4,7 +4,7 @@ A minimal Linux distribution designed for simplicity and portability. SparkOS fe
- **Minimal footprint**: Barebones Linux system with bash shell
- **Portable**: dd-able disk image for USB flash drives
- **Custom init**: Lightweight C++ init system
- **Custom init**: Lightweight C init system
- **Future-ready**: Designed to support Qt6/QML GUI and Wayland
- **Root elevation**: Uses sudo for privilege management

View File

@@ -10,6 +10,37 @@ IMAGE_FILE="$PROJECT_ROOT/sparkos.img"
IMAGE_SIZE="512M"
MOUNT_POINT="/tmp/sparkos_mount"
ROOTFS_DIR="$PROJECT_ROOT/rootfs"
LOOP_DEV=""
# Cleanup function
cleanup() {
local exit_code=$?
echo "Cleaning up..."
# Unmount if mounted
if mountpoint -q "$MOUNT_POINT" 2>/dev/null; then
umount "$MOUNT_POINT" 2>/dev/null || true
fi
# Remove mount point
if [ -d "$MOUNT_POINT" ]; then
rmdir "$MOUNT_POINT" 2>/dev/null || true
fi
# Detach loop device
if [ -n "$LOOP_DEV" ] && losetup "$LOOP_DEV" &>/dev/null; then
losetup -d "$LOOP_DEV" 2>/dev/null || true
fi
if [ $exit_code -ne 0 ]; then
echo "ERROR: Image creation failed"
fi
exit $exit_code
}
# Set trap for cleanup on exit, interrupt, or error
trap cleanup EXIT INT TERM
echo "SparkOS Image Builder"
echo "====================="
@@ -91,11 +122,6 @@ dd if=/usr/lib/syslinux/mbr/mbr.bin of="$LOOP_DEV" bs=440 count=1 conv=notrunc 2
dd if=/usr/share/syslinux/mbr.bin of="$LOOP_DEV" bs=440 count=1 conv=notrunc 2>/dev/null || \
echo "WARNING: Could not install MBR, you may need to do this manually"
echo "Cleaning up..."
umount "$MOUNT_POINT"
rmdir "$MOUNT_POINT"
losetup -d "$LOOP_DEV"
echo ""
echo "SUCCESS! Bootable image created: $IMAGE_FILE"
echo ""

View File

@@ -12,8 +12,6 @@
#include <errno.h>
#include <string.h>
#define INIT_PATH "/sbin/init"
static void signal_handler(int sig) {
if (sig == SIGCHLD) {
// Reap zombie processes