MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sys_ksem_post

Function sys_ksem_post

freebsd/kern/uipc_sem.c:718–752  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

716};
717#endif
718int
719sys_ksem_post(struct thread *td, struct ksem_post_args *uap)
720{
721 cap_rights_t rights;
722 struct file *fp;
723 struct ksem *ks;
724 int error;
725
726 AUDIT_ARG_FD(uap->id);
727 error = ksem_get(td, uap->id,
728 cap_rights_init_one(&rights, CAP_SEM_POST), &fp);
729 if (error)
730 return (error);
731 ks = fp->f_data;
732
733 mtx_lock(&sem_lock);
734#ifdef MAC
735 error = mac_posixsem_check_post(td->td_ucred, fp->f_cred, ks);
736 if (error)
737 goto err;
738#endif
739 if (ks->ks_value == SEM_VALUE_MAX) {
740 error = EOVERFLOW;
741 goto err;
742 }
743 ++ks->ks_value;
744 if (ks->ks_waiters > 0)
745 cv_signal(&ks->ks_cv);
746 error = 0;
747 vfs_timestamp(&ks->ks_ctime);
748err:
749 mtx_unlock(&sem_lock);
750 fdrop(fp, td);
751 return (error);
752}
753
754#ifndef _SYS_SYSPROTO_H_
755struct ksem_wait_args {

Callers

nothing calls this directly

Calls 6

ksem_getFunction · 0.85
mac_posixsem_check_postFunction · 0.85
vfs_timestampFunction · 0.85
mtx_lockFunction · 0.70
cv_signalFunction · 0.70
mtx_unlockFunction · 0.70

Tested by

no test coverage detected