< prev index next >

src/hotspot/os/posix/os_posix.cpp

Print this page

        

*** 62,71 **** --- 62,77 ---- #ifndef MAP_ANONYMOUS #define MAP_ANONYMOUS MAP_ANON #endif + #ifndef O_TMPFILE + #ifdef __O_TMPFILE + #define O_TMPFILE __O_TMPFILE + #endif + #endif + #define check_with_errno(check_type, cond, msg) \ do { \ int err = errno; \ check_type(cond, "%s; error='%s' (errno=%s)", msg, os::strerror(err), \ os::errno_name(err)); \
*** 174,184 **** --- 180,199 ---- // don't do anything on posix platforms return; } int os::create_file_for_heap(const char* dir) { + char* native_dir = os::strdup(dir); + if (native_dir == NULL) { + vm_exit_during_initialization(err_msg("strdup failed during creation of backing file for heap (%s)", os::strerror(errno))); + return -1; + } + os::native_path(native_dir); + int fd = os::open(dir, O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR); + os::free(native_dir); + if (fd == -1) { const char name_template[] = "/jvmheap.XXXXXX"; size_t fullname_len = strlen(dir) + strlen(name_template); char *fullname = (char*)os::malloc(fullname_len + 1, mtInternal); if (fullname == NULL) {
*** 188,214 **** int n = snprintf(fullname, fullname_len + 1, "%s%s", dir, name_template); assert((size_t)n == fullname_len, "Unexpected number of characters in string"); os::native_path(fullname); - // set the file creation mask. - mode_t file_mode = S_IRUSR | S_IWUSR; - // create a new file. ! int fd = mkstemp(fullname); if (fd < 0) { warning("Could not create file for heap with template %s", fullname); os::free(fullname); return -1; ! } ! // delete the name from the filesystem. When 'fd' is closed, the file (and space) will be deleted. int ret = unlink(fullname); assert_with_errno(ret == 0, "unlink returned error"); os::free(fullname); return fd; } static char* reserve_mmapped_memory(size_t bytes, char* requested_addr) { char * addr; --- 203,228 ---- int n = snprintf(fullname, fullname_len + 1, "%s%s", dir, name_template); assert((size_t)n == fullname_len, "Unexpected number of characters in string"); os::native_path(fullname); // create a new file. ! fd = mkstemp(fullname); if (fd < 0) { warning("Could not create file for heap with template %s", fullname); os::free(fullname); return -1; ! } else { // delete the name from the filesystem. When 'fd' is closed, the file (and space) will be deleted. int ret = unlink(fullname); assert_with_errno(ret == 0, "unlink returned error"); + } os::free(fullname); + } + return fd; } static char* reserve_mmapped_memory(size_t bytes, char* requested_addr) { char * addr;
< prev index next >