Skip to content
Snippets Groups Projects
Commit 4e015d81 authored by Austin Clements's avatar Austin Clements
Browse files

Shorten sys_unlink a little; create now fits in column

parent 9bb1e53d
No related branches found
No related tags found
No related merge requests found
...@@ -188,26 +188,18 @@ sys_unlink(void) ...@@ -188,26 +188,18 @@ sys_unlink(void)
ilock(dp); ilock(dp);
// Cannot unlink "." or "..". // Cannot unlink "." or "..".
if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0){ if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0)
iunlockput(dp); goto bad;
commit_trans();
return -1;
}
if((ip = dirlookup(dp, name, &off)) == 0){ if((ip = dirlookup(dp, name, &off)) == 0)
iunlockput(dp); goto bad;
commit_trans();
return -1;
}
ilock(ip); ilock(ip);
if(ip->nlink < 1) if(ip->nlink < 1)
panic("unlink: nlink < 1"); panic("unlink: nlink < 1");
if(ip->type == T_DIR && !isdirempty(ip)){ if(ip->type == T_DIR && !isdirempty(ip)){
iunlockput(ip); iunlockput(ip);
iunlockput(dp); goto bad;
commit_trans();
return -1;
} }
memset(&de, 0, sizeof(de)); memset(&de, 0, sizeof(de));
...@@ -226,6 +218,11 @@ sys_unlink(void) ...@@ -226,6 +218,11 @@ sys_unlink(void)
commit_trans(); commit_trans();
return 0; return 0;
bad:
iunlockput(dp);
commit_trans();
return -1;
} }
static struct inode* static struct inode*
......
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