We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9b76955 commit 69b96f9Copy full SHA for 69b96f9
src/java.base/unix/native/libjava/io_util_md.c
@@ -32,6 +32,8 @@
32
33
#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(_AIX)
34
#include <sys/ioctl.h>
35
+#include <linux/fs.h>
36
+#include <sys/stat.h>
37
#endif
38
39
#ifdef MACOSX
@@ -245,9 +247,17 @@ handleGetLength(FD fd)
245
247
struct stat64 sb;
246
248
int result;
249
RESTARTABLE(fstat64(fd, &sb), result);
- if (result == 0) {
- return sb.st_size;
250
- } else {
+ if (result < 0) {
251
return -1;
252
}
253
+ #ifdef BLKGETSIZE64
254
+ if (S_ISBLK(sb.st_mode)) {
255
+ uint64_t size;
256
+ if(ioctl(fd, BLKGETSIZE64, &size) < 0) {
257
+ return -1;
258
+ }
259
+ return (jlong)size;
260
261
+ #endif
262
+ return sb.st_size;
263
0 commit comments