diff --git a/userspace/CMakeLists.txt b/userspace/CMakeLists.txt index a1b64e041f..9874d57055 100644 --- a/userspace/CMakeLists.txt +++ b/userspace/CMakeLists.txt @@ -16,6 +16,7 @@ set(USERSPACE_PROJECTS mkdir mmap-shared-test poweroff + rm Shell snake stat diff --git a/userspace/rm/CMakeLists.txt b/userspace/rm/CMakeLists.txt new file mode 100644 index 0000000000..672839c759 --- /dev/null +++ b/userspace/rm/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.26) + +project(rm CXX) + +set(SOURCES + main.cpp +) + +add_executable(rm ${SOURCES}) +target_compile_options(rm PUBLIC -O2 -g) +target_link_libraries(rm PUBLIC libc) + +add_custom_target(rm-install + COMMAND sudo cp ${CMAKE_CURRENT_BINARY_DIR}/rm ${BANAN_BIN}/ + DEPENDS rm + USES_TERMINAL +) diff --git a/userspace/rm/main.cpp b/userspace/rm/main.cpp new file mode 100644 index 0000000000..42896b6c7c --- /dev/null +++ b/userspace/rm/main.cpp @@ -0,0 +1,22 @@ +#include +#include + +int main(int argc, char** argv) +{ + if (argc <= 1) + { + fprintf(stderr, "Missing operand\n"); + return 1; + } + + int ret = 0; + for (int i = 1; i < argc; i++) + { + if (unlink(argv[i]) == -1) + { + perror(argv[i]); + ret = 1; + } + } + return ret; +}