Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:get_cmdline() - copy the cmdline value to a buffer.*@task: the task whose cmdline value to copy.*@buffer: the buffer to copy to.*@buflen: the length of the buffer. Larger cmdline values are truncated* to this length.

Proto:int get_cmdline(struct task_struct *task, char *buffer, int buflen)

Type:int

Parameter:

TypeParameterName
struct task_struct *task
char *buffer
intbuflen
855  res = 0
857  mm = get_task_mm - acquire a reference to the task's mm* Returns %NULL if the task has no mm. Checks PF_KTHREAD (meaning* this kernel workthread has transiently adopted a user mm with use_mm,* to do its AIO) is not set and if so returns a reference to it, after
859  If Not mm Then Go to out
861  If Not arg_end Then Go to out_mm
864  spin_lock( & protect the below fields )
865  arg_start = arg_start
866  arg_end = arg_end
867  env_start = env_start
868  env_end = env_end
869  spin_unlock( & protect the below fields )
871  len = arg_end - arg_start
873  If len > buflen Then len = buflen
876  res = access_process_vm(task, arg_start, buffer, len, get_user_pages read/write w/o permission )
882  If res > 0 && buffer[res - 1] != '\0' && len < buflen Then
883  len = strnlen(buffer, res)
884  If len < res Then
885  res = len
886  Else
887  len = env_end - env_start
888  If len > buflen - res Then len = buflen - res
893  res = strnlen(buffer, res)
896  out_mm :
897  Decrement the use count and release all resources for an mm.
898  out :
899  Return res
Caller
NameDescribe
kstrdup_quotable_cmdlineReturns allocated NULL-terminated string containing process* command line, with inter-argument NULLs replaced with spaces,* and other special characters escaped.