diff options
author | Laszlo Csomor <laszlocsomor@google.com> | 2018-07-13 01:58:15 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-07-13 01:59:26 -0700 |
commit | 87bd94787f459a52ebe8bf395d4877cdb8d1929b (patch) | |
tree | c9843626da589a807d81856b7128f9a5de3c8510 /src/main/java/com/google/devtools/build/lib/windows | |
parent | 75bc18a6290f9112077884460d61f34bec325814 (diff) |
Windows,JNI: graceful error-handling
CreateJunction and DeletePath are now more
resilient to errors:
- CreateJunction opens the junction path to check
its target requesting fewer rights and with
greater sharing permission. This way it can
check junction targets even if the junction name
is opened by another process with no sharing.
- DeletePath attempts to call FindFirstFileW if
GetFileAttributesW fails with
ERROR_ACCESS_DENIED. There's hardly any info
about this error mode online, except for a code
comment in the .NET CoreFX library. (See new
code comments in this commit.)
Also:
- Change the error codes for DeletePath.
- Wrap the DeletPath error codes in a struct for
better readability.
Fixes https://github.com/bazelbuild/bazel/issues/5433
Change-Id: I5b6e0f27b5b22c1cf00da90104495eda84178283
Closes #5590.
Change-Id: I5b6e0f27b5b22c1cf00da90104495eda84178283
PiperOrigin-RevId: 204438994
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/windows')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/windows/jni/WindowsFileOperations.java | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/windows/jni/WindowsFileOperations.java b/src/main/java/com/google/devtools/build/lib/windows/jni/WindowsFileOperations.java index 229c207e91..4b5d74f701 100644 --- a/src/main/java/com/google/devtools/build/lib/windows/jni/WindowsFileOperations.java +++ b/src/main/java/com/google/devtools/build/lib/windows/jni/WindowsFileOperations.java @@ -61,10 +61,10 @@ public class WindowsFileOperations { // Keep DELETE_PATH_* values in sync with src/main/native/windows/file.cc. private static final int DELETE_PATH_SUCCESS = 0; - private static final int DELETE_PATH_DOES_NOT_EXIST = 1; - private static final int DELETE_PATH_DIRECTORY_NOT_EMPTY = 2; - private static final int DELETE_PATH_ACCESS_DENIED = 3; - private static final int DELETE_PATH_ERROR = 4; + private static final int DELETE_PATH_ERROR = 1; + private static final int DELETE_PATH_DOES_NOT_EXIST = 2; + private static final int DELETE_PATH_DIRECTORY_NOT_EMPTY = 3; + private static final int DELETE_PATH_ACCESS_DENIED = 4; private static native int nativeIsJunction(String path, String[] error); |