Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:block\ioctl.c Create Date:2022-07-28 17:16:01
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:blkpg_ioctl

Proto:static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user *arg)

Type:int

Parameter:

TypeParameterName
struct block_device *bdev
struct blkpg_ioctl_arg __user *arg
25  If Not Check operation authority Then Return -EACCES
27  If copy_from_user( & a, arg, sizeof(structblkpg_ioctl_arg)) Then Return -EFAULT
29  If copy_from_user( & p, data, sizeof(structblkpg_partition)) Then Return -EFAULT
31  disk = bd_disk
32  If bdev != bd_contains Then Return -EINVAL
34  partno = partition number
35  If partno <= 0 Then Return -EINVAL
38  Case op == The subfunctions (for the op field)
39  start = starting offset in bytes >> 9
40  length = length in bytes >> 9
42  If sizeof(sector_t) == sizeof(long) && sizeof(longlong) > sizeof(long) Then
44  pstart = start , plength = length
45  If pstart != start || plength != length || pstart < 0 || plength < 0 || partno > 65535 Then Return -EINVAL
50  If starting offset in bytes & bdev_logical_block_size(bdev) - 1 Then Return -EINVAL
53  mutex_lock( & open/close mutex )
56  disk_part_iter_init( & piter, disk, clude 0-sized parts )
66  disk_part_iter_exit( & piter)
69  part = add_partition(disk, partno, start, length, ADDPART_FLAG_NONE, NULL)
71  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.
72  Return PTR_ERR_OR_ZERO(part)
73  Case op == BLKPG_DEL_PARTITION
74  part = disk_get_part(disk, partno)
75  If Not part Then Return -ENXIO
78  bdevp = bdget(part_devt(part))
79  disk_put_part(part)
80  If Not bdevp Then Return -ENOMEM
83  mutex_lock( & open/close mutex )
84  If bd_openers Then
86  bdput(bdevp)
87  Return -EBUSY
90  fsync_bdev(bdevp)
91  invalidate_bdev(bdevp)
93  mutex_lock_nested( & open/close mutex , 1)
94  delete_partition(disk, partno)
95  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.
96  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.
97  bdput(bdevp)
99  Return 0
100  Case op == BLKPG_RESIZE_PARTITION
101  start = starting offset in bytes >> 9
103  length = length in bytes >> 9
105  If sizeof(sector_t) == sizeof(long) && sizeof(longlong) > sizeof(long) Then
107  pstart = start , plength = length
108  If pstart != start || plength != length || pstart < 0 || plength < 0 Then Return -EINVAL
112  part = disk_get_part(disk, partno)
113  If Not part Then Return -ENXIO
115  bdevp = bdget(part_devt(part))
116  If Not bdevp Then
118  Return -ENOMEM
120  mutex_lock( & open/close mutex )
121  mutex_lock_nested( & open/close mutex , 1)
122  If start != start_sect Then
125  bdput(bdevp)
127  Return -EINVAL
130  disk_part_iter_init( & piter, disk, clude 0-sized parts )
145  disk_part_iter_exit( & piter)
146  Should be called with mutex lock held (typically bd_mutex) of partition* to provide mutual exlusion among writers otherwise seqcount might be* left in wrong state leaving the readers spinning infinitely.
147  NOTE: unlike i_size_read(), i_size_write() does need locking around it* (normally i_mutex), otherwise on 32bit/SMP an update of i_size_seqcount* can be lost, resulting in subsequent i_size_read() calls spinning forever.
148  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.
149  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.
150  bdput(bdevp)
151  disk_put_part(part)
152  Return 0
153  Default
154  Return -EINVAL
Caller
NameDescribe
blkdev_ioctlalways keep this in sync with compat_blkdev_ioctl()