Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:ipc\msg.c Create Date:2022-07-28 16:42:16
Last Modify:2020-03-17 22:56:56 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:do_msgsnd

Proto:static long do_msgsnd(int msqid, long mtype, void __user *mtext, size_t msgsz, int msgflg)

Type:long

Parameter:

TypeParameterName
intmsqid
longmtype
void __user *mtext
size_tmsgsz
intmsgflg
826  ns = ipc_ns
828  If msgsz > msg_ctlmax || msgsz < 0 || msqid < 0 Then Return -EINVAL
830  If mtype < 1 Then Return -EINVAL
833  msg = load_msg(mtext, msgsz)
834  If IS_ERR(msg) Then Return PTR_ERR(msg)
837  m_type = mtype
838  message text size = msgsz
840  _read_lock() - mark the beginning of an RCU read-side critical section* When synchronize_rcu() is invoked on one CPU while other CPUs* are within RCU read-side critical sections, then the* synchronize_rcu() is guaranteed to block until after all the other
841  msq = msq_obtain_object_check(ns, msqid)
842  If IS_ERR(msq) Then
843  err = PTR_ERR(msq)
844  Go to out_unlock1
847  ipc_lock_object( & q_perm)
849  cycle
852  err = -EACCES
853  If pcperms - check ipc permissions*@ns: ipc namespace*@ipcp: ipc permission set*@flag: desired permission set* Check user, group, other permissions for access* to ipc resources. return 0 if allowed*@flag will most probably be 0 or ``S_ Then Go to out_unlock0
858  err = -EIDRM
859  Go to out_unlock0
862  err = security_msg_queue_msgsnd( & q_perm, msg, msgflg)
863  If err Then Go to out_unlock0
866  If msg_fits_inqueue(msq, msgsz) Then Break
870  If msgflg & urn error on wait Then
871  err = -EAGAIN
872  Go to out_unlock0
876  ss_add(msq, & s, msgsz)
878  If Not ipc_rcu_getref( & q_perm) Then
879  err = -EIDRM
880  Go to out_unlock0
883  ipc_unlock_object( & q_perm)
884  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
885  schedule()
887  _read_lock() - mark the beginning of an RCU read-side critical section* When synchronize_rcu() is invoked on one CPU while other CPUs* are within RCU read-side critical sections, then the* synchronize_rcu() is guaranteed to block until after all the other
888  ipc_lock_object( & q_perm)
890  ipc_rcu_putref( & q_perm, msg_rcu_free)
893  err = -EIDRM
894  Go to out_unlock0
896  ss_del( & s)
900  Go to out_unlock0
905  ipc_update_pid( & pid of last msgsnd , task_tgid(current process))
906  last msgsnd time = ktime_get_real_seconds - Get the seconds portion of CLOCK_REALTIME* Returns the wall clock seconds since 1970. This replaces the* get_seconds() interface which is not y2038 safe on 32bit systems.
908  If Not pipelined_send(msq, msg, & wake_q) Then
910  list_add_tail - add a new entry*@new: new entry to be added*@head: list head to add it before* Insert a new entry before the specified head.* This is useful for implementing queues.
911  current number of bytes on queue += msgsz
912  umber of messages in queue ++
913  atomic_add(msgsz, & msg_bytes)
914  atomic_inc( & msg_hdrs)
917  err = 0
918  msg = NULL
920  out_unlock0 :
921  ipc_unlock_object( & q_perm)
922  wake_up_q( & wake_q)
923  out_unlock1 :
924  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
925  If (msg != NULL) Then free_msg(msg)
927  Return err
Caller
NameDescribe
ksys_msgsnd
compat_ksys_msgsnd