Skip to content

Commit 7dbb958

Browse files
committed
Backport of 9732fbe428c3b6a5422cc94e7295ba5482d1a7a9
1 parent 3533374 commit 7dbb958

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

src/hotspot/os/linux/os_linux.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,14 +1697,6 @@ const char* os::dll_file_extension() { return ".so"; }
16971697
// directory not the java application's temp directory, ala java.io.tmpdir.
16981698
const char* os::get_temp_directory() { return "/tmp"; }
16991699

1700-
static bool file_exists(const char* filename) {
1701-
struct stat statbuf;
1702-
if (filename == NULL || strlen(filename) == 0) {
1703-
return false;
1704-
}
1705-
return os::stat(filename, &statbuf) == 0;
1706-
}
1707-
17081700
// check if addr is inside libjvm.so
17091701
bool os::address_is_in_vm(address addr) {
17101702
static address libjvm_base_addr;
@@ -2738,7 +2730,7 @@ static void print_sys_devices_cpu_info(outputStream* st, char* buf, size_t bufle
27382730
snprintf(hbuf_type, 60, "/sys/devices/system/cpu/cpu0/cache/index%u/type", i);
27392731
snprintf(hbuf_size, 60, "/sys/devices/system/cpu/cpu0/cache/index%u/size", i);
27402732
snprintf(hbuf_coherency_line_size, 80, "/sys/devices/system/cpu/cpu0/cache/index%u/coherency_line_size", i);
2741-
if (file_exists(hbuf_level)) {
2733+
if (os::file_exists(hbuf_level)) {
27422734
_print_ascii_file_h("cache level", hbuf_level, st);
27432735
_print_ascii_file_h("cache type", hbuf_type, st);
27442736
_print_ascii_file_h("cache size", hbuf_size, st);

src/hotspot/share/logging/logFileOutput.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@ static size_t parse_value(const char* value_str) {
8383
return value;
8484
}
8585

86-
static bool file_exists(const char* filename) {
87-
struct stat dummy_stat;
88-
return os::stat(filename, &dummy_stat) == 0;
89-
}
90-
9186
static uint number_of_digits(uint number) {
9287
return number < 10 ? 1 : (number < 100 ? 2 : 3);
9388
}
@@ -130,7 +125,7 @@ static uint next_file_number(const char* filename,
130125
assert(ret > 0 && static_cast<size_t>(ret) == len - 1,
131126
"incorrect buffer length calculation");
132127

133-
if (file_exists(archive_name) && !is_regular_file(archive_name)) {
128+
if (os::file_exists(archive_name) && !is_regular_file(archive_name)) {
134129
// We've encountered something that's not a regular file among the
135130
// possible file rotation targets. Fail immediately to prevent
136131
// problems later.
@@ -141,7 +136,7 @@ static uint next_file_number(const char* filename,
141136
}
142137

143138
// Stop looking if we find an unused file name
144-
if (!file_exists(archive_name)) {
139+
if (!os::file_exists(archive_name)) {
145140
next_num = i;
146141
found = true;
147142
break;
@@ -224,7 +219,7 @@ bool LogFileOutput::initialize(const char* options, outputStream* errstream) {
224219
return false;
225220
}
226221

227-
bool file_exist = file_exists(_file_name);
222+
bool file_exist = os::file_exists(_file_name);
228223
if (file_exist && _is_default_file_count && is_fifo_file(_file_name)) {
229224
_file_count = 0; // Prevent file rotation for fifo's such as named pipes.
230225
}

src/hotspot/share/runtime/os.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,14 @@ bool os::set_boot_path(char fileSep, char pathSep) {
13611361
return false;
13621362
}
13631363

1364+
bool os::file_exists(const char* filename) {
1365+
struct stat statbuf;
1366+
if (filename == NULL || strlen(filename) == 0) {
1367+
return false;
1368+
}
1369+
return os::stat(filename, &statbuf) == 0;
1370+
}
1371+
13641372
/*
13651373
* Splits a path, based on its separator, the number of
13661374
* elements is returned back in n.

src/hotspot/share/runtime/os.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ class os: AllStatic {
587587
static FILE* fopen(const char* path, const char* mode);
588588
static int close(int fd);
589589
static jlong lseek(int fd, jlong offset, int whence);
590+
static bool file_exists(const char* file);
590591
// This function, on Windows, canonicalizes a given path (see os_windows.cpp for details).
591592
// On Posix, this function is a noop: it does not change anything and just returns
592593
// the input pointer.

0 commit comments

Comments
 (0)