1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:57:35 +00:00

Add a "pwd" utility to userland.

It's implemented as a separate process. How cute is that.
Tasks now have a current working directory. Spawned tasks inherit their
parent task's working directory.
Currently everyone just uses "/" as there's no way to chdir().
This commit is contained in:
Andreas Kling 2018-10-24 14:28:22 +02:00
parent eb4074bb9d
commit ec1d16b307
17 changed files with 87 additions and 14 deletions

1
Userland/.gitignore vendored
View file

@ -2,4 +2,5 @@ id
sh
ps
ls
pwd
*.o

View file

@ -2,13 +2,15 @@ OBJS = \
id.o \
sh.o \
ps.o \
ls.o
ls.o \
pwd.o
APPS = \
id \
sh \
ps \
ls
ls \
pwd
ARCH_FLAGS =
STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib
@ -40,6 +42,9 @@ ps: ps.o
ls: ls.o
$(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a
pwd: pwd.o
$(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a
.cpp.o:
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<

15
Userland/pwd.cpp Normal file
View file

@ -0,0 +1,15 @@
#include <LibC/unistd.h>
#include <LibC/stdio.h>
int main(int c, char** v)
{
char buffer[1024];
char* ptr = getcwd(buffer, sizeof(buffer));
if (!ptr) {
printf("getcwd() failed\n");
return 1;
}
printf("%s\n", ptr);
return 0;
}