hotspot/src/os/aix/vm/os_aix.cpp
changeset 27157 364276bc8d8b
parent 26693 f2910bf56d71
child 27400 c5955f4b7c84
equal deleted inserted replaced
27007:3cacf4ad4fc9 27157:364276bc8d8b
  4023 }
  4023 }
  4024 
  4024 
  4025 // This code originates from JDK's sysOpen and open64_w
  4025 // This code originates from JDK's sysOpen and open64_w
  4026 // from src/solaris/hpi/src/system_md.c
  4026 // from src/solaris/hpi/src/system_md.c
  4027 
  4027 
  4028 #ifndef O_DELETE
       
  4029 #define O_DELETE 0x10000
       
  4030 #endif
       
  4031 
       
  4032 // Open a file. Unlink the file immediately after open returns
       
  4033 // if the specified oflag has the O_DELETE flag set.
       
  4034 // O_DELETE is used only in j2se/src/share/native/java/util/zip/ZipFile.c
       
  4035 
       
  4036 int os::open(const char *path, int oflag, int mode) {
  4028 int os::open(const char *path, int oflag, int mode) {
  4037 
  4029 
  4038   if (strlen(path) > MAX_PATH - 1) {
  4030   if (strlen(path) > MAX_PATH - 1) {
  4039     errno = ENAMETOOLONG;
  4031     errno = ENAMETOOLONG;
  4040     return -1;
  4032     return -1;
  4041   }
  4033   }
  4042   int fd;
  4034   int fd;
  4043   int o_delete = (oflag & O_DELETE);
       
  4044   oflag = oflag & ~O_DELETE;
       
  4045 
  4035 
  4046   fd = ::open64(path, oflag, mode);
  4036   fd = ::open64(path, oflag, mode);
  4047   if (fd == -1) return -1;
  4037   if (fd == -1) return -1;
  4048 
  4038 
  4049   // If the open succeeded, the file might still be a directory.
  4039   // If the open succeeded, the file might still be a directory.
  4090     if (flags != -1)
  4080     if (flags != -1)
  4091       ::fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
  4081       ::fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
  4092   }
  4082   }
  4093 #endif
  4083 #endif
  4094 
  4084 
  4095   if (o_delete != 0) {
       
  4096     ::unlink(path);
       
  4097   }
       
  4098   return fd;
  4085   return fd;
  4099 }
  4086 }
  4100 
  4087 
  4101 
  4088 
  4102 // create binary file, rewriting existing file if required
  4089 // create binary file, rewriting existing file if required