Skip to content

Commit ea03f73

Browse files
committed
Resolved review comments.
1 parent 58c7115 commit ea03f73

File tree

10 files changed

+296
-72
lines changed

10 files changed

+296
-72
lines changed

sdk/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This changelog summarizes major changes between GraalVM SDK versions. The main f
1111
* GR-61448 Compilation id (`CompId`) was added to the `opt done` truffle compilation logs. This id matches the compilation id in the output of deoptimization, compilation and code cache logs on HotSpot and SubstrateVM.
1212
* GR-31495 Added the ability to specify language and instrument specific options using `Source.Builder.option(String, String)`. See the language and or tool specific documentation for available options. Available source options may also be reflected using `Instrument.getSourceOptions()` and `Language.getSourceOptions()`.
1313
* GR-55223 The option sandbox.MaxStackFrames is no longer mandatory for the UNTRUSTED polyglot sandbox policy thanks to improved deoptimization handling of compiled code.
14-
* GR-64488 FileSystem implementations can now provide disk-related metadata, such as [total size](https://www.graalvm.org/truffle/javadoc/org/graalvm/polyglot/io/FileSystem.html#getTotalSpace(java.nio.file.Path)), [usable space](https://www.graalvm.org/truffle/javadoc/org/graalvm/polyglot/io/FileSystem.html#getUsableSpace(java.nio.file.Path)), and [unallocated space](https://www.graalvm.org/truffle/javadoc/org/graalvm/polyglot/io/FileSystem.html#getUnallocatedSpace(java.nio.file.Path)).
14+
* GR-64488 FileSystem implementations can now provide disk-related metadata, including [total space](https://www.graalvm.org/truffle/javadoc/org/graalvm/polyglot/io/FileSystem.html##getFileStoreTotalSpace(java.nio.file.Path)), [usable space](https://www.graalvm.org/truffle/javadoc/org/graalvm/polyglot/io/FileSystem.html#getFileStoreUsableSpace(java.nio.file.Path)), [unallocated space](https://www.graalvm.org/truffle/javadoc/org/graalvm/polyglot/io/FileSystem.html#getFileStoreUnallocatedSpace(java.nio.file.Path)), [block size](https://www.graalvm.org/truffle/javadoc/org/graalvm/polyglot/io/FileSystem.html#getFileStoreBlockSize(java.nio.file.Path)), and [read-only status](https://www.graalvm.org/truffle/javadoc/org/graalvm/polyglot/io/FileSystem.html#isFileStoreReadOnly(java.nio.file.Path)).
1515

1616
## Version 24.2.0
1717
* GR-54905 When using Truffle NFI with the Panama backend, native access must now be granted to the Truffle module instead of the NFI Panama module. Use the `--enable-native-access=org.graalvm.truffle` Java command line option to enable the native access for the NFI Panama backend.

sdk/src/org.graalvm.polyglot/snapshot.sigtest

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -707,15 +707,17 @@ meth public abstract java.nio.file.Path parsePath(java.lang.String)
707707
meth public abstract java.nio.file.Path parsePath(java.net.URI)
708708
meth public abstract java.nio.file.Path toAbsolutePath(java.nio.file.Path)
709709
meth public abstract void delete(java.nio.file.Path) throws java.io.IOException
710+
meth public boolean isFileStoreReadOnly(java.nio.file.Path) throws java.io.IOException
710711
meth public java.lang.String getMimeType(java.nio.file.Path)
711712
meth public java.lang.String getPathSeparator()
712713
meth public java.lang.String getSeparator()
713714
meth public java.nio.charset.Charset getEncoding(java.nio.file.Path)
714715
meth public java.nio.file.Path getTempDirectory()
715716
meth public java.nio.file.Path readSymbolicLink(java.nio.file.Path) throws java.io.IOException
716-
meth public long getTotalSpace(java.nio.file.Path) throws java.io.IOException
717-
meth public long getUnallocatedSpace(java.nio.file.Path) throws java.io.IOException
718-
meth public long getUsableSpace(java.nio.file.Path) throws java.io.IOException
717+
meth public long getFileStoreBlockSize(java.nio.file.Path) throws java.io.IOException
718+
meth public long getFileStoreTotalSpace(java.nio.file.Path) throws java.io.IOException
719+
meth public long getFileStoreUnallocatedSpace(java.nio.file.Path) throws java.io.IOException
720+
meth public long getFileStoreUsableSpace(java.nio.file.Path) throws java.io.IOException
719721
meth public static org.graalvm.polyglot.io.FileSystem allowInternalResourceAccess(org.graalvm.polyglot.io.FileSystem)
720722
meth public static org.graalvm.polyglot.io.FileSystem allowLanguageHomeAccess(org.graalvm.polyglot.io.FileSystem)
721723
anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="")

sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/io/FileSystem.java

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,8 @@ default boolean isSameFile(Path path1, Path path2, LinkOption... options) throws
447447
* @throws SecurityException if the {@link FileSystem} implementation denied the operation
448448
* @since 25.0.0
449449
*/
450-
default long getTotalSpace(Path path) throws IOException {
451-
throw new UnsupportedOperationException("TotalSpace is not supported");
450+
default long getFileStoreTotalSpace(Path path) throws IOException {
451+
throw new UnsupportedOperationException("GetFileStoreTotalSpace is not supported");
452452
}
453453

454454
/**
@@ -467,15 +467,15 @@ default long getTotalSpace(Path path) throws IOException {
467467
* @throws SecurityException if the {@link FileSystem} implementation denied the operation
468468
* @since 25.0.0
469469
*/
470-
default long getUnallocatedSpace(Path path) throws IOException {
471-
throw new UnsupportedOperationException("UnallocatedSpace is not supported");
470+
default long getFileStoreUnallocatedSpace(Path path) throws IOException {
471+
throw new UnsupportedOperationException("GetFileStoreUnallocatedSpace is not supported");
472472
}
473473

474474
/**
475475
* Returns the number of bytes available to this Java virtual machine on the file store that
476-
* contains the given {@code path}. Unlike {@link #getUnallocatedSpace(Path)}, this method
477-
* accounts for operating system-level restrictions, user quotas, and file system permissions,
478-
* and therefore may return a smaller value. If the available space exceeds
476+
* contains the given {@code path}. Unlike {@link #getFileStoreUnallocatedSpace(Path)}, this
477+
* method accounts for operating system level restrictions, user quotas, and file system
478+
* permissions, and therefore may return a smaller value. If the available space exceeds
479479
* {@link Long#MAX_VALUE}, {@code Long.MAX_VALUE} is returned. Note that the returned value may
480480
* be imprecise, as it can change at any time due to external I/O activity, including operations
481481
* performed outside this virtual machine.
@@ -488,8 +488,41 @@ default long getUnallocatedSpace(Path path) throws IOException {
488488
* @throws SecurityException if the {@link FileSystem} implementation denied the operation
489489
* @since 25.0.0
490490
*/
491-
default long getUsableSpace(Path path) throws IOException {
492-
throw new UnsupportedOperationException("UsableSpace is not supported");
491+
default long getFileStoreUsableSpace(Path path) throws IOException {
492+
throw new UnsupportedOperationException("GetFileStoreUsableSpace is not supported");
493+
}
494+
495+
/**
496+
* Returns the number of bytes per block in the file store that contains the given {@code path}.
497+
*
498+
* @param path the path whose file store is to be queried
499+
* @return the block size
500+
* @throws UnsupportedOperationException if the file system does not support retrieving file
501+
* store information
502+
* @throws IOException if an I/O error occurs while accessing the file store
503+
* @throws SecurityException if the {@link FileSystem} implementation denied the operation
504+
* @since 25.0.0
505+
*/
506+
default long getFileStoreBlockSize(Path path) throws IOException {
507+
throw new UnsupportedOperationException("GetFileStoreBlockSize is not supported");
508+
}
509+
510+
/**
511+
* Determines whether the file store containing the given {@code path} is read-only.
512+
* <p>
513+
* Note that even if the file store is not read-only, individual write operations may still be
514+
* denied due to restrictions imposed by the {@link FileSystem} implementation, operating system
515+
* level policies, user quotas, or file system permissions.
516+
*
517+
* @param path the path whose file store is to be queried
518+
* @throws UnsupportedOperationException if the file system does not support retrieving file
519+
* store information
520+
* @throws IOException if an I/O error occurs while accessing the file store
521+
* @throws SecurityException if the {@link FileSystem} implementation denied the operation
522+
* @since 25.0.0
523+
*/
524+
default boolean isFileStoreReadOnly(Path path) throws IOException {
525+
throw new UnsupportedOperationException("IsFileStoreReadOnly is not supported");
493526
}
494527

495528
/**

truffle/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This changelog summarizes major changes between Truffle versions relevant to lan
1717
* GR-64533 By default every specialization is now included for {@link GenerateUncached}, except specializations that require a {@link Specialization#limit() limit} and are replaced, those are excluded by default. By setting `@Specialization(excludeForUncached=..)` explicitly the default behavior can be overridden, e.g. to include or exclude a specialization for uncached. Specializations which are no longer compatible with uncached will produce a warning instead of an error for compatibility reasons until all languages are migrated. It is therefore expected that language implementations may see new warnings with this version.
1818
* GR-64124 Added `BytecodeOSRNode.pollOSRBackEdge(BytecodeOSRNode, int)` that supports batch polling for bytecode OSR. Using this method avoids checking for bytecode OSR on every loop backedge.
1919
* GR-64124 Deprecated `BytecodeOSRNode.pollOSRBackEdge(BytecodeOSRNode)`. Use `BytecodeOSRNode.pollOSRBackEdge(BytecodeOSRNode, int)` instead. Please note that the old method did call `TruffleSafepoint.poll(Node)`, but the the new method does not. Please double check that your bytecode interpreter polls Truffle safepoints at loop back-edges.
20-
* GR-64488 Added `TruffleFile#getFileStoreInfo()` providing access to disk-related metadata such as total size, usable space, and unallocated space.
20+
* GR-64488 Added `TruffleFile#getFileStoreInfo()` providing access to disk-related metadata such as total size, usable space, unallocated space and block size.
2121

2222
## Version 24.2.0
2323
* GR-60636 Truffle now stops compiling when the code cache fills up on HotSpot. A warning is printed when that happens.

truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/FileSystemsTest.java

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2752,6 +2752,18 @@ protected Object execute(RootNode node, Env env, Object[] contextArguments, Obje
27522752
} catch (SecurityException se) {
27532753
Assert.assertFalse(formatErrorMessage("Unexpected SecurityException", configurationName, path), canRead);
27542754
}
2755+
try {
2756+
fsInfo.getBlockSize();
2757+
Assert.assertTrue(formatErrorMessage("Expected SecurityException", configurationName, path), canRead);
2758+
} catch (SecurityException se) {
2759+
Assert.assertFalse(formatErrorMessage("Unexpected SecurityException", configurationName, path), canRead);
2760+
}
2761+
try {
2762+
fsInfo.isReadOnly();
2763+
Assert.assertTrue(formatErrorMessage("Expected SecurityException", configurationName, path), canRead);
2764+
} catch (SecurityException se) {
2765+
Assert.assertFalse(formatErrorMessage("Unexpected SecurityException", configurationName, path), canRead);
2766+
}
27552767
return null;
27562768
}
27572769
}
@@ -3292,18 +3304,28 @@ public boolean isSameFile(Path path1, Path path2, LinkOption... options) throws
32923304
}
32933305

32943306
@Override
3295-
public long getTotalSpace(Path path) throws IOException {
3296-
return delegate.getTotalSpace(path);
3307+
public long getFileStoreTotalSpace(Path path) throws IOException {
3308+
return delegate.getFileStoreTotalSpace(path);
3309+
}
3310+
3311+
@Override
3312+
public long getFileStoreUnallocatedSpace(Path path) throws IOException {
3313+
return delegate.getFileStoreUnallocatedSpace(path);
3314+
}
3315+
3316+
@Override
3317+
public long getFileStoreUsableSpace(Path path) throws IOException {
3318+
return delegate.getFileStoreUsableSpace(path);
32973319
}
32983320

32993321
@Override
3300-
public long getUnallocatedSpace(Path path) throws IOException {
3301-
return delegate.getUnallocatedSpace(path);
3322+
public long getFileStoreBlockSize(Path path) throws IOException {
3323+
return delegate.getFileStoreBlockSize(path);
33023324
}
33033325

33043326
@Override
3305-
public long getUsableSpace(Path path) throws IOException {
3306-
return delegate.getUsableSpace(path);
3327+
public boolean isFileStoreReadOnly(Path path) throws IOException {
3328+
return delegate.isFileStoreReadOnly(path);
33073329
}
33083330
}
33093331

@@ -3408,21 +3430,33 @@ public void setAttribute(Path path, String attribute, Object value, LinkOption..
34083430
}
34093431

34103432
@Override
3411-
public long getTotalSpace(Path path) throws IOException {
3433+
public long getFileStoreTotalSpace(Path path) throws IOException {
3434+
checkRead(path);
3435+
return super.getFileStoreTotalSpace(path);
3436+
}
3437+
3438+
@Override
3439+
public long getFileStoreUnallocatedSpace(Path path) throws IOException {
3440+
checkRead(path);
3441+
return super.getFileStoreUnallocatedSpace(path);
3442+
}
3443+
3444+
@Override
3445+
public long getFileStoreUsableSpace(Path path) throws IOException {
34123446
checkRead(path);
3413-
return super.getTotalSpace(path);
3447+
return super.getFileStoreUsableSpace(path);
34143448
}
34153449

34163450
@Override
3417-
public long getUnallocatedSpace(Path path) throws IOException {
3451+
public long getFileStoreBlockSize(Path path) throws IOException {
34183452
checkRead(path);
3419-
return super.getUnallocatedSpace(path);
3453+
return super.getFileStoreBlockSize(path);
34203454
}
34213455

34223456
@Override
3423-
public long getUsableSpace(Path path) throws IOException {
3457+
public boolean isFileStoreReadOnly(Path path) throws IOException {
34243458
checkRead(path);
3425-
return super.getUsableSpace(path);
3459+
return super.isFileStoreReadOnly(path);
34263460
}
34273461

34283462
private void checkRead(Path path) {

truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/MemoryFileSystem.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,18 +432,28 @@ public Path getTempDirectory() {
432432
}
433433

434434
@Override
435-
public long getTotalSpace(Path path) {
435+
public long getFileStoreTotalSpace(Path path) {
436436
return Runtime.getRuntime().maxMemory();
437437
}
438438

439439
@Override
440-
public long getUnallocatedSpace(Path path) {
440+
public long getFileStoreUnallocatedSpace(Path path) {
441441
return Runtime.getRuntime().freeMemory();
442442
}
443443

444444
@Override
445-
public long getUsableSpace(Path path) {
446-
return getUnallocatedSpace(path);
445+
public long getFileStoreUsableSpace(Path path) {
446+
return getFileStoreUnallocatedSpace(path);
447+
}
448+
449+
@Override
450+
public long getFileStoreBlockSize(Path path) {
451+
return 1024;
452+
}
453+
454+
@Override
455+
public boolean isFileStoreReadOnly(Path path) {
456+
return false;
447457
}
448458

449459
private static Object[] parse(String attributesSelector) {

truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/TruffleFileTest.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,8 @@ protected Object execute(RootNode node, Env env, Object[] contextArguments, Obje
12021202
// Unallocated space may change after retrieval; use a weak assertion to account for
12031203
// fluctuations.
12041204
assertInTolerance(fileStore.getUsableSpace(), fsInfo.getUsableSpace());
1205+
assertEquals(fileStore.getBlockSize(), fsInfo.getBlockSize());
1206+
assertEquals(fileStore.isReadOnly(), fsInfo.isReadOnly());
12051207
return null;
12061208
}
12071209

@@ -1486,17 +1488,27 @@ public boolean isSameFile(Path path1, Path path2, LinkOption... options) {
14861488
}
14871489

14881490
@Override
1489-
public long getTotalSpace(Path path) {
1491+
public long getFileStoreTotalSpace(Path path) {
14901492
throw fail();
14911493
}
14921494

14931495
@Override
1494-
public long getUnallocatedSpace(Path path) {
1496+
public long getFileStoreUnallocatedSpace(Path path) {
14951497
throw fail();
14961498
}
14971499

14981500
@Override
1499-
public long getUsableSpace(Path path) {
1501+
public long getFileStoreUsableSpace(Path path) {
1502+
throw fail();
1503+
}
1504+
1505+
@Override
1506+
public long getFileStoreBlockSize(Path path) {
1507+
throw fail();
1508+
}
1509+
1510+
@Override
1511+
public boolean isFileStoreReadOnly(Path path) {
15001512
throw fail();
15011513
}
15021514

truffle/src/com.oracle.truffle.api/snapshot.sigtest

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,8 @@ hfds delegate,queriedAttributes
440440

441441
CLSS public final com.oracle.truffle.api.TruffleFile$FileStoreInfo
442442
outer com.oracle.truffle.api.TruffleFile
443+
meth public boolean isReadOnly() throws java.io.IOException
444+
meth public long getBlockSize() throws java.io.IOException
443445
meth public long getTotalSpace() throws java.io.IOException
444446
meth public long getUnallocatedSpace() throws java.io.IOException
445447
meth public long getUsableSpace() throws java.io.IOException

truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleFile.java

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,7 @@ private FileStoreInfo() {
21062106
@TruffleBoundary
21072107
public long getTotalSpace() throws IOException {
21082108
try {
2109-
return fileSystemContext.fileSystem.getTotalSpace(normalizedPath);
2109+
return fileSystemContext.fileSystem.getFileStoreTotalSpace(normalizedPath);
21102110
} catch (IOException | SecurityException | UnsupportedOperationException e) {
21112111
throw e;
21122112
} catch (Throwable t) {
@@ -2132,7 +2132,7 @@ public long getTotalSpace() throws IOException {
21322132
@TruffleBoundary
21332133
public long getUnallocatedSpace() throws IOException {
21342134
try {
2135-
return fileSystemContext.fileSystem.getUnallocatedSpace(normalizedPath);
2135+
return fileSystemContext.fileSystem.getFileStoreUnallocatedSpace(normalizedPath);
21362136
} catch (IOException | SecurityException | UnsupportedOperationException e) {
21372137
throw e;
21382138
} catch (Throwable t) {
@@ -2159,7 +2159,52 @@ public long getUnallocatedSpace() throws IOException {
21592159
@TruffleBoundary
21602160
public long getUsableSpace() throws IOException {
21612161
try {
2162-
return fileSystemContext.fileSystem.getUsableSpace(normalizedPath);
2162+
return fileSystemContext.fileSystem.getFileStoreUsableSpace(normalizedPath);
2163+
} catch (IOException | SecurityException | UnsupportedOperationException e) {
2164+
throw e;
2165+
} catch (Throwable t) {
2166+
throw wrapHostException(t);
2167+
}
2168+
}
2169+
2170+
/**
2171+
* Returns the number of bytes per block in the file store.
2172+
*
2173+
* @return the block size
2174+
* @throws UnsupportedOperationException if the file system does not support retrieving file
2175+
* store information
2176+
* @throws IOException if an I/O error occurs while accessing the file store
2177+
* @throws SecurityException if the {@link FileSystem} implementation denied the operation
2178+
* @since 25.0.0
2179+
*/
2180+
@TruffleBoundary
2181+
public long getBlockSize() throws IOException {
2182+
try {
2183+
return fileSystemContext.fileSystem.getFileStoreBlockSize(normalizedPath);
2184+
} catch (IOException | SecurityException | UnsupportedOperationException e) {
2185+
throw e;
2186+
} catch (Throwable t) {
2187+
throw wrapHostException(t);
2188+
}
2189+
}
2190+
2191+
/**
2192+
* Determines whether the file store is read-only.
2193+
* <p>
2194+
* Note that even if the file store is not read-only, individual write operations may still
2195+
* be denied due to restrictions imposed by the {@link FileSystem} implementation, operating
2196+
* system level policies, user quotas, or file system permissions.
2197+
*
2198+
* @throws UnsupportedOperationException if the file system does not support retrieving file
2199+
* store information
2200+
* @throws IOException if an I/O error occurs while accessing the file store
2201+
* @throws SecurityException if the {@link FileSystem} implementation denied the operation
2202+
* @since 25.0.0
2203+
*/
2204+
@TruffleBoundary
2205+
public boolean isReadOnly() throws IOException {
2206+
try {
2207+
return fileSystemContext.fileSystem.isFileStoreReadOnly(normalizedPath);
21632208
} catch (IOException | SecurityException | UnsupportedOperationException e) {
21642209
throw e;
21652210
} catch (Throwable t) {

0 commit comments

Comments
 (0)