diff options
author | rtm <rtm> | 2007-08-24 14:56:17 +0000 |
---|---|---|
committer | rtm <rtm> | 2007-08-24 14:56:17 +0000 |
commit | 2036534834841641edf3a6d1e142c4798e146b7b (patch) | |
tree | 2f2b1bbeff631d55d7ec0dc1bd0b5271723e95bf /usertests.c | |
parent | b55513796f2234d1fbdb816015506f981befb60d (diff) | |
download | xv6-labs-2036534834841641edf3a6d1e142c4798e146b7b.tar.gz xv6-labs-2036534834841641edf3a6d1e142c4798e146b7b.tar.bz2 xv6-labs-2036534834841641edf3a6d1e142c4798e146b7b.zip |
add missing iput() at end of _namei()
Diffstat (limited to 'usertests.c')
-rw-r--r-- | usertests.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/usertests.c b/usertests.c index 7132666..3a9cd9a 100644 --- a/usertests.c +++ b/usertests.c @@ -1096,6 +1096,99 @@ rmdot(void) printf(1, "rmdot ok\n"); } +void +dirfile(void) +{ + int fd; + + printf(1, "dir vs file\n"); + + fd = open("dirfile", O_CREATE); + if(fd < 0){ + printf(1, "create dirfile failed\n"); + exit(); + } + close(fd); + if(chdir("dirfile") == 0){ + printf(1, "chdir dirfile succeeded!\n"); + exit(); + } + fd = open("dirfile/xx", 0); + if(fd >= 0){ + printf(1, "create dirfile/xx succeeded!\n"); + exit(); + } + fd = open("dirfile/xx", O_CREATE); + if(fd >= 0){ + printf(1, "create dirfile/xx succeeded!\n"); + exit(); + } + if(mkdir("dirfile/xx") == 0){ + printf(1, "mkdir dirfile/xx succeeded!\n"); + exit(); + } + if(unlink("dirfile/xx") == 0){ + printf(1, "unlink dirfile/xx succeeded!\n"); + exit(); + } + if(link("README", "dirfile/xx") == 0){ + printf(1, "link to dirfile/xx succeeded!\n"); + exit(); + } + if(unlink("dirfile") != 0){ + printf(1, "unlink dirfile failed!\n"); + exit(); + } + + fd = open(".", O_RDWR); + if(fd >= 0){ + printf(1, "open . for writing succeeded!\n"); + exit(); + } + fd = open(".", 0); + if(write(fd, "x", 1) > 0){ + printf(1, "write . succeeded!\n"); + exit(); + } + close(fd); + + printf(1, "dir vs file OK\n"); +} + +// test that iput() is called at the end of _namei() +void +iref(void) +{ + int i, fd; + + printf(1, "empty file name\n"); + + // the 50 is NINODE + for(i = 0; i < 50 + 1; i++){ + if(mkdir("irefd") != 0){ + printf(1, "mkdir irefd failed\n"); + exit(); + } + if(chdir("irefd") != 0){ + printf(1, "chdir irefd failed\n"); + exit(); + } + + mkdir(""); + link("README", ""); + fd = open("", O_CREATE); + if(fd >= 0) + close(fd); + fd = open("xx", O_CREATE); + if(fd >= 0) + close(fd); + unlink("xx"); + } + + chdir("/"); + printf(1, "empty file name OK\n"); +} + int main(int argc, char *argv[]) { @@ -1128,6 +1221,8 @@ main(int argc, char *argv[]) createdelete(); twofiles(); sharedfd(); + dirfile(); + iref(); exectest(); |