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

Function sys_ksem_getvalue

freebsd/kern/uipc_sem.c:880–910  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

878};
879#endif
880int
881sys_ksem_getvalue(struct thread *td, struct ksem_getvalue_args *uap)
882{
883 cap_rights_t rights;
884 struct file *fp;
885 struct ksem *ks;
886 int error, val;
887
888 AUDIT_ARG_FD(uap->id);
889 error = ksem_get(td, uap->id,
890 cap_rights_init_one(&rights, CAP_SEM_GETVALUE), &fp);
891 if (error)
892 return (error);
893 ks = fp->f_data;
894
895 mtx_lock(&sem_lock);
896#ifdef MAC
897 error = mac_posixsem_check_getvalue(td->td_ucred, fp->f_cred, ks);
898 if (error) {
899 mtx_unlock(&sem_lock);
900 fdrop(fp, td);
901 return (error);
902 }
903#endif
904 val = ks->ks_value;
905 vfs_timestamp(&ks->ks_atime);
906 mtx_unlock(&sem_lock);
907 fdrop(fp, td);
908 error = copyout(&val, uap->val, sizeof(val));
909 return (error);
910}
911
912#ifndef _SYS_SYSPROTO_H_
913struct ksem_destroy_args {

Callers

nothing calls this directly

Calls 6

ksem_getFunction · 0.85
vfs_timestampFunction · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70
copyoutFunction · 0.50

Tested by

no test coverage detected