# HG changeset patch # User bpb # Date 1434153926 25200 # Node ID 8154c9d7bc323b55df659a35cd730d098ca9509f # Parent 35889b7bb6e9da78e03a75264be0ddc4e065175c 8087288: File.get{Free,Total,Usable}Space may return unexpected results with >2TB file systems Summary: On Mac OS X replace statvfs64() and struct statvfs64 with statfs() and struct statfs, respectively, and f_frsize with f_bsize. Reviewed-by: alanb diff -r 35889b7bb6e9 -r 8154c9d7bc32 jdk/src/java.base/unix/native/libjava/UnixFileSystem_md.c --- a/jdk/src/java.base/unix/native/libjava/UnixFileSystem_md.c Fri Jun 12 16:40:05 2015 -0400 +++ b/jdk/src/java.base/unix/native/libjava/UnixFileSystem_md.c Fri Jun 12 17:05:26 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, 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 @@ -27,7 +27,12 @@ #include #include #include +#ifdef MACOSX +#include +#include +#else #include +#endif #include #include #include @@ -46,8 +51,10 @@ #define dirent64 dirent #define readdir64_r readdir_r #define stat64 stat +#ifndef MACOSX #define statvfs64 statvfs #endif +#endif /* -- Field IDs -- */ @@ -432,8 +439,32 @@ jlong rv = 0L; WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) { +#ifdef MACOSX + struct statfs fsstat; +#else struct statvfs64 fsstat; +#endif memset(&fsstat, 0, sizeof(fsstat)); +#ifdef MACOSX + if (statfs(path, &fsstat) == 0) { + switch(t) { + case java_io_FileSystem_SPACE_TOTAL: + rv = jlong_mul(long_to_jlong(fsstat.f_bsize), + long_to_jlong(fsstat.f_blocks)); + break; + case java_io_FileSystem_SPACE_FREE: + rv = jlong_mul(long_to_jlong(fsstat.f_bsize), + long_to_jlong(fsstat.f_bfree)); + break; + case java_io_FileSystem_SPACE_USABLE: + rv = jlong_mul(long_to_jlong(fsstat.f_bsize), + long_to_jlong(fsstat.f_bavail)); + break; + default: + assert(0); + } + } +#else if (statvfs64(path, &fsstat) == 0) { switch(t) { case java_io_FileSystem_SPACE_TOTAL: @@ -452,6 +483,7 @@ assert(0); } } +#endif } END_PLATFORM_STRING(env, path); return rv; }