userspace: Implement pwd utility
This commit is contained in:
8
userspace/programs/pwd/CMakeLists.txt
Normal file
8
userspace/programs/pwd/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
set(SOURCES
|
||||
main.cpp
|
||||
)
|
||||
|
||||
add_executable(pwd ${SOURCES})
|
||||
banan_link_library(pwd libc)
|
||||
|
||||
install(TARGETS pwd OPTIONAL)
|
||||
15
userspace/programs/pwd/main.cpp
Normal file
15
userspace/programs/pwd/main.cpp
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user