root/user/dorphan.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

   1 #include "kernel/types.h"
   2 #include "kernel/stat.h"
   3 #include "kernel/fcntl.h"
   4 #include "user/user.h"
   5 
   6 // Create an orphaned directory and check if test-xv6.py recovers it.
   7 
   8 #define BUFSZ 500
   9 
  10 char buf[BUFSZ];
  11 
  12 int
  13 main(int argc, char **argv)
  14 {
  15   char *s = argv[0];
  16 
  17   if(mkdir("dd") != 0){
  18     printf("%s: mkdir dd failed\n", s);
  19     exit(1);
  20   }
  21 
  22   if(chdir("dd") != 0){
  23     printf("%s: chdir dd failed\n", s);
  24     exit(1);
  25   }
  26 
  27   if (unlink("../dd") < 0) {
  28     printf("%s: unlink failed\n", s);
  29     exit(1);
  30   }
  31   printf("wait for kill and reclaim\n");
  32   // sit around until killed
  33   for(;;) pause(1000);
  34 }

/* [<][>][^][v][top][bottom][index][help] */