userspace: Implement pwd utility

This commit is contained in:
Bananymous 2025-11-04 18:46:13 +02:00
parent fc730679ed
commit acd792d8b4
3 changed files with 24 additions and 0 deletions

View File

@ -31,6 +31,7 @@ set(USERSPACE_PROGRAMS
nslookup nslookup
poweroff poweroff
ProgramLauncher ProgramLauncher
pwd
resolver resolver
rm rm
Shell Shell

View File

@ -0,0 +1,8 @@
set(SOURCES
main.cpp
)
add_executable(pwd ${SOURCES})
banan_link_library(pwd libc)
install(TARGETS pwd OPTIONAL)

View File

@ -0,0 +1,15 @@
#include <limits.h>
#include <stdio.h>
#include <unistd.h>
int main()
{
char buffer[PATH_MAX];
if (getcwd(buffer, PATH_MAX) == nullptr)
{
perror("getcwd");
return 1;
}
printf("%s\n", buffer);
}