Skip to content

Commit

Permalink
Merge pull request #40 from ToolmanP/libc-fix
Browse files Browse the repository at this point in the history
fix: fix wrong libc source code overrides
  • Loading branch information
ToolmanP authored Oct 9, 2024
2 parents 5db209d + 6e75c3f commit fa237c1
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 39 deletions.
Binary file modified Lab3/ramdisk/userland.bin
Binary file not shown.
25 changes: 13 additions & 12 deletions Lab3/user/chcore-libc/libchcore/cmake/do_override_dir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ set -e
self=`basename "$0"`

function usage {
echo "Usage: $self [overrides_absolute_path] [target_absolute_path]"
echo "Usage: $self [[overrides_absolute_path]] [[target_absolute_path]]"
exit 1
}

if [ "$#" -ne 2 ]; then
if [[ "$#" -ne 2 ]]; then
usage
fi

if [[ $1 != /* ]] || [[ $2 != /* ]]; then
if [[[[ $1 != /* ]]]] || [[[[ $2 != /* ]]]]; then
usage
fi

Expand Down Expand Up @@ -63,28 +63,29 @@ function traverse {
rel_path=${file#$overrides/}
target_file=$target/$rel_path

if [ -d "$file" ]; then
if [ ! -e "$target_file" ]; then
if [[ -d "$file" ]]; then
if [[ ! -e "$target_file" ]]; then
ln -sf "$file" "$target_file"
echo "--- Overrided ${target_file} with ${file} symlink"
elif [ ! -L "$target_file" ]; then
elif [[ ! -L "$target_file" ]]; then
traverse "$file"
else
echo "--- Target directory ${target_file} has been overrided, skipping..."
fi
elif [ -f "$file" ]; then
if [ ! -s "$file" ]; then
if [ -e "$target_file" ]; then
mv "$target_file" "$target_file.bak"
elif [[ -f "$file" ]]; then
if [[ "$file" == *.del ]]; then
target_file="${target_file%.del}"
if [[ -e "${target_file}" ]]; then
mv "${target_file}" "$target_file.bak"
echo "--- Overrided ${target_file} with ${file}"
else
echo "--- Target file ${target_file} has been deleted, skipping..."
fi
else
if [ ! -e "$target_file" ]; then
if [[ ! -e "$target_file" ]]; then
ln -sf "$file" "$target_file"
echo "--- Overrided ${target_file} with ${file}"
elif [ ! -L "$target_file" ]; then
elif [[ ! -L "$target_file" ]]; then
mv "$target_file" "$target_file.bak"
ln -sf "$file" "$target_file"
echo "--- Overrided ${target_file} with ${file}"
Expand Down
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion Lab4/filelist.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SCHEDULER := $(SCHED)/sched.c
RR := $(SCHED)/policy_rr.c
ARCH_TIMER := $(ARCH_IRQ)/timer.c
IRQ := $(ARCH_IRQ)/irq.c
KERNEL_TIMER := $(IRQ)/timer.c
KERNEL_TIMER := $(KERNEL_IRQ)/timer.c
CONNECTION := $(IPC)/connection.c

FILES := $(SCHEDULER) \
Expand Down
2 changes: 1 addition & 1 deletion Lab4/kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ macro(_kernel_incbin _binary_name _binary_path)
endmacro()

# Include essential user-level binaries
_kernel_incbin(procmgr_bin ${CMAKE_CURRENT_SOURCE_DIR}/../user/procmgr)
_kernel_incbin(procmgr_bin ${CHCORE_USER_INSTALL_DIR}/system-servers/procmgr/procmgr)

# Rebuild kernel when ramdisk changes
add_custom_target(touch-inc-procmgr
Expand Down
25 changes: 13 additions & 12 deletions Lab4/user/chcore-libc/libchcore/cmake/do_override_dir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ set -e
self=`basename "$0"`

function usage {
echo "Usage: $self [overrides_absolute_path] [target_absolute_path]"
echo "Usage: $self [[overrides_absolute_path]] [[target_absolute_path]]"
exit 1
}

if [ "$#" -ne 2 ]; then
if [[ "$#" -ne 2 ]]; then
usage
fi

if [[ $1 != /* ]] || [[ $2 != /* ]]; then
if [[[[ $1 != /* ]]]] || [[[[ $2 != /* ]]]]; then
usage
fi

Expand Down Expand Up @@ -63,28 +63,29 @@ function traverse {
rel_path=${file#$overrides/}
target_file=$target/$rel_path

if [ -d "$file" ]; then
if [ ! -e "$target_file" ]; then
if [[ -d "$file" ]]; then
if [[ ! -e "$target_file" ]]; then
ln -sf "$file" "$target_file"
echo "--- Overrided ${target_file} with ${file} symlink"
elif [ ! -L "$target_file" ]; then
elif [[ ! -L "$target_file" ]]; then
traverse "$file"
else
echo "--- Target directory ${target_file} has been overrided, skipping..."
fi
elif [ -f "$file" ]; then
if [ ! -s "$file" ]; then
if [ -e "$target_file" ]; then
mv "$target_file" "$target_file.bak"
elif [[ -f "$file" ]]; then
if [[ "$file" == *.del ]]; then
target_file="${target_file%.del}"
if [[ -e "${target_file}" ]]; then
mv "${target_file}" "$target_file.bak"
echo "--- Overrided ${target_file} with ${file}"
else
echo "--- Target file ${target_file} has been deleted, skipping..."
fi
else
if [ ! -e "$target_file" ]; then
if [[ ! -e "$target_file" ]]; then
ln -sf "$file" "$target_file"
echo "--- Overrided ${target_file} with ${file}"
elif [ ! -L "$target_file" ]; then
elif [[ ! -L "$target_file" ]]; then
mv "$target_file" "$target_file.bak"
ln -sf "$file" "$target_file"
echo "--- Overrided ${target_file} with ${file}"
Expand Down
Empty file.
Binary file removed Lab4/user/procmgr
Binary file not shown.
16 changes: 3 additions & 13 deletions Lab4/user/system-services/system-servers/procmgr/procmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,20 +645,10 @@ void boot_default_apps(void)

/* Start shell. */

char *userland_argv= "userland.bin";
char *test_ipc_argv= "test_ipc.bin";
(void)procmgr_launch_process(1,
&userland_argv,
"userland",
true,
INIT_BADGE,
NULL,
COMMON_APP,
NULL);

char *hello_world_argv= "hello_world.bin";
(void)procmgr_launch_process(1,
&hello_world_argv,
"hello_world",
&test_ipc_argv,
"test_ipc",
true,
INIT_BADGE,
NULL,
Expand Down

0 comments on commit fa237c1

Please sign in to comment.