open-calls in hotspot code instead of os::open ?

Baesken, Matthias matthias.baesken at sap.com
Wed Feb 6 13:18:40 UTC 2019


Hello,  I noticed a few  calls to open instead of os::open  in the hotspot C++ code .
For example :

share/memory/filemap.cpp:553:  int fd = open(_full_path, O_RDONLY | O_BINARY, 0);
share/memory/filemap.cpp:588:  int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0444);
share/utilities/vmError.cpp:1197:    fd = open(buf, O_RDWR | O_CREAT | O_EXCL, 0666);
share/utilities/ostream.cpp:563:  _fd = open(file_name, O_WRONLY | O_CREAT | O_TRUNC, 0666);

share/ci/ciEnv.cpp:1256:    int fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
share/ci/ciEnv.cpp:1274:    int fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
share/classfile/compactHashtable.cpp:201:  _fd = open(filename, O_RDONLY | O_BINARY, 0);
share/compiler/compileLog.cpp:210:    int partial_fd = open(partial_file, O_RDONLY);


This might be often fine, but  in special  cases   we miss  platform specific   extensions  done in  os::open  ,
for example  for Windows the  unc/extended path handling done in os::open   ( calls create_unc_path  for long paths)  :


int os::open(const char *path, int oflag, int mode) {
  char* pathbuf = (char*)os::strdup(path, mtInternal);
  . . .
  os::native_path(pathbuf);
  int ret;
  if (strlen(path) < MAX_PATH) {
    ret = ::open(pathbuf, oflag | O_BINARY | O_NOINHERIT, mode);
  } else {
    errno_t err = ERROR_SUCCESS;
    wchar_t* wpath = create_unc_path(pathbuf, err);
     .  . .
    ret = ::_wopen(wpath, oflag | O_BINARY | O_NOINHERIT, mode);


Should I open a bug and replace   the open calls  by os::open   ?

Thanks , Matthias





More information about the hotspot-dev mailing list