Skip to content

Commit e8ab3db

Browse files
kevinlulethomson
authored andcommitted
p_chmod: Android compatibility
Fix libgit2#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.
1 parent 2ab99c6 commit e8ab3db

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/unix/posix.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,23 @@ GIT_INLINE(int) p_fsync(int fd)
6262
#define p_snprintf snprintf
6363
#define p_mkstemp(p) mkstemp(p)
6464
#define p_chdir(p) chdir(p)
65-
#define p_chmod(p,m) chmod(p, m)
6665
#define p_rmdir(p) rmdir(p)
6766
#define p_access(p,m) access(p,m)
6867
#define p_ftruncate(fd, sz) ftruncate(fd, sz)
6968

69+
/*
70+
* Pre-Android 5 did not implement a virtual filesystem atop FAT
71+
* partitions for Unix permissions, which causes chmod to fail. However,
72+
* Unix permissions have no effect on Android anyway as file permissions
73+
* are not actually managed this way, so treating it as a no-op across
74+
* all Android is safe.
75+
*/
76+
#ifdef __ANDROID__
77+
# define p_chmod(p,m) 0
78+
#else
79+
# define p_chmod(p,m) chmod(p, m)
80+
#endif
81+
7082
/* see win32/posix.h for explanation about why this exists */
7183
#define p_lstat_posixly(p,b) lstat(p,b)
7284

0 commit comments

Comments
 (0)