Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:string_get_size - get the size in the specified units*@size: The size to be converted in blocks*@blk_size: Size of the block (use 1 for size in bytes)*@units: units to use (powers of 1000 or 1024)*@buf: buffer to format to*@len: length of buffer* This

Proto:void string_get_size(u64 size, u64 blk_size, const enum string_size_units units, char *buf, int len)

Type:void

Parameter:

TypeParameterName
u64size
u64blk_size
const enum string_size_unitsunits
char *buf
intlen
37  static const char * const units_10[] = {"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}
40  static const char * const units_2[] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"}
43  static const char * const * const units_str[] = {[use powers of 10^3 (standard SI) ] = units_10, [use binary powers of 2^10 ] = units_2, }
47  static const unsigned int divisor[] = {[use powers of 10^3 (standard SI) ] = 1000, [use binary powers of 2^10 ] = 1024, }
51  static const unsigned int rounding[] = {500, 50, 5}
52  i = 0
53  remainder = 0
57  tmp[0] = '\0'
59  If blk_size == 0 Then size = 0
61  If size == 0 Then Go to out
75  When blk_size >> 32 cycle
76  do_div() is NOT a C function(blk_size, divisor[units])
77  i++
80  When size >> 32 cycle
81  do_div() is NOT a C function(size, divisor[units])
82  i++
87  size *= blk_size
90  When size >= divisor[units] cycle
91  remainder = do_div() is NOT a C function(size, divisor[units])
92  i++
97  sf_cap = size
98  When sf_cap * 10 < 1000 cycle sf_cap *= 10
101  If units == use binary powers of 2^10 Then
105  remainder *= 1000
106  remainder >>= 10
111  remainder += rounding[j]
112  If remainder >= 1000 Then
113  remainder -= 1000
114  size += 1
117  If j Then
118  snprintf - Format a string and place it in a buffer*@buf: The buffer to place the result into*@size: The size of the buffer, including the trailing null space*@fmt: The format string to use*@
119  tmp[j + 1] = '\0'
122  out :
123  If i >= ARRAY_SIZE - get the number of elements in array @arr*@arr: array to be sized(units_2) Then unit = "UNK"
125  Else unit = units_str[units][i]
128  snprintf - Format a string and place it in a buffer*@buf: The buffer to place the result into*@size: The size of the buffer, including the trailing null space*@fmt: The format string to use*@
Caller
NameDescribe
__test_string_get_size
report_hugepages