diff --git a/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java b/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java index 963e3777bdfc4228f932c0b04b825949344c0840..d7a1f8b0310b6ac2a2b7a51d95d4de1ec0294c91 100644 --- a/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java +++ b/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java @@ -36,8 +36,6 @@ import sun.nio.ch.SimpleAsynchronousFileChannelImpl; import sun.misc.SharedSecrets; import sun.misc.JavaIOFileDescriptorAccess; -import com.sun.nio.file.ExtendedOpenOption; - import static sun.nio.fs.UnixNativeDispatcher.*; import static sun.nio.fs.UnixConstants.*; @@ -86,13 +84,13 @@ class UnixChannelFactory { } continue; } - if (option == LinkOption.NOFOLLOW_LINKS) { + if (option == LinkOption.NOFOLLOW_LINKS && supportsNoFollowLinks()) { flags.noFollowLinks = true; continue; } if (option == null) throw new NullPointerException(); - throw new UnsupportedOperationException(); + throw new UnsupportedOperationException(option + " not supported"); } return flags; } @@ -220,6 +218,15 @@ class UnixChannelFactory { // follow links by default boolean followLinks = true; if (!flags.createNew && (flags.noFollowLinks || flags.deleteOnClose)) { + if (flags.deleteOnClose && !supportsNoFollowLinks()) { + try { + if (UnixFileAttributes.get(path, false).isSymbolicLink()) + throw new UnixException("DELETE_ON_CLOSE specified and file is a symbolic link"); + } catch (UnixException x) { + if (!flags.create || x.errno() != ENOENT) + throw x; + } + } followLinks = false; oflags |= O_NOFOLLOW; } diff --git a/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java b/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java index 0c14ef02e7e439dbbd144e2261911dd6ae0ba3b1..ea9df0c1fdcbf51b668fd0525c472aa601cb4e2b 100644 --- a/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java +++ b/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java @@ -395,7 +395,7 @@ public abstract class UnixFileSystemProvider // can't return SecureDirectoryStream on kernels that don't support // openat, etc. - if (!supportsAtSysCalls()) { + if (!supportsAtSysCalls() || !supportsNoFollowLinks()) { try { long ptr = opendir(dir); return new UnixDirectoryStream(dir, ptr, filter); diff --git a/src/solaris/classes/sun/nio/fs/UnixNativeDispatcher.java b/src/solaris/classes/sun/nio/fs/UnixNativeDispatcher.java index 2d037f303adced31089f40a638186e38f2f9225c..886598885668e9b1d5ef52b6c34f170066b88218 100644 --- a/src/solaris/classes/sun/nio/fs/UnixNativeDispatcher.java +++ b/src/solaris/classes/sun/nio/fs/UnixNativeDispatcher.java @@ -548,6 +548,10 @@ class UnixNativeDispatcher { return hasAtSysCalls; } + static boolean supportsNoFollowLinks() { + return UnixConstants.O_NOFOLLOW != 0; + } + // initialize syscalls and fieldIDs private static native int init(); diff --git a/src/solaris/classes/sun/nio/fs/UnixPath.java b/src/solaris/classes/sun/nio/fs/UnixPath.java index 30c4dfe6501f7064cb1b8f49f7fed0ee7f91f585..52b88416eb744caa96f1369178eb84f45780096e 100644 --- a/src/solaris/classes/sun/nio/fs/UnixPath.java +++ b/src/solaris/classes/sun/nio/fs/UnixPath.java @@ -767,8 +767,11 @@ class UnixPath // package-private int openForAttributeAccess(boolean followLinks) throws IOException { int flags = O_RDONLY; - if (!followLinks) + if (!followLinks) { + if (!supportsNoFollowLinks()) + throw new IOException("NOFOLLOW_LINKS is not supported on this platform"); flags |= O_NOFOLLOW; + } try { return open(this, flags, 0); } catch (UnixException x) { diff --git a/src/solaris/native/sun/nio/fs/genUnixConstants.c b/src/solaris/native/sun/nio/fs/genUnixConstants.c index 56984a7e35275c48d3ec9ecbb64ab12cd7e5c913..769982859bcb59b1119810ada99a6b1af659cf8d 100644 --- a/src/solaris/native/sun/nio/fs/genUnixConstants.c +++ b/src/solaris/native/sun/nio/fs/genUnixConstants.c @@ -64,7 +64,12 @@ int main(int argc, const char* argv[]) { DEFX(O_TRUNC); DEFX(O_SYNC); DEFX(O_DSYNC); +#ifdef O_NOFOLLOW DEFX(O_NOFOLLOW); +#else + // not supported (dummy values will not be used at runtime). + emitX("O_NOFOLLOW", 0x0); +#endif // mode masks emitX("S_IAMB",