I'm attempting to use flock(2) on a directory.
The code running is equivalent of:
const char* path = "/data/data/com.mypackage/files/somefilename";
mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP;
int fd = mkdir(path, mode);
fapi_.opendir(path);
int status = flock(fd, LOCK_EX | LOCK_NB);
=> status = 13
error shown in logcat:
03-21 20:12:22.530 1525 1525 W Thread-1027: type=1400 audit(0.0:536): avc: denied { lock } for path="/data/data/com.mypackage/files/somefilename" dev="mmcblk0p28" ino=114736 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0
So it seems like SELinux is prevent the flock?
Built Android API Level 9, running on an Nexus 5, Android 6.0.
Thanks