Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\printk\printk.c Create Date:2022-07-28 10:05:57
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:devkmsg_read

Proto:static ssize_t devkmsg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)

Type:ssize_t

Parameter:

TypeParameterName
struct file *file
char __user *buf
size_tcount
loff_t *ppos
871  user = needed for tty driver, and maybe others
876  If Not user Then Return -EBADF
879  ret = mutex_lock_interruptible( & lock)
880  If ret Then Return ret
883  Helper macros to lock/unlock logbuf_lock and switch between* printk-safe/unsafe modes.()
884  When seq == dex and sequence number of the next record to store in the buffer cycle
885  If f_flags & O_NONBLOCK Then
886  ret = -EAGAIN
888  Go to out
891  logbuf_unlock_irq()
892  ret = wait_event_interruptible - sleep until a condition gets true*@wq_head: the waitqueue to wait on*@condition: a C expression for the event to wait for* The process is put to sleep (TASK_INTERRUPTIBLE) until the(log_wait, seq != dex and sequence number of the next record to store in the buffer )
894  If ret Then Go to out
896  Helper macros to lock/unlock logbuf_lock and switch between* printk-safe/unsafe modes.()
899  If seq < dex and sequence number of the first record stored in the buffer Then
901  idx = log_first_idx
902  seq = dex and sequence number of the first record stored in the buffer
903  ret = -EPIPE
904  logbuf_unlock_irq()
905  Go to out
908  msg = get record by index; idx must point to valid msg
909  len = msg_print_ext_header(buf, size of buf , msg, seq)
911  len += msg_print_ext_body(buf + len, size of buf - len, ptional key/value pair dictionary attached to the record , length of dictionary buffer , human readable text of the record , length of text buffer )
915  idx = get next record; idx must point to valid msg
916  seq++
917  logbuf_unlock_irq()
919  If len > count Then
920  ret = -EINVAL
921  Go to out
924  If copy_to_user(buf, buf, len) Then
925  ret = -EFAULT
926  Go to out
928  ret = len
929  out :
930  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
931  Return ret