user/usertests.c
void
openiputtest(void)
{
  int pid;

  printf("openiput test\n");
  if(mkdir("oidir") < 0){
    printf("mkdir oidir failed\n");
    exit(1);
  }
  pid = fork();
  if(pid < 0){
    printf("fork failed\n");
    exit(1);
  }
  if(pid == 0){
    int fd = open("oidir", O_RDWR);
    if(fd >= 0){
      printf("open directory for write succeeded\n");
      exit(1);
    }
    exit(0);
  }
  sleep(1);
  if(unlink("oidir") != 0){
    printf("unlink failed\n");
    exit(1);
  }
  wait(0);
  printf("openiput test ok\n");
}
// does the error path in open() for attempt to write a
// directory call iput() in a transaction?
// needs a hacked kernel that pauses just after the namei()
// call in sys_open():
//    if((ip = namei(path)) == 0)
//      return -1;
//    {
//      int i;
//      for(i = 0; i < 10000; i++)
//        yield();
//    }
does the error path in open() for attempt to write a
directory call iput() in a transaction.
does the error path in open () for attempt to write a directory call iput () in a transaction .
void
openiputtest(void)
{
  int pid;
  printf("openiput test\n");
  if(mkdir("oidir") < 0){
    printf("mkdir oidir failed\n");
    exit(1);
  }
  pid = fork();
  if(pid < 0){
    printf("fork failed\n");
    exit(1);
  }
  if(pid == 0){
    int fd = open("oidir", O_RDWR);
    if(fd >= 0){
      printf("open directory for write succeeded\n");
      exit(1);
    }
    exit(0);
  }
  sleep(1);
  if(unlink("oidir") != 0){
    printf("unlink failed\n");
    exit(1);
  }
  wait(0);
  printf("openiput test ok\n");
}
void openiputtest ( void ) { int pid ; printf ( " \n " ) ; if ( mkdir ( " " ) < 0 ) { printf ( " \n " ) ; exit ( 1 ) ; } pid = fork ( ) ; if ( pid < 0 ) { printf ( " \n " ) ; exit ( 1 ) ; } if ( pid == 0 ) { int fd = open ( " " , O_RDWR ) ; if ( fd >= 0 ) { printf ( " \n " ) ; exit ( 1 ) ; } exit ( 0 ) ; } sleep ( 1 ) ; if ( unlink ( " " ) != 0 ) { printf ( " \n " ) ; exit ( 1 ) ; } wait ( 0 ) ; printf ( " \n " ) ; }
does the error path in open() for attempt to write a
directory call iput() in a transaction?
does the error path in open () for attempt to write a directory call iput () in a transaction?