diff options
author | Robert Morris <[email protected]> | 2022-08-10 06:13:52 -0400 |
---|---|---|
committer | Robert Morris <[email protected]> | 2022-08-10 06:13:52 -0400 |
commit | 872fa88e8afd24a8f228ba431fad380d326b0f36 (patch) | |
tree | 8577fd7cfd9067a34eb6b8a2b41925cabcd0d014 /user/usertests.c | |
parent | 7d573bae2ab70f0d0bd1807f0099c00e8f9e24f2 (diff) | |
download | xv6-labs-872fa88e8afd24a8f228ba431fad380d326b0f36.tar.gz xv6-labs-872fa88e8afd24a8f228ba431fad380d326b0f36.tar.bz2 xv6-labs-872fa88e8afd24a8f228ba431fad380d326b0f36.zip |
tolerate running out of disk blocks
Diffstat (limited to 'user/usertests.c')
-rw-r--r-- | user/usertests.c | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/user/usertests.c b/user/usertests.c index 0fe7371..4ab34da 100644 --- a/user/usertests.c +++ b/user/usertests.c @@ -2706,6 +2706,49 @@ execout(char *s) exit(0); } +// can the kernel tolerate running out of disk space? +void +diskfull(char *s) +{ + int fi; + int done = 0; + + for(fi = 0; done == 0; fi++){ + char name[32]; + name[0] = 'b'; + name[1] = 'i'; + name[2] = 'g'; + name[3] = '0' + fi; + name[4] = '\0'; + unlink(name); + int fd = open(name, O_CREATE|O_RDWR|O_TRUNC); + if(fd < 0){ + printf("%s: could not create file %s\n", s, name); + done = 1; + break; + } + for(int i = 0; i < MAXFILE; i++){ + char buf[BSIZE]; + if(write(fd, buf, BSIZE) != BSIZE){ + done = 1; + close(fd); + break; + } + } + close(fd); + } + + for(int i = 0; i < fi; i++){ + char name[32]; + name[0] = 'b'; + name[1] = 'i'; + name[2] = 'g'; + name[3] = '0' + i; + name[4] = '\0'; + unlink(name); + } +} + // // use sbrk() to count how many free physical memory pages there are. // touches the pages to force allocation. @@ -2818,7 +2861,7 @@ main(int argc, char *argv[]) void (*f)(char *); char *s; } tests[] = { - {MAXVAplus, "MAXVAplus"}, + {diskfull, "diskfull"}, {manywrites, "manywrites"}, {execout, "execout"}, {copyin, "copyin"}, @@ -2880,6 +2923,7 @@ main(int argc, char *argv[]) {dirfile, "dirfile"}, {iref, "iref"}, {forktest, "forktest"}, + {MAXVAplus, "MAXVAplus"}, {bigdir, "bigdir"}, // slow { 0, 0}, }; |