1 /* |
1 /* |
2 * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
116 } |
116 } |
117 |
117 |
118 @Override |
118 @Override |
119 public long getTotalSpace() throws IOException { |
119 public long getTotalSpace() throws IOException { |
120 UnixFileStoreAttributes attrs = readAttributes(); |
120 UnixFileStoreAttributes attrs = readAttributes(); |
121 return attrs.blockSize() * attrs.totalBlocks(); |
121 try { |
|
122 return Math.multiplyExact(attrs.blockSize(), attrs.totalBlocks()); |
|
123 } catch (ArithmeticException ignore) { |
|
124 return Long.MAX_VALUE; |
|
125 } |
122 } |
126 } |
123 |
127 |
124 @Override |
128 @Override |
125 public long getUsableSpace() throws IOException { |
129 public long getUsableSpace() throws IOException { |
126 UnixFileStoreAttributes attrs = readAttributes(); |
130 UnixFileStoreAttributes attrs = readAttributes(); |
127 return attrs.blockSize() * attrs.availableBlocks(); |
131 try { |
|
132 return Math.multiplyExact(attrs.blockSize(), attrs.availableBlocks()); |
|
133 } catch (ArithmeticException ignore) { |
|
134 return Long.MAX_VALUE; |
|
135 } |
|
136 } |
|
137 |
|
138 @Override |
|
139 public long getUnallocatedSpace() throws IOException { |
|
140 UnixFileStoreAttributes attrs = readAttributes(); |
|
141 try { |
|
142 return Math.multiplyExact(attrs.blockSize(), attrs.freeBlocks()); |
|
143 } catch (ArithmeticException ignore) { |
|
144 return Long.MAX_VALUE; |
|
145 } |
128 } |
146 } |
129 |
147 |
130 @Override |
148 @Override |
131 public long getBlockSize() throws IOException { |
149 public long getBlockSize() throws IOException { |
132 UnixFileStoreAttributes attrs = readAttributes(); |
150 UnixFileStoreAttributes attrs = readAttributes(); |
133 return attrs.blockSize(); |
151 return attrs.blockSize(); |
134 } |
|
135 |
|
136 @Override |
|
137 public long getUnallocatedSpace() throws IOException { |
|
138 UnixFileStoreAttributes attrs = readAttributes(); |
|
139 return attrs.blockSize() * attrs.freeBlocks(); |
|
140 } |
152 } |
141 |
153 |
142 @Override |
154 @Override |
143 public <V extends FileStoreAttributeView> V getFileStoreAttributeView(Class<V> view) |
155 public <V extends FileStoreAttributeView> V getFileStoreAttributeView(Class<V> view) |
144 { |
156 { |