< prev index next >
src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -72,23 +72,13 @@
#define _STRUCTURED_PROC 1
#include <sys/procfs.h>
#endif /* _ALLBSD_SOURCE */
-static struct dirent* read_dir(DIR* dirp, struct dirent* entry) {
-#ifdef __solaris__
- struct dirent* dbuf = readdir(dirp);
- return dbuf;
-#else /* __linux__ || _ALLBSD_SOURCE */
- struct dirent* p;
- if (readdir_r(dirp, entry, &p) == 0) {
- return p;
- } else {
- return NULL;
- }
+#if defined(_ALLBSD_SOURCE)
+ #define readdir64 readdir
#endif
-}
// true = get available swap in bytes
// false = get total swap in bytes
static jlong get_total_or_available_swap_space_size(JNIEnv* env, jboolean available) {
#ifdef __solaris__
@@ -430,11 +420,10 @@
*/
// throw_internal_error(env, "Unimplemented in FreeBSD");
return (100);
#else /* solaris/linux */
DIR *dirp;
- struct dirent dbuf;
struct dirent* dentp;
jlong fds = 0;
#if defined(_AIX)
/* AIX does not understand '/proc/self' - it requires the real process ID */
@@ -451,11 +440,11 @@
return -1;
}
// iterate through directory entries, skipping '.' and '..'
// each entry represents an open file descriptor.
- while ((dentp = read_dir(dirp, &dbuf)) != NULL) {
+ while ((dentp = readdir64(dirp)) != NULL) {
if (isdigit(dentp->d_name[0])) {
fds++;
}
}
< prev index next >