From 5f0c20ec14dc1c97519e0843d715fd91b430e77c Mon Sep 17 00:00:00 2001 From: rsc Date: Wed, 8 Aug 2007 09:08:29 +0000 Subject: [PATCH] fix . .. unlink bug --- BUGS | 2 -- fs.c | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/BUGS b/BUGS index 2f6d8bc..509b414 100644 --- a/BUGS +++ b/BUGS @@ -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 wdir keep in fs.c) - unlink . and .. should be disallowed - ls.c: apply tim's patch diff --git a/fs.c b/fs.c index 3f0a71d..8f7b872 100644 --- a/fs.c +++ b/fs.c @@ -579,6 +579,12 @@ namei(char *path, int mode, uint *ret_off, found: 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; return dp; }