Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Allocate a new array of pipe buffers and copy the info over. Returns the* pipe size if successful, or return -ERROR on error.

Proto:static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg)

Type:long

Parameter:

TypeParameterName
struct pipe_inode_info *pipe
unsigned longarg
1174  ret = 0
1176  size = Currently we rely on the pipe array holding a power-of-2 number* of pages. Returns 0 on error.
1177  nr_slots = size >> PAGE_SHIFT determines the page size
1179  If Not nr_slots Then Return -EINVAL
1189  If nr_slots > ring_size && size > The max size that a non-root user is allowed to grow the pipe. Can* be set by root in /proc/sys/fs/pipe-max-size && Not Check operation authority Then Return -EPERM
1193  user_bufs = account_pipe_buffers(user, ring_size, nr_slots)
1195  If nr_slots > ring_size && (too_many_pipe_buffers_hard(user_bufs) || too_many_pipe_buffers_soft(user_bufs)) && is_unprivileged_user() Then
1199  ret = -EPERM
1200  Go to out_revert_acct
1209  mask = ring_size - 1
1210  head = head
1211  tail = tail
1212  n = pipe_occupancy - Return number of slots used in the pipe*@head: The pipe ring head pointer*@tail: The pipe ring tail pointer
1213  If nr_slots < n Then
1214  ret = -EBUSY
1215  Go to out_revert_acct
1218  bufs = kcalloc - allocate memory for an array. The memory is set to zero.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc).
1220  If Value for the false possibility is greater at compile time(!bufs) Then
1221  ret = -ENOMEM
1222  Go to out_revert_acct
1229  If n > 0 Then
1230  h = head & mask
1231  t = tail & mask
1232  If h > t Then
1233  memcpy(bufs, bufs + t, n * sizeof(structpipe_buffer))
1235  Else
1236  tsize = ring_size - t
1237  If h > 0 Then memcpy(bufs + tsize, bufs, h * sizeof(structpipe_buffer))
1240  memcpy(bufs, bufs + t, tsize * sizeof(structpipe_buffer))
1245  head = n
1246  tail = 0
1248  kfree(bufs)
1249  bufs = bufs
1250  ring_size = nr_slots
1251  max_usage = nr_slots
1252  tail = tail
1253  head = head
1254  wake_up_interruptible_all( & wait)
1255  Return max_usage * PAGE_SIZE
1257  out_revert_acct :
1258  account_pipe_buffers(user, nr_slots, ring_size)
1259  Return ret
Caller
NameDescribe
pipe_fcntl