Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Do a strncpy, return length of string without final '\0'.* 'count' is the user-supplied count (return 'count' if we* hit it), 'max' is the address space maximum (and we return* -EFAULT if we hit it).

Proto:static inline long do_strncpy_from_user(char *dst, const char __user *src, unsigned long count, unsigned long max)

Type:long

Parameter:

TypeParameterName
char *dst
const char __user *src
unsigned longcount
unsigned longmax
30  constants = WORD_AT_A_TIME_CONSTANTS
31  res = 0
33  If IS_UNALIGNED(src, dst) Then Go to byte_at_a_time
36  When max >= sizeof(unsignedlong) cycle
40  unsafe_get_user(c, (unsignedlong__user * )(src + res), byte_at_a_time)
42  *(dst + res) = c
46  Return res + find_zero(data)
48  res += sizeof(unsignedlong)
49  max -= sizeof(unsignedlong)
52  byte_at_a_time :
53  When max cycle
56  unsafe_get_user(c, src + res, efault)
57  dst[res] = c
58  If Not c Then Return res
60  res++
61  max--
68  If res >= count Then Return res
75  efault :
76  Return -EFAULT
Caller
NameDescribe
strncpy_from_userCopy a NUL terminated string from userspace