// * [ugoa]*([-+=]([rwxXst]*|[ugo]))+ extern "C" t_std_error std_user_chmod(const char *path, const char *perm_str) { //todo wrap this initialization with a mutex static std_mutex_lock_create_static_init_fast(lock); std_mutex_lock(&lock); static const mode_t all_mode_mask = _perm_map.find('a')->second.find('w')->second | _perm_map.find('a')->second.find('r')->second | _perm_map.find('a')->second.find('x')->second ; std_mutex_unlock(&lock); struct stat buf; if (stat(path, &buf)!=0) { int err = errno; EV_LOG(ERR,COM,0,"COM-USER-PERM","path element doesn't exist %s",path); return STD_ERR(COM,FAIL,err); } STD_ASSERT(path!=nullptr && perm_str!=nullptr); mode_t mod = 0; while(*perm_str!=0) { char op = '+'; mode_t _ch_mod = 0; if (!_chomp(perm_str,op,_ch_mod)) { EV_LOG(ERR,COM,0,"COM-USER-PERM","permission string invalid %s",perm_str); return STD_ERR(COM,PARAM,*perm_str); } if (op=='=') { mod = _ch_mod; } else { if (mod==0) mod = buf.st_mode & all_mode_mask; } if (op=='+') { mod |= _ch_mod; } if (op=='-') { mod = mod & (~_ch_mod); } } if (chmod(path,mod)!=0) { int err = errno; EV_LOG(ERR,COM,0,"COM-USER-PERM","Unable to change the file permissions %s:%x (%d)",path,mod,err); return STD_ERR(COM,FAIL,err); } return STD_ERR_OK; }
/* @TODO send an notification when flush is done */ void nas_l2_mac_req_handler(void){ std_condition_var_init(&nas_mac_request_cv); while(1){ std_mutex_lock(&nas_mac_request_mutex); while(nas_mac_request_queue.size() == 0 ){ std_condition_var_wait(&nas_mac_request_cv,&nas_mac_request_mutex); } nas_mac_request_entry_t & req_entry = nas_mac_request_queue.front(); if(req_entry.op_type == NAS_MAC_DEL){ if(nas_mac_delete_entries_from_hw(&(req_entry.entry),req_entry.static_type, req_entry.del_type,req_entry.subtype_all) != STD_ERR_OK){ NAS_MAC_LOG(ERR,0,"Failed to remove MAC entry from hardware"); } } nas_mac_request_queue.pop(); std_mutex_unlock(&nas_mac_request_mutex); } }
int nas_acl_unlock () noexcept { return (std_mutex_unlock (&nas_acl_mutex)); }
void unlock(void) { std_mutex_unlock(&m_lock); }