Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSteve Pfister <steveisok@users.noreply.github.com>2019-10-29 15:47:44 +0300
committerGitHub <noreply@github.com>2019-10-29 15:47:44 +0300
commit11501bfb54371d0a4a6de8ecfab1438708c2dea1 (patch)
tree885d65fdec6150e59fcea9d8cc433cc8829bda04 /src
parenteb2575e5e7622787eff151391e7b127c8c9a073e (diff)
Restore fchmod check in SystemNative_CopyFile and only ignore when it fails on android (#365)
Diffstat (limited to 'src')
-rw-r--r--src/Native/Unix/System.Native/pal_io.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/Native/Unix/System.Native/pal_io.c b/src/Native/Unix/System.Native/pal_io.c
index 39dfefc249..dc5e9e825a 100644
--- a/src/Native/Unix/System.Native/pal_io.c
+++ b/src/Native/Unix/System.Native/pal_io.c
@@ -1258,23 +1258,6 @@ int32_t SystemNative_CopyFile(intptr_t sourceFd, intptr_t destinationFd)
struct stat_ sourceStat;
bool copied = false;
-#if !MONODROID
- // First, stat the source file.
- while ((ret = fstat_(inFd, &sourceStat)) < 0 && errno == EINTR);
- if (ret != 0)
- {
- // If we can't stat() it, then we likely don't have permission to read it.
- return -1;
- }
-
- // Then copy permissions.
- while ((ret = fchmod(outFd, sourceStat.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO))) < 0 && errno == EINTR);
- if (ret != 0)
- {
- return -1;
- }
-#endif
-
#if HAVE_SENDFILE_4
// If sendfile is available (Linux), try to use it, as the whole copy
// can be performed in the kernel, without lots of unnecessary copying.
@@ -1284,7 +1267,6 @@ int32_t SystemNative_CopyFile(intptr_t sourceFd, intptr_t destinationFd)
return -1;
}
-
// On 32-bit, if you use 64-bit offsets, the last argument of `sendfile' will be a
// `size_t' a 32-bit integer while the `st_size' field of the stat structure will be off64_t.
// So `size' will have to be `uint64_t'. In all other cases, it will be `size_t'.
@@ -1352,6 +1334,24 @@ int32_t SystemNative_CopyFile(intptr_t sourceFd, intptr_t destinationFd)
#endif
}
+ if (ret != 0)
+ {
+ return -1;
+ }
+
+ // Then copy permissions.
+ while ((ret = fchmod(outFd, sourceStat.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO))) < 0 && errno == EINTR);
+
+// We are ignoring the error on Android because in the case of external storage we are not allowed
+// to modify permissions, but the copy should still succeed.
+// https://github.com/mono/mono/issues/17133
+#if !TARGET_ANDROID
+ if (ret != 0)
+ {
+ return -1;
+ }
+#endif
+
return 0;
#endif // HAVE_FCOPYFILE
}