From acd792d8b4f1226ea51677c2b7f0c56216208859 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 4 Nov 2025 18:46:13 +0200 Subject: [PATCH] userspace: Implement pwd utility --- userspace/programs/CMakeLists.txt | 1 + userspace/programs/pwd/CMakeLists.txt | 8 ++++++++ userspace/programs/pwd/main.cpp | 15 +++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 userspace/programs/pwd/CMakeLists.txt create mode 100644 userspace/programs/pwd/main.cpp diff --git a/userspace/programs/CMakeLists.txt b/userspace/programs/CMakeLists.txt index 1a76d688..8808641a 100644 --- a/userspace/programs/CMakeLists.txt +++ b/userspace/programs/CMakeLists.txt @@ -31,6 +31,7 @@ set(USERSPACE_PROGRAMS nslookup poweroff ProgramLauncher + pwd resolver rm Shell diff --git a/userspace/programs/pwd/CMakeLists.txt b/userspace/programs/pwd/CMakeLists.txt new file mode 100644 index 00000000..2818d88b --- /dev/null +++ b/userspace/programs/pwd/CMakeLists.txt @@ -0,0 +1,8 @@ +set(SOURCES + main.cpp +) + +add_executable(pwd ${SOURCES}) +banan_link_library(pwd libc) + +install(TARGETS pwd OPTIONAL) diff --git a/userspace/programs/pwd/main.cpp b/userspace/programs/pwd/main.cpp new file mode 100644 index 00000000..76b45f06 --- /dev/null +++ b/userspace/programs/pwd/main.cpp @@ -0,0 +1,15 @@ +#include +#include +#include + +int main() +{ + char buffer[PATH_MAX]; + if (getcwd(buffer, PATH_MAX) == nullptr) + { + perror("getcwd"); + return 1; + } + + printf("%s\n", buffer); +}