8162520: (fs) FileStore should support file stores with > Long.MAX_VALUE capacity

Reviewed-by: alanb, darcy, rriggs
This commit is contained in:
Brian Burkhalter 2019-11-01 13:16:50 -07:00
parent 012dffcd27
commit 2cea148cdf
3 changed files with 61 additions and 40 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2019, 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
@ -118,13 +118,31 @@ abstract class UnixFileStore
@Override
public long getTotalSpace() throws IOException {
UnixFileStoreAttributes attrs = readAttributes();
return attrs.blockSize() * attrs.totalBlocks();
try {
return Math.multiplyExact(attrs.blockSize(), attrs.totalBlocks());
} catch (ArithmeticException ignore) {
return Long.MAX_VALUE;
}
}
@Override
public long getUsableSpace() throws IOException {
UnixFileStoreAttributes attrs = readAttributes();
return attrs.blockSize() * attrs.availableBlocks();
UnixFileStoreAttributes attrs = readAttributes();
try {
return Math.multiplyExact(attrs.blockSize(), attrs.availableBlocks());
} catch (ArithmeticException ignore) {
return Long.MAX_VALUE;
}
}
@Override
public long getUnallocatedSpace() throws IOException {
UnixFileStoreAttributes attrs = readAttributes();
try {
return Math.multiplyExact(attrs.blockSize(), attrs.freeBlocks());
} catch (ArithmeticException ignore) {
return Long.MAX_VALUE;
}
}
@Override
@ -133,12 +151,6 @@ abstract class UnixFileStore
return attrs.blockSize();
}
@Override
public long getUnallocatedSpace() throws IOException {
UnixFileStoreAttributes attrs = readAttributes();
return attrs.blockSize() * attrs.freeBlocks();
}
@Override
public <V extends FileStoreAttributeView> V getFileStoreAttributeView(Class<V> view)
{