diff options
author | Austin Clements <[email protected]> | 2011-09-02 15:20:27 -0400 |
---|---|---|
committer | Austin Clements <[email protected]> | 2011-09-02 15:20:27 -0400 |
commit | 4e015d81aabb19d319fa73f2da11cd6b7ca5c2c3 (patch) | |
tree | e01138f4b1cba470100f63ee8cf5b677dd955bde | |
parent | 9bb1e53df5cd77986d126cb7800066b6190d684f (diff) | |
download | xv6-labs-4e015d81aabb19d319fa73f2da11cd6b7ca5c2c3.tar.gz xv6-labs-4e015d81aabb19d319fa73f2da11cd6b7ca5c2c3.tar.bz2 xv6-labs-4e015d81aabb19d319fa73f2da11cd6b7ca5c2c3.zip |
Shorten sys_unlink a little; create now fits in column
-rw-r--r-- | sysfile.c | 23 |
1 files changed, 10 insertions, 13 deletions
@@ -188,26 +188,18 @@ sys_unlink(void) ilock(dp); // Cannot unlink "." or "..". - if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0){ - iunlockput(dp); - commit_trans(); - return -1; - } + if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0) + goto bad; - if((ip = dirlookup(dp, name, &off)) == 0){ - iunlockput(dp); - commit_trans(); - return -1; - } + if((ip = dirlookup(dp, name, &off)) == 0) + goto bad; ilock(ip); if(ip->nlink < 1) panic("unlink: nlink < 1"); if(ip->type == T_DIR && !isdirempty(ip)){ iunlockput(ip); - iunlockput(dp); - commit_trans(); - return -1; + goto bad; } memset(&de, 0, sizeof(de)); @@ -226,6 +218,11 @@ sys_unlink(void) commit_trans(); return 0; + +bad: + iunlockput(dp); + commit_trans(); + return -1; } static struct inode* |