diff options
Diffstat (limited to 'user')
| -rw-r--r-- | user/grep.c | 3 | ||||
| -rw-r--r-- | user/user.h | 2 | ||||
| -rw-r--r-- | user/usertests.c | 35 | 
3 files changed, 38 insertions, 2 deletions
| diff --git a/user/grep.c b/user/grep.c index 19882b9..2315a0c 100644 --- a/user/grep.c +++ b/user/grep.c @@ -62,7 +62,8 @@ main(int argc, char *argv[])  }  // Regexp matcher from Kernighan & Pike, -// The Practice of Programming, Chapter 9. +// The Practice of Programming, Chapter 9, or +// https://www.cs.princeton.edu/courses/archive/spr09/cos333/beautiful.html  int matchhere(char*, char*);  int matchstar(int, char*, char*); diff --git a/user/user.h b/user/user.h index 8ac6395..4d398d5 100644 --- a/user/user.h +++ b/user/user.h @@ -9,7 +9,7 @@ int write(int, const void*, int);  int read(int, void*, int);  int close(int);  int kill(int); -int exec(char*, char**); +int exec(const char*, char**);  int open(const char*, int);  int mknod(const char*, short, short);  int unlink(const char*); diff --git a/user/usertests.c b/user/usertests.c index 0a84ef9..7c31013 100644 --- a/user/usertests.c +++ b/user/usertests.c @@ -2737,6 +2737,8 @@ diskfull(char *s)  {    int fi;    int done = 0; + +  unlink("diskfulldir");    for(fi = 0; done == 0; fi++){      char name[32]; @@ -2763,6 +2765,39 @@ diskfull(char *s)      close(fd);    } +  // now that there are no free blocks, test that dirlink() +  // merely fails (doesn't panic) if it can't extend +  // directory content. +  int nzz = 128; +  for(int i = 0; i < nzz; i++){ +    char name[32]; +    name[0] = 'z'; +    name[1] = 'z'; +    name[2] = '0' + (i / 32); +    name[3] = '0' + (i % 32); +    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); +      break; +    } +    close(fd); +  } + +  mkdir("diskfulldir"); +  unlink("diskfulldir"); + +  for(int i = 0; i < nzz; i++){ +    char name[32]; +    name[0] = 'z'; +    name[1] = 'z'; +    name[2] = '0' + (i / 32); +    name[3] = '0' + (i % 32); +    name[4] = '\0'; +    unlink(name); +  } +    for(int i = 0; i < fi; i++){      char name[32];      name[0] = 'b'; | 
