mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8266610: Method RandomAccessFile#length() returns 0 for block devices on linux.
Reviewed-by: alanb, bpb
This commit is contained in:
parent
9b76955024
commit
69b96f9a1b
1 changed files with 13 additions and 3 deletions
|
@ -32,6 +32,8 @@
|
|||
|
||||
#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(_AIX)
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/fs.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#ifdef MACOSX
|
||||
|
@ -245,9 +247,17 @@ handleGetLength(FD fd)
|
|||
struct stat64 sb;
|
||||
int result;
|
||||
RESTARTABLE(fstat64(fd, &sb), result);
|
||||
if (result == 0) {
|
||||
return sb.st_size;
|
||||
} else {
|
||||
if (result < 0) {
|
||||
return -1;
|
||||
}
|
||||
#ifdef BLKGETSIZE64
|
||||
if (S_ISBLK(sb.st_mode)) {
|
||||
uint64_t size;
|
||||
if(ioctl(fd, BLKGETSIZE64, &size) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return (jlong)size;
|
||||
}
|
||||
#endif
|
||||
return sb.st_size;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue