/* * Copyright (c) 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
long size = Files.size(path); int capacity = (int)Math.min(1024, size);
ByteBuffer buf = ByteBuffer.allocate(capacity); try (SeekableByteChannel sbc = Files.newByteChannel(path)) { int n = sbc.read(buf);
System.out.format("Read %d bytes from %s%n", n, path);
}
}
privatestaticfinalvoid checkDataVolume() throws IOException {
System.out.format("--- Checking data volume %s ---%n", DATA_VOLUME);
Path data = Path.of(DATA_VOLUME, "private", "tmp"); if (Files.getFileStore(data).isReadOnly()) { thrownew RuntimeException("Data volume is read-only");
}
Path tempDir = Files.createTempDirectory(data, "tempDir");
tempDir.toFile().deleteOnExit();
System.out.format("Temporary directory: %s%n", tempDir); if (!Files.isWritable(tempDir)) { thrownew RuntimeException("Temporary directory is not writable");
}
Path tempFile = Files.createTempFile(tempDir, "tempFile", null);
tempFile.toFile().deleteOnExit();
System.out.format("Temporary file: %s%n", tempFile); if (!Files.isWritable(tempFile)) { thrownew RuntimeException("Temporary file is not writable");
}
byte[] bytes = newbyte[42]; new Random().nextBytes(bytes); try (SeekableByteChannel sbc = Files.newByteChannel(tempFile,
StandardOpenOption.WRITE)) {
ByteBuffer src = ByteBuffer.wrap(bytes); if (sbc.write(src) != bytes.length) { thrownew RuntimeException("Incorrect number of bytes written");
}
}
try (SeekableByteChannel sbc = Files.newByteChannel(tempFile)) {
ByteBuffer dst = ByteBuffer.allocate(bytes.length); if (sbc.read(dst) != bytes.length) { thrownew RuntimeException("Incorrect number of bytes read");
} if (!Arrays.equals(dst.array(), bytes)) { thrownew RuntimeException("Bytes read != bytes written");
}
}
}
staticvoid checkFirmlinks() throws IOException {
System.out.format("--- Checking firmlinks %s ---%n", FIRMLINKS);
Path firmlinks = Path.of(FIRMLINKS); if (!Files.exists(firmlinks)) {
System.err.format("%s does not exist: skipping firmlinks test%n",
firmlinks); return;
} elseif (!Files.isReadable(firmlinks)) { thrownew RuntimeException(String.format("%s is not readable",
firmlinks));
}
try (BufferedReader br = Files.newBufferedReader(firmlinks)) {
String line; while ((line = br.readLine()) != null) {
String file = line.split("\\s")[0];
Path path = Path.of(file); if (!Files.exists(path)) {
System.err.format("Firmlink %s does not exist: skipping%n",
file); continue;
} if (Files.getFileStore(path).isReadOnly()) {
String msg = String.format("%s is read-only%n", file); thrownew RuntimeException(msg);
} else {
System.out.format("Firmlink %s OK%n", file);
}
}
}
}
publicstaticvoid main(String[] args) throws Exception {
String[] osv = System.getProperty("os.version").split("\\."); int major = Integer.valueOf(osv[0]); int minor = Integer.valueOf(osv[1]); if (major < 10 || (major == 10 && minor < 15)) {
System.out.format("macOS version %d.%d too old: skipping test%n",
major, minor); return;
}
// Check system volume for read-only.
checkSystemVolume();
// Check data volume for read-write.
checkDataVolume();
// Check firmlinks for read-write.
checkFirmlinks();
}
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.13Bemerkung:
(vorverarbeitet am 2026-06-05)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.