mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8218811: replace open by os::open in hotspot coding
Reviewed-by: dholmes, iklam, stuefe
This commit is contained in:
parent
1d5674ab33
commit
4de51069e4
8 changed files with 17 additions and 22 deletions
|
@ -1062,7 +1062,7 @@ int64_t NetworkPerformanceInterface::NetworkPerformance::read_counter(const char
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "/sys/class/net/%s/statistics/%s", iface, counter);
|
snprintf(buf, sizeof(buf), "/sys/class/net/%s/statistics/%s", iface, counter);
|
||||||
|
|
||||||
int fd = open(buf, O_RDONLY);
|
int fd = os::open(buf, O_RDONLY, 0);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -97,8 +97,8 @@ static void save_memory_to_file(char* addr, size_t size) {
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
RESTARTABLE(::open(destfile, O_CREAT|O_WRONLY|O_TRUNC, S_IREAD|S_IWRITE),
|
RESTARTABLE(os::open(destfile, O_CREAT|O_WRONLY|O_TRUNC, S_IRUSR|S_IWUSR),
|
||||||
result);;
|
result);
|
||||||
if (result == OS_ERR) {
|
if (result == OS_ERR) {
|
||||||
if (PrintMiscellaneous && Verbose) {
|
if (PrintMiscellaneous && Verbose) {
|
||||||
warning("Could not create Perfdata save file: %s: %s\n",
|
warning("Could not create Perfdata save file: %s: %s\n",
|
||||||
|
@ -871,7 +871,7 @@ static int create_sharedmem_resources(const char* dirname, const char* filename,
|
||||||
// Cannot use O_TRUNC here; truncation of an existing file has to happen
|
// Cannot use O_TRUNC here; truncation of an existing file has to happen
|
||||||
// after the is_file_secure() check below.
|
// after the is_file_secure() check below.
|
||||||
int result;
|
int result;
|
||||||
RESTARTABLE(::open(filename, O_RDWR|O_CREAT|O_NOFOLLOW, S_IREAD|S_IWRITE), result);
|
RESTARTABLE(os::open(filename, O_RDWR|O_CREAT|O_NOFOLLOW, S_IRUSR|S_IWUSR), result);
|
||||||
if (result == OS_ERR) {
|
if (result == OS_ERR) {
|
||||||
if (PrintMiscellaneous && Verbose) {
|
if (PrintMiscellaneous && Verbose) {
|
||||||
if (errno == ELOOP) {
|
if (errno == ELOOP) {
|
||||||
|
@ -949,7 +949,7 @@ static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
|
||||||
|
|
||||||
// open the file
|
// open the file
|
||||||
int result;
|
int result;
|
||||||
RESTARTABLE(::open(filename, oflags), result);
|
RESTARTABLE(os::open(filename, oflags, 0), result);
|
||||||
if (result == OS_ERR) {
|
if (result == OS_ERR) {
|
||||||
if (errno == ENOENT) {
|
if (errno == ENOENT) {
|
||||||
THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
|
THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
|
||||||
|
|
|
@ -74,7 +74,7 @@ static int get_info(const char* path, void* info, size_t s, off_t o) {
|
||||||
|
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
||||||
if ((fd = open(path, O_RDONLY)) < 0) {
|
if ((fd = os::open(path, O_RDONLY, 0)) < 0) {
|
||||||
return OS_ERR;
|
return OS_ERR;
|
||||||
}
|
}
|
||||||
if (pread(fd, info, s, o) != s) {
|
if (pread(fd, info, s, o) != s) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -191,7 +191,7 @@ int ZBackingFile::create_file_fd(const char* name) const {
|
||||||
|
|
||||||
// Try to create an anonymous file using the O_TMPFILE flag. Note that this
|
// Try to create an anonymous file using the O_TMPFILE flag. Note that this
|
||||||
// flag requires kernel >= 3.11. If this fails we fall back to open/unlink.
|
// flag requires kernel >= 3.11. If this fails we fall back to open/unlink.
|
||||||
const int fd_anon = open(path.get(), O_TMPFILE|O_EXCL|O_RDWR|O_CLOEXEC, S_IRUSR|S_IWUSR);
|
const int fd_anon = os::open(path.get(), O_TMPFILE|O_EXCL|O_RDWR|O_CLOEXEC, S_IRUSR|S_IWUSR);
|
||||||
if (fd_anon == -1) {
|
if (fd_anon == -1) {
|
||||||
ZErrno err;
|
ZErrno err;
|
||||||
log_debug(gc, init)("Failed to create anonymous file in %s (%s)", path.get(),
|
log_debug(gc, init)("Failed to create anonymous file in %s (%s)", path.get(),
|
||||||
|
@ -217,7 +217,7 @@ int ZBackingFile::create_file_fd(const char* name) const {
|
||||||
snprintf(filename, sizeof(filename), "%s/%s.%d", path.get(), name, os::current_process_id());
|
snprintf(filename, sizeof(filename), "%s/%s.%d", path.get(), name, os::current_process_id());
|
||||||
|
|
||||||
// Create file
|
// Create file
|
||||||
const int fd = open(filename, O_CREAT|O_EXCL|O_RDWR|O_CLOEXEC, S_IRUSR|S_IWUSR);
|
const int fd = os::open(filename, O_CREAT|O_EXCL|O_RDWR|O_CLOEXEC, S_IRUSR|S_IWUSR);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
ZErrno err;
|
ZErrno err;
|
||||||
log_error(gc, init)("Failed to create file %s (%s)", filename, err.to_string());
|
log_error(gc, init)("Failed to create file %s (%s)", filename, err.to_string());
|
||||||
|
|
|
@ -1253,7 +1253,7 @@ void ciEnv::dump_replay_data(int compile_id) {
|
||||||
static char buffer[O_BUFLEN];
|
static char buffer[O_BUFLEN];
|
||||||
int ret = jio_snprintf(buffer, O_BUFLEN, "replay_pid%p_compid%d.log", os::current_process_id(), compile_id);
|
int ret = jio_snprintf(buffer, O_BUFLEN, "replay_pid%p_compid%d.log", os::current_process_id(), compile_id);
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
int fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
|
int fd = os::open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
FILE* replay_data_file = os::open(fd, "w");
|
FILE* replay_data_file = os::open(fd, "w");
|
||||||
if (replay_data_file != NULL) {
|
if (replay_data_file != NULL) {
|
||||||
|
@ -1271,7 +1271,7 @@ void ciEnv::dump_inline_data(int compile_id) {
|
||||||
static char buffer[O_BUFLEN];
|
static char buffer[O_BUFLEN];
|
||||||
int ret = jio_snprintf(buffer, O_BUFLEN, "inline_pid%p_compid%d.log", os::current_process_id(), compile_id);
|
int ret = jio_snprintf(buffer, O_BUFLEN, "inline_pid%p_compid%d.log", os::current_process_id(), compile_id);
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
int fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
|
int fd = os::open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
FILE* inline_data_file = os::open(fd, "w");
|
FILE* inline_data_file = os::open(fd, "w");
|
||||||
if (inline_data_file != NULL) {
|
if (inline_data_file != NULL) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -198,7 +198,7 @@ HashtableTextDump::HashtableTextDump(const char* filename) : _fd(-1) {
|
||||||
quit("Unable to get hashtable dump file size", filename);
|
quit("Unable to get hashtable dump file size", filename);
|
||||||
}
|
}
|
||||||
_size = st.st_size;
|
_size = st.st_size;
|
||||||
_fd = open(filename, O_RDONLY | O_BINARY, 0);
|
_fd = os::open(filename, O_RDONLY | O_BINARY, 0);
|
||||||
if (_fd < 0) {
|
if (_fd < 0) {
|
||||||
quit("Unable to open hashtable dump file", filename);
|
quit("Unable to open hashtable dump file", filename);
|
||||||
}
|
}
|
||||||
|
|
|
@ -561,7 +561,7 @@ bool FileMapInfo::init_from_file(int fd) {
|
||||||
// Read the FileMapInfo information from the file.
|
// Read the FileMapInfo information from the file.
|
||||||
bool FileMapInfo::open_for_read() {
|
bool FileMapInfo::open_for_read() {
|
||||||
_full_path = Arguments::GetSharedArchivePath();
|
_full_path = Arguments::GetSharedArchivePath();
|
||||||
int fd = open(_full_path, O_RDONLY | O_BINARY, 0);
|
int fd = os::open(_full_path, O_RDONLY | O_BINARY, 0);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
if (errno == ENOENT) {
|
if (errno == ENOENT) {
|
||||||
// Not locating the shared archive is ok.
|
// Not locating the shared archive is ok.
|
||||||
|
@ -596,7 +596,7 @@ void FileMapInfo::open_for_write() {
|
||||||
// Use remove() to delete the existing file because, on Unix, this will
|
// Use remove() to delete the existing file because, on Unix, this will
|
||||||
// allow processes that have it open continued access to the file.
|
// allow processes that have it open continued access to the file.
|
||||||
remove(_full_path);
|
remove(_full_path);
|
||||||
int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0444);
|
int fd = os::open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0444);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
fail_stop("Unable to create shared archive file %s: (%s).", _full_path,
|
fail_stop("Unable to create shared archive file %s: (%s).", _full_path,
|
||||||
os::strerror(errno));
|
os::strerror(errno));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -559,11 +559,6 @@ void fileStream::flush() {
|
||||||
fflush(_file);
|
fflush(_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
fdStream::fdStream(const char* file_name) {
|
|
||||||
_fd = open(file_name, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
|
||||||
_need_close = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
fdStream::~fdStream() {
|
fdStream::~fdStream() {
|
||||||
if (_fd != -1) {
|
if (_fd != -1) {
|
||||||
if (_need_close) close(_fd);
|
if (_need_close) close(_fd);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue