Skip to content
Snippets Groups Projects
Commit 94d7e259 authored by rsc's avatar rsc
Browse files

avoid system binary clashes

parent 7678a19e
No related branches found
No related tags found
No related merge requests found
...@@ -96,45 +96,43 @@ fstests : fstests.o $(ULIB) ...@@ -96,45 +96,43 @@ fstests : fstests.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o fstests fstests.o $(ULIB) $(LD) -N -e main -Ttext 0 -o fstests fstests.o $(ULIB)
$(OBJDUMP) -S fstests > fstests.asm $(OBJDUMP) -S fstests > fstests.asm
echo : echo.o $(ULIB) _echo : echo.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o echo echo.o $(ULIB) $(LD) -N -e main -Ttext 0 -o _echo echo.o $(ULIB)
$(OBJDUMP) -S echo > echo.asm $(OBJDUMP) -S _echo > echo.asm
cat : cat.o $(ULIB) _cat : cat.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o cat cat.o $(ULIB) $(LD) -N -e main -Ttext 0 -o _cat cat.o $(ULIB)
$(OBJDUMP) -S cat > cat.asm $(OBJDUMP) -S _cat > cat.asm
userfs : userfs.o $(ULIB) userfs : userfs.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o userfs userfs.o $(ULIB) $(LD) -N -e main -Ttext 0 -o userfs userfs.o $(ULIB)
$(OBJDUMP) -S userfs > userfs.asm $(OBJDUMP) -S userfs > userfs.asm
init : init.o $(ULIB) _init : init.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o init init.o $(ULIB) $(LD) -N -e main -Ttext 0 -o _init init.o $(ULIB)
$(OBJDUMP) -S init > init.asm $(OBJDUMP) -S _init > init.asm
sh : sh.o $(ULIB) _sh : sh.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o sh sh.o $(ULIB) $(LD) -N -e main -Ttext 0 -o _sh sh.o $(ULIB)
$(OBJDUMP) -S sh > sh.asm $(OBJDUMP) -S _sh > sh.asm
ls : ls.o $(ULIB) _ls : ls.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o ls ls.o $(ULIB) $(LD) -N -e main -Ttext 0 -o _ls ls.o $(ULIB)
$(OBJDUMP) -S ls > ls.asm $(OBJDUMP) -S _ls > ls.asm
mkdir : mkdir.o $(ULIB) _mkdir : mkdir.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o mkdir mkdir.o $(ULIB) $(LD) -N -e main -Ttext 0 -o _mkdir mkdir.o $(ULIB)
$(OBJDUMP) -S mkdir > mkdir.asm $(OBJDUMP) -S _mkdir > mkdir.asm
rm : rm.o $(ULIB) _rm : rm.o $(ULIB)
$(LD) -N -e main -Ttext 0 -o rm rm.o $(ULIB) $(LD) -N -e main -Ttext 0 -o _rm rm.o $(ULIB)
$(OBJDUMP) -S rm > rm.asm $(OBJDUMP) -S _rm > rm.asm
mkfs : mkfs.c fs.h mkfs : mkfs.c fs.h
cc -o mkfs mkfs.c cc -o mkfs mkfs.c
fs.img : mkfs userfs usertests echo cat README init sh ls mkdir rm fstests fs.img : mkfs userfs usertests _echo _cat README _init _sh _ls _mkdir _rm fstests
./mkfs fs.img userfs usertests echo cat README init sh ls mkdir rm fstests ./mkfs fs.img userfs usertests _echo _cat README _init _sh _ls _mkdir _rm fstests
# Remove system binaries to avoid confusion.
/bin/rm -f echo cat sh ls mkdir rm
-include *.d -include *.d
......
...@@ -51,6 +51,7 @@ xint(uint x) ...@@ -51,6 +51,7 @@ xint(uint x)
return y; return y;
} }
int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int i, cc, fd; int i, cc, fd;
...@@ -111,6 +112,13 @@ main(int argc, char *argv[]) ...@@ -111,6 +112,13 @@ main(int argc, char *argv[])
perror(argv[i]); perror(argv[i]);
exit(1); exit(1);
} }
// Skip leading _ in name when writing to file system.
// The binaries are named _rm, _cat, etc. to keep the
// build operating system from trying to execute them
// in place of system binaries like rm and cat.
if(argv[i][0] == '_')
++argv[i];
inum = ialloc(T_FILE); inum = ialloc(T_FILE);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment