mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-15 10:23:28 +00:00
8349092: File.getFreeSpace violates specification if quotas are in effect (win)
Reviewed-by: naoto
This commit is contained in:
parent
0181030bdc
commit
1a74ee64eb
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2025, 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
|
||||
@ -584,6 +584,13 @@ final class WinNTFileSystem extends FileSystem {
|
||||
@Override
|
||||
public long getSpace(File f, int t) {
|
||||
if (f.exists()) {
|
||||
// the value for the number of bytes of free space returned by the
|
||||
// native layer is not used here as it represents the number of free
|
||||
// bytes not considering quotas, whereas the value returned for the
|
||||
// number of usable bytes does respect quotas, and it is required
|
||||
// that free space <= total space
|
||||
if (t == SPACE_FREE)
|
||||
t = SPACE_USABLE;
|
||||
return getSpace0(f, t);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2025, 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
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 4057701 6286712 6364377 8181919
|
||||
* @bug 4057701 6286712 6364377 8181919 8349092
|
||||
* @requires (os.family == "linux" | os.family == "mac" |
|
||||
* os.family == "windows")
|
||||
* @summary Basic functionality of File.get-X-Space methods.
|
||||
@ -176,6 +176,12 @@ public class GetXSpace {
|
||||
long fs = f.getFreeSpace();
|
||||
long us = f.getUsableSpace();
|
||||
|
||||
// Verify inequalities us <= fs <= ts (JDK-8349092)
|
||||
if (fs > ts)
|
||||
throw new RuntimeException(f + " free space " + fs + " > total space " + ts);
|
||||
if (us > fs)
|
||||
throw new RuntimeException(f + " usable space " + fs + " > free space " + ts);
|
||||
|
||||
out.format("%s (%d):%n", s.name(), s.size());
|
||||
String fmt = " %-4s total = %12d free = %12d usable = %12d%n";
|
||||
String method = Platform.isWindows() & isCDDrive(s.name()) ? "getCDDriveSpace" : "getSpace0";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user