access wpa_supplicant.conf

if (access(SUPP_CONFIG_TEMPLATE, R_OK|W_OK) == 0){
LOGE("access %s successfull!", SUPP_CONFIG_TEMPLATE);
} else if(errno != ENOENT) {
LOGE("access %s failed! Now try to open it in O_WRONLY mode", SUPP_CONFIG_TEMPLATE);

if (chown(SUPP_CONFIG_TEMPLATE, AID_SYSTEM, AID_WIFI) < 0) {
LOGE("Error changing group ownership of %s to %d: %s",
SUPP_CONFIG_TEMPLATE, AID_WIFI, strerror(errno));
} else {

ret = chmod(SUPP_CONFIG_TEMPLATE, S_IRUSR | S_IWUSR);
if (ret < 0) {
LOGE("chmod %s with write and read right failed!", SUPP_CONFIG_TEMPLATE);
} else {
LOGE("chmod %s with write and read right Successfully!", SUPP_CONFIG_TEMPLATE);
}
}

}

你可能感兴趣的:(Access)