fix . .. unlink bug

This commit is contained in:
rsc 2007-08-08 09:08:29 +00:00
parent 5bbba977d1
commit 5f0c20ec14
2 changed files with 6 additions and 2 deletions

2
BUGS
View file

@ -33,7 +33,5 @@ ide.c: synchronous disk write -> polling disk write. search for
fs.c: split all name operations off in name.c? (starting with namei but move fs.c: split all name operations off in name.c? (starting with namei but move
wdir keep in fs.c) wdir keep in fs.c)
unlink . and .. should be disallowed
ls.c: apply tim's patch ls.c: apply tim's patch

6
fs.c
View file

@ -579,6 +579,12 @@ namei(char *path, int mode, uint *ret_off,
found: found:
if(mode == NAMEI_DELETE && *cp == '\0'){ if(mode == NAMEI_DELETE && *cp == '\0'){
// can't unlink . and ..
if((i == 1 && memcmp(cp-1, ".", 1) == 0) ||
(i == 2 && memcmp(cp-2, "..", 2) == 0)){
iput(dp);
return 0;
}
*ret_off = off; *ret_off = off;
return dp; return dp;
} }