提交 4035ec20 编写于 作者: T tbell

Merge

...@@ -133,10 +133,11 @@ public final class Files { ...@@ -133,10 +133,11 @@ public final class Files {
* <p> This method walks a file tree rooted at a given starting file. The * <p> This method walks a file tree rooted at a given starting file. The
* file tree traversal is <em>depth-first</em> with the given {@link * file tree traversal is <em>depth-first</em> with the given {@link
* FileVisitor} invoked for each file encountered. File tree traversal * FileVisitor} invoked for each file encountered. File tree traversal
* completes when all accessible files in the tree have been visited, a * completes when all accessible files in the tree have been visited, or a
* visitor returns a result of {@link FileVisitResult#TERMINATE TERMINATE}, * visit method returns a result of {@link FileVisitResult#TERMINATE
* or the visitor terminates due to an uncaught {@code Error} or {@code * TERMINATE}. Where a visit method terminates due an uncaught error or
* RuntimeException}. * runtime exception then the traversal is terminated and the error or
* exception is propagated to the caller of this method.
* *
* <p> For each file encountered this method attempts to gets its {@link * <p> For each file encountered this method attempts to gets its {@link
* java.nio.file.attribute.BasicFileAttributes}. If the file is not a * java.nio.file.attribute.BasicFileAttributes}. If the file is not a
......
...@@ -124,8 +124,8 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> { ...@@ -124,8 +124,8 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
* cause. * cause.
* *
* @throws IOError * @throws IOError
* if iteration of the directory completed prematurely due to an * with the I/O exception thrown when iteration of the directory
* I/O error * completed prematurely due to an I/O error
*/ */
@Override @Override
public FileVisitResult postVisitDirectory(T dir, IOException exc) { public FileVisitResult postVisitDirectory(T dir, IOException exc) {
......
...@@ -57,9 +57,9 @@ public class Xdd { ...@@ -57,9 +57,9 @@ public class Xdd {
Path file = (args.length == 1) ? Path file = (args.length == 1) ?
Paths.get(args[0]) : Paths.get(args[2]); Paths.get(args[0]) : Paths.get(args[2]);
// check that user defined attributes are supported by the file system // check that user defined attributes are supported by the file store
FileStore store = file.getFileStore(); FileStore store = file.getFileStore();
if (!store.supportsFileAttributeView("user")) { if (!store.supportsFileAttributeView(UserDefinedFileAttributeView.class)) {
System.err.format("UserDefinedFileAttributeView not supported on %s\n", store); System.err.format("UserDefinedFileAttributeView not supported on %s\n", store);
System.exit(-1); System.exit(-1);
......
...@@ -134,15 +134,16 @@ setOptions(int fd) ...@@ -134,15 +134,16 @@ setOptions(int fd)
static jdwpTransportError static jdwpTransportError
handshake(int fd, jlong timeout) { handshake(int fd, jlong timeout) {
char *hello = "JDWP-Handshake"; const char *hello = "JDWP-Handshake";
char b[16]; char b[16];
int rv, received, i; int rv, helloLen, received;
if (timeout > 0) { if (timeout > 0) {
dbgsysConfigureBlocking(fd, JNI_FALSE); dbgsysConfigureBlocking(fd, JNI_FALSE);
} }
helloLen = (int)strlen(hello);
received = 0; received = 0;
while (received < (int)strlen(hello)) { while (received < helloLen) {
int n; int n;
char *buf; char *buf;
if (timeout > 0) { if (timeout > 0) {
...@@ -154,7 +155,7 @@ handshake(int fd, jlong timeout) { ...@@ -154,7 +155,7 @@ handshake(int fd, jlong timeout) {
} }
buf = b; buf = b;
buf += received; buf += received;
n = dbgsysRecv(fd, buf, (int)strlen(hello)-received, 0); n = dbgsysRecv(fd, buf, helloLen-received, 0);
if (n == 0) { if (n == 0) {
setLastError(0, "handshake failed - connection prematurally closed"); setLastError(0, "handshake failed - connection prematurally closed");
return JDWPTRANSPORT_ERROR_IO_ERROR; return JDWPTRANSPORT_ERROR_IO_ERROR;
...@@ -167,20 +168,19 @@ handshake(int fd, jlong timeout) { ...@@ -167,20 +168,19 @@ handshake(int fd, jlong timeout) {
if (timeout > 0) { if (timeout > 0) {
dbgsysConfigureBlocking(fd, JNI_TRUE); dbgsysConfigureBlocking(fd, JNI_TRUE);
} }
for (i=0; i<(int)strlen(hello); i++) { if (strncmp(b, hello, received) != 0) {
if (b[i] != hello[i]) { char msg[80+2*16];
char msg[64]; b[received] = '\0';
strcpy(msg, "handshake failed - received >"); /*
strncat(msg, b, strlen(hello)); * We should really use snprintf here but it's not available on Windows.
strcat(msg, "< - excepted >"); * We can't use jio_snprintf without linking the transport against the VM.
strcat(msg, hello); */
strcat(msg, "<"); sprintf(msg, "handshake failed - received >%s< - expected >%s<", b, hello);
setLastError(0, msg); setLastError(0, msg);
return JDWPTRANSPORT_ERROR_IO_ERROR; return JDWPTRANSPORT_ERROR_IO_ERROR;
}
} }
if (dbgsysSend(fd, hello, (int)strlen(hello), 0) != (int)strlen(hello)) { if (dbgsysSend(fd, (char*)hello, helloLen, 0) != helloLen) {
RETURN_IO_ERROR("send failed during handshake"); RETURN_IO_ERROR("send failed during handshake");
} }
return JDWPTRANSPORT_ERROR_NONE; return JDWPTRANSPORT_ERROR_NONE;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
package sun.nio.fs; package sun.nio.fs;
import java.nio.file.attribute.*;
import java.util.*; import java.util.*;
import java.io.IOException; import java.io.IOException;
...@@ -113,10 +114,12 @@ class LinuxFileStore ...@@ -113,10 +114,12 @@ class LinuxFileStore
} }
@Override @Override
public boolean supportsFileAttributeView(String name) { public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
// support DosFileAttributeView and UserDefinedAttributeView if extended // support DosFileAttributeView and UserDefinedAttributeView if extended
// attributes enabled // attributes enabled
if (name.equals("dos") || name.equals("user")) { if (type == DosFileAttributeView.class ||
type == UserDefinedFileAttributeView.class)
{
// lookup fstypes.properties // lookup fstypes.properties
FeatureStatus status = checkIfFeaturePresent("user_xattr"); FeatureStatus status = checkIfFeaturePresent("user_xattr");
if (status == FeatureStatus.PRESENT) if (status == FeatureStatus.PRESENT)
...@@ -142,7 +145,15 @@ class LinuxFileStore ...@@ -142,7 +145,15 @@ class LinuxFileStore
} }
return xattrEnabled; return xattrEnabled;
} }
return super.supportsFileAttributeView(type);
}
@Override
public boolean supportsFileAttributeView(String name) {
if (name.equals("dos"))
return supportsFileAttributeView(DosFileAttributeView.class);
if (name.equals("user"))
return supportsFileAttributeView(UserDefinedFileAttributeView.class);
return super.supportsFileAttributeView(name); return super.supportsFileAttributeView(name);
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
package sun.nio.fs; package sun.nio.fs;
import java.nio.file.attribute.*;
import java.io.IOException; import java.io.IOException;
import static sun.nio.fs.UnixNativeDispatcher.*; import static sun.nio.fs.UnixNativeDispatcher.*;
...@@ -72,27 +73,39 @@ class SolarisFileStore ...@@ -72,27 +73,39 @@ class SolarisFileStore
} }
@Override @Override
public boolean supportsFileAttributeView(String name) { public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
if (name.equals("acl")) { if (type == AclFileAttributeView.class) {
// lookup fstypes.properties // lookup fstypes.properties
FeatureStatus status = checkIfFeaturePresent("nfsv4acl"); FeatureStatus status = checkIfFeaturePresent("nfsv4acl");
if (status == FeatureStatus.PRESENT) switch (status) {
return true; case PRESENT : return true;
if (status == FeatureStatus.NOT_PRESENT) case NOT_PRESENT : return false;
return false; default :
// AclFileAttributeView available on ZFS // AclFileAttributeView available on ZFS
return (type().equals("zfs")); return (type().equals("zfs"));
}
} }
if (name.equals("user")) { if (type == UserDefinedFileAttributeView.class) {
// lookup fstypes.properties // lookup fstypes.properties
FeatureStatus status = checkIfFeaturePresent("xattr"); FeatureStatus status = checkIfFeaturePresent("xattr");
if (status == FeatureStatus.PRESENT) switch (status) {
return true; case PRESENT : return true;
if (status == FeatureStatus.NOT_PRESENT) case NOT_PRESENT : return false;
return false; default :
return xattrEnabled; // UserDefinedFileAttributeView available if extended
// attributes supported
return xattrEnabled;
}
} }
return super.supportsFileAttributeView(type);
}
@Override
public boolean supportsFileAttributeView(String name) {
if (name.equals("acl"))
return supportsFileAttributeView(AclFileAttributeView.class);
if (name.equals("user"))
return supportsFileAttributeView(UserDefinedFileAttributeView.class);
return super.supportsFileAttributeView(name); return super.supportsFileAttributeView(name);
} }
......
...@@ -145,9 +145,8 @@ abstract class UnixFileStore ...@@ -145,9 +145,8 @@ abstract class UnixFileStore
{ {
// lookup fstypes.properties // lookup fstypes.properties
FeatureStatus status = checkIfFeaturePresent("posix"); FeatureStatus status = checkIfFeaturePresent("posix");
if (status == FeatureStatus.NOT_PRESENT) // assume supported if UNKNOWN
return false; return (status != FeatureStatus.NOT_PRESENT);
return true;
} }
return false; return false;
} }
......
...@@ -153,7 +153,7 @@ class WindowsFileStore ...@@ -153,7 +153,7 @@ class WindowsFileStore
public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) { public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
if (type == null) if (type == null)
throw new NullPointerException(); throw new NullPointerException();
if (type == BasicFileAttributeView.class) if (type == BasicFileAttributeView.class || type == DosFileAttributeView.class)
return true; return true;
if (type == AclFileAttributeView.class || type == FileOwnerAttributeView.class) if (type == AclFileAttributeView.class || type == FileOwnerAttributeView.class)
return ((volInfo.flags() & FILE_PERSISTENT_ACLS) != 0); return ((volInfo.flags() & FILE_PERSISTENT_ACLS) != 0);
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
/* @test /* @test
* @bug 6306165 * @bug 6306165 6432567
* @summary Check that a bad handshake doesn't cause a debuggee to abort * @summary Check that a bad handshake doesn't cause a debuggee to abort
* *
* @build VMConnection BadHandshakeTest Exit0 * @build VMConnection BadHandshakeTest Exit0
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
/* @test /* @test
* @bug 4313887 * @bug 4313887 6873621
* @summary Unit test for java.nio.file.FileStore * @summary Unit test for java.nio.file.FileStore
* @library .. * @library ..
*/ */
...@@ -67,6 +67,15 @@ public class Basic { ...@@ -67,6 +67,15 @@ public class Basic {
* Test: File and FileStore attributes * Test: File and FileStore attributes
*/ */
assertTrue(store1.supportsFileAttributeView("basic")); assertTrue(store1.supportsFileAttributeView("basic"));
assertTrue(store1.supportsFileAttributeView(BasicFileAttributeView.class));
assertTrue(store1.supportsFileAttributeView("posix") ==
store1.supportsFileAttributeView(PosixFileAttributeView.class));
assertTrue(store1.supportsFileAttributeView("dos") ==
store1.supportsFileAttributeView(DosFileAttributeView.class));
assertTrue(store1.supportsFileAttributeView("acl") ==
store1.supportsFileAttributeView(AclFileAttributeView.class));
assertTrue(store1.supportsFileAttributeView("user") ==
store1.supportsFileAttributeView(UserDefinedFileAttributeView.class));
/** /**
* Test: Enumerate all FileStores * Test: Enumerate all FileStores
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册