8313368: (fc) FileChannel.size returns 0 on block special files
Reviewed-by: vtewari, alanb
This commit is contained in:
parent
c1a3f143bf
commit
4ba81f631f
@ -45,6 +45,11 @@
|
||||
#define fstatvfs64 fstatvfs
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <linux/fs.h>
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#include "jni.h"
|
||||
#include "nio.h"
|
||||
#include "nio_util.h"
|
||||
@ -169,7 +174,7 @@ Java_sun_nio_ch_UnixFileDispatcherImpl_size0(JNIEnv *env, jobject this, jobject
|
||||
if (fstat64(fd, &fbuf) < 0)
|
||||
return handle(env, -1, "Size failed");
|
||||
|
||||
#ifdef BLKGETSIZE64
|
||||
#if defined(__linux__)
|
||||
if (S_ISBLK(fbuf.st_mode)) {
|
||||
uint64_t size;
|
||||
if (ioctl(fd, BLKGETSIZE64, &size) < 0)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2023, 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
|
||||
@ -22,9 +22,10 @@
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 8054029
|
||||
* @bug 8054029 8313368
|
||||
* @requires (os.family == "linux")
|
||||
* @summary Block devices should not report size=0 on Linux
|
||||
* @run main/manual BlockDeviceSize
|
||||
*/
|
||||
|
||||
import java.io.RandomAccessFile;
|
||||
@ -56,8 +57,8 @@ public class BlockDeviceSize {
|
||||
System.err.println("File " + BLK_FNAME + " not found." +
|
||||
" Skipping test");
|
||||
} catch (AccessDeniedException ade) {
|
||||
System.err.println("Access to " + BLK_FNAME + " is denied." +
|
||||
" Run test as root.");
|
||||
throw new RuntimeException("Access to " + BLK_FNAME + " is denied."
|
||||
+ " Run test as root.", ade);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user