Merge "Revert "Add API tests for FileStore.""
diff --git a/luni/src/test/java/libcore/java/nio/file/LinuxFileSystemTest.java b/luni/src/test/java/libcore/java/nio/file/LinuxFileSystemTest.java
index 31ef1f7..4d2f4cb 100644
--- a/luni/src/test/java/libcore/java/nio/file/LinuxFileSystemTest.java
+++ b/luni/src/test/java/libcore/java/nio/file/LinuxFileSystemTest.java
@@ -89,54 +89,10 @@
@Test
public void test_getFileStores() {
Iterable<FileStore> fileStores = fileSystem.getFileStores();
- // The FileSystem should have at least one FileStore
+ // Asserting if the the list has non zero number stores.
assertTrue(fileStores.iterator().hasNext());
}
- // It's difficult to make assumptions that are true across all devices but
- // in general the root filestore should be full and read-only (it's the system image)
- // and on a device undergoing CTS /data should be writable and have free space.
- @Test
- public void rootFilestore() throws Exception {
- FileStore filestore = getFilestore("/");
- assertEquals(0, filestore.getBlockSize() % 512);
- assertTrue(filestore.getTotalSpace() > 0);
- assertTrue(filestore.getUnallocatedSpace() > 0);
- assertEquals(0, filestore.getUsableSpace());
- assertTrue(filestore.isReadOnly());
- }
-
- // See explanation for rootFilestore()
- @Test
- public void dataFilestore() throws Exception {
- FileStore filestore = getFilestore("/data");
- assertEquals(0, filestore.getBlockSize() % 512);
- assertTrue(filestore.getTotalSpace() > 0);
- assertTrue(filestore.getUnallocatedSpace() > 0);
- assertTrue(filestore.getUsableSpace() > 0);
- assertFalse(filestore.isReadOnly());
- }
-
- // File.getFileStore(path) throws a SecurityException on Android, so we
- // iterate over all file stores until we find a matching mount point.
- private FileStore getFilestore(String mountPoint) throws IOException {
- for (FileStore filestore : fileSystem.getFileStores()) {
- if (mountPoint.equals(getMountPoint(filestore))) {
- return filestore;
- }
- }
- fail("Unable to find FileStore for " + mountPoint);
- return null;
- }
-
- // Naturally there is no official API to get the mount point for a FileStore,
- // so we rely on the fact that the string representation is always "<mountpoint> (<device>)"
- private String getMountPoint(FileStore fileStore) {
- String description = fileStore.toString();
- int index = description.indexOf(" (");
- return description.substring(0, index);
- }
-
@Test
public void test_supportedFileAttributeViews() {
Set<String> supportedFileAttributeViewsList = fileSystem.supportedFileAttributeViews();
diff --git a/ojluni/src/main/java/sun/nio/fs/UnixFileStore.java b/ojluni/src/main/java/sun/nio/fs/UnixFileStore.java
index 8c7031b..0532e4d 100644
--- a/ojluni/src/main/java/sun/nio/fs/UnixFileStore.java
+++ b/ojluni/src/main/java/sun/nio/fs/UnixFileStore.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2015, 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
@@ -27,8 +27,11 @@
import java.nio.file.*;
import java.nio.file.attribute.*;
+import java.nio.channels.*;
import java.util.*;
import java.io.IOException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
/**
* Base implementation of FileStore for Unix/like implementations.
@@ -123,12 +126,6 @@
}
@Override
- public long getBlockSize() throws IOException {
- UnixFileStoreAttributes attrs = readAttributes();
- return attrs.blockSize();
- }
-
- @Override
public long getUnallocatedSpace() throws IOException {
UnixFileStoreAttributes attrs = readAttributes();
return attrs.blockSize() * attrs.freeBlocks();
@@ -221,17 +218,12 @@
/**
* Returns status to indicate if file system supports a given feature
*/
- // BEGIN Android-changed: fstypes properties file is not used on Android.
- FeatureStatus checkIfFeaturePresent(String feature) {
- return FeatureStatus.UNKNOWN;
- }
- /*
FeatureStatus checkIfFeaturePresent(String feature) {
if (props == null) {
synchronized (loadLock) {
if (props == null) {
props = AccessController.doPrivileged(
- new PrivilegedAction<>() {
+ new PrivilegedAction<Properties>() {
@Override
public Properties run() {
return loadProperties();
@@ -261,16 +253,14 @@
private static Properties loadProperties() {
Properties result = new Properties();
- String fstypes = StaticProperty.javaHome() + "/lib/fstypes.properties";
- Path file = Path.of(fstypes);
+ String fstypes = System.getProperty("java.home") + "/lib/fstypes.properties";
+ Path file = Paths.get(fstypes);
try {
try (ReadableByteChannel rbc = Files.newByteChannel(file)) {
- result.load(Channels.newReader(rbc, UTF_8.INSTANCE));
+ result.load(Channels.newReader(rbc, "UTF-8"));
}
} catch (IOException x) {
}
return result;
}
- */
- // END Android-changed: fstypes properties file is not used on Android.
}