summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkevinlul <6320810+kevinlul@users.noreply.github.com>2020-07-07 22:29:05 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2020-10-04 18:46:36 +0100
commite8ab3db99e13bcb330e91e0ca0265b60483a5e47 (patch)
treefb15becf2cb08ee78bcdae3f0677be08ed30c1c8
parent2ab99c6d0a773f00f2d62933d0a0866071edf275 (diff)
downloadlibgit2-e8ab3db99e13bcb330e91e0ca0265b60483a5e47.tar.gz
p_chmod: Android compatibility
Fix #5565 Pre-Android 5 did not implement a virtual filesystem atop FAT partitions for Unix permissions, which causes chmod to fail. However, Unix permissions have no effect on Android anyway as file permissions are not actually managed this way, so treating it as a no-op across all Android is safe.
-rw-r--r--src/unix/posix.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/unix/posix.h b/src/unix/posix.h
index 4fa725013..b5527a4a8 100644
--- a/src/unix/posix.h
+++ b/src/unix/posix.h
@@ -62,11 +62,23 @@ GIT_INLINE(int) p_fsync(int fd)
#define p_snprintf snprintf
#define p_mkstemp(p) mkstemp(p)
#define p_chdir(p) chdir(p)
-#define p_chmod(p,m) chmod(p, m)
#define p_rmdir(p) rmdir(p)
#define p_access(p,m) access(p,m)
#define p_ftruncate(fd, sz) ftruncate(fd, sz)
+/*
+ * Pre-Android 5 did not implement a virtual filesystem atop FAT
+ * partitions for Unix permissions, which causes chmod to fail. However,
+ * Unix permissions have no effect on Android anyway as file permissions
+ * are not actually managed this way, so treating it as a no-op across
+ * all Android is safe.
+ */
+#ifdef __ANDROID__
+# define p_chmod(p,m) 0
+#else
+# define p_chmod(p,m) chmod(p, m)
+#endif
+
/* see win32/posix.h for explanation about why this exists */
#define p_lstat_posixly(p,b) lstat(p,b)