mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:17:44 +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:
parent
eb4074bb9d
commit
ec1d16b307
17 changed files with 87 additions and 14 deletions
1
Userland/.gitignore
vendored
1
Userland/.gitignore
vendored
|
@ -2,4 +2,5 @@ id
|
|||
sh
|
||||
ps
|
||||
ls
|
||||
pwd
|
||||
*.o
|
||||
|
|
|
@ -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
15
Userland/pwd.cpp
Normal 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;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue