src/share/vm/memory/filemap.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File bug_8072694_errno Sdiff src/share/vm/memory

src/share/vm/memory/filemap.cpp

Print this page


   1 /*
   2  * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 371 
 372 
 373 // Write the FileMapInfo information to the file.
 374 
 375 void FileMapInfo::open_for_write() {
 376  _full_path = Arguments::GetSharedArchivePath();
 377   if (PrintSharedSpaces) {
 378     tty->print_cr("Dumping shared data to file: ");
 379     tty->print_cr("   %s", _full_path);
 380   }
 381 
 382 #ifdef _WINDOWS  // On Windows, need WRITE permission to remove the file.
 383   chmod(_full_path, _S_IREAD | _S_IWRITE);
 384 #endif
 385 
 386   // Use remove() to delete the existing file because, on Unix, this will
 387   // allow processes that have it open continued access to the file.
 388   remove(_full_path);
 389   int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0444);
 390   if (fd < 0) {
 391     fail_stop("Unable to create shared archive file %s.", _full_path);

 392   }
 393   _fd = fd;
 394   _file_offset = 0;
 395   _file_open = true;
 396 }
 397 
 398 
 399 // Write the header to the file, seek to the next allocation boundary.
 400 
 401 void FileMapInfo::write_header() {
 402   int info_size = ClassLoader::get_shared_paths_misc_info_size();
 403 
 404   _header->_paths_misc_info_size = info_size;
 405 
 406   align_file_position();
 407   size_t sz = _header->data_size();
 408   char* addr = _header->data();
 409   write_bytes(addr, (int)sz); // skip the C++ vtable
 410   write_bytes(ClassLoader::get_shared_paths_misc_info(), info_size);
 411   align_file_position();


   1 /*
   2  * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 371 
 372 
 373 // Write the FileMapInfo information to the file.
 374 
 375 void FileMapInfo::open_for_write() {
 376  _full_path = Arguments::GetSharedArchivePath();
 377   if (PrintSharedSpaces) {
 378     tty->print_cr("Dumping shared data to file: ");
 379     tty->print_cr("   %s", _full_path);
 380   }
 381 
 382 #ifdef _WINDOWS  // On Windows, need WRITE permission to remove the file.
 383   chmod(_full_path, _S_IREAD | _S_IWRITE);
 384 #endif
 385 
 386   // Use remove() to delete the existing file because, on Unix, this will
 387   // allow processes that have it open continued access to the file.
 388   remove(_full_path);
 389   int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0444);
 390   if (fd < 0) {
 391     fail_stop("Unable to create shared archive file %s: %s.", _full_path,
 392               strerror(errno));
 393   }
 394   _fd = fd;
 395   _file_offset = 0;
 396   _file_open = true;
 397 }
 398 
 399 
 400 // Write the header to the file, seek to the next allocation boundary.
 401 
 402 void FileMapInfo::write_header() {
 403   int info_size = ClassLoader::get_shared_paths_misc_info_size();
 404 
 405   _header->_paths_misc_info_size = info_size;
 406 
 407   align_file_position();
 408   size_t sz = _header->data_size();
 409   char* addr = _header->data();
 410   write_bytes(addr, (int)sz); // skip the C++ vtable
 411   write_bytes(ClassLoader::get_shared_paths_misc_info(), info_size);
 412   align_file_position();


src/share/vm/memory/filemap.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File