Skip to content

Commit

Permalink
add ln
Browse files Browse the repository at this point in the history
  • Loading branch information
rsc committed Aug 22, 2007
1 parent c88bf23 commit 6bf2e5c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ _rm : rm.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o _rm rm.o $(ULIB)
$(OBJDUMP) -S _rm > rm.asm

_ln : ln.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o _ln ln.o $(ULIB)
$(OBJDUMP) -S _ln > ln.asm

_sh : sh.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o _sh sh.o $(ULIB)
$(OBJDUMP) -S _sh > sh.asm
Expand All @@ -116,7 +120,7 @@ _zombie: zombie.o $(ULIB)
mkfs : mkfs.c fs.h
cc -o mkfs mkfs.c

UPROGS=usertests _echo _cat _init _kill _ls _mkdir _rm _sh _zombie
UPROGS=usertests _echo _cat _init _kill _ln _ls _mkdir _rm _sh _zombie
fs.img : mkfs README $(UPROGS)
./mkfs fs.img README $(UPROGS)

Expand Down
15 changes: 15 additions & 0 deletions ln.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "types.h"
#include "stat.h"
#include "user.h"

int
main(int argc, char *argv[])
{
if(argc != 3){
printf(2, "Usage: ln old new\n");
exit();
}
if(link(argv[1], argv[2]) < 0)
printf(2, "link %s %s: failed\n", argv[1], argv[2]);
exit();
}

0 comments on commit 6bf2e5c

Please sign in to comment.