hotspot/src/os/bsd/vm/os_bsd.cpp
changeset 27157 364276bc8d8b
parent 26704 36bff23b2c2e
child 27400 c5955f4b7c84
equal deleted inserted replaced
27007:3cacf4ad4fc9 27157:364276bc8d8b
  3843 }
  3843 }
  3844 
  3844 
  3845 // This code originates from JDK's sysOpen and open64_w
  3845 // This code originates from JDK's sysOpen and open64_w
  3846 // from src/solaris/hpi/src/system_md.c
  3846 // from src/solaris/hpi/src/system_md.c
  3847 
  3847 
  3848 #ifndef O_DELETE
       
  3849   #define O_DELETE 0x10000
       
  3850 #endif
       
  3851 
       
  3852 // Open a file. Unlink the file immediately after open returns
       
  3853 // if the specified oflag has the O_DELETE flag set.
       
  3854 // O_DELETE is used only in j2se/src/share/native/java/util/zip/ZipFile.c
       
  3855 
       
  3856 int os::open(const char *path, int oflag, int mode) {
  3848 int os::open(const char *path, int oflag, int mode) {
  3857   if (strlen(path) > MAX_PATH - 1) {
  3849   if (strlen(path) > MAX_PATH - 1) {
  3858     errno = ENAMETOOLONG;
  3850     errno = ENAMETOOLONG;
  3859     return -1;
  3851     return -1;
  3860   }
  3852   }
  3861   int fd;
  3853   int fd;
  3862   int o_delete = (oflag & O_DELETE);
       
  3863   oflag = oflag & ~O_DELETE;
       
  3864 
  3854 
  3865   fd = ::open(path, oflag, mode);
  3855   fd = ::open(path, oflag, mode);
  3866   if (fd == -1) return -1;
  3856   if (fd == -1) return -1;
  3867 
  3857 
  3868   // If the open succeeded, the file might still be a directory
  3858   // If the open succeeded, the file might still be a directory
  3911       ::fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
  3901       ::fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
  3912     }
  3902     }
  3913   }
  3903   }
  3914 #endif
  3904 #endif
  3915 
  3905 
  3916   if (o_delete != 0) {
       
  3917     ::unlink(path);
       
  3918   }
       
  3919   return fd;
  3906   return fd;
  3920 }
  3907 }
  3921 
  3908 
  3922 
  3909 
  3923 // create binary file, rewriting existing file if required
  3910 // create binary file, rewriting existing file if required