mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:27:35 +00:00
Kernel: Add link() syscall to create hard links.
This accidentally grew into a little bit of VFS cleanup as well. Also add a simple /bin/ln implementation to exercise it.
This commit is contained in:
parent
b6115ee5b7
commit
7d288aafb2
13 changed files with 138 additions and 93 deletions
1
Userland/.gitignore
vendored
1
Userland/.gitignore
vendored
|
@ -31,3 +31,4 @@ dmesg
|
|||
top
|
||||
chmod
|
||||
pape
|
||||
ln
|
||||
|
|
|
@ -27,6 +27,7 @@ OBJS = \
|
|||
dmesg.o \
|
||||
chmod.o \
|
||||
top.o \
|
||||
ln.o \
|
||||
rm.o
|
||||
|
||||
APPS = \
|
||||
|
@ -59,6 +60,7 @@ APPS = \
|
|||
dmesg \
|
||||
chmod \
|
||||
top \
|
||||
ln \
|
||||
rm
|
||||
|
||||
ARCH_FLAGS =
|
||||
|
@ -169,6 +171,9 @@ chmod: chmod.o
|
|||
top: top.o
|
||||
$(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a
|
||||
|
||||
ln: ln.o
|
||||
$(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a
|
||||
|
||||
.cpp.o:
|
||||
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
|
||||
|
||||
|
|
18
Userland/ln.cpp
Normal file
18
Userland/ln.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (argc != 3) {
|
||||
fprintf(stderr, "usage: ln <old-path> <new-path>\n");
|
||||
return 1;
|
||||
}
|
||||
int rc = link(argv[1], argv[2]);
|
||||
if (rc < 0) {
|
||||
perror("link");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue