Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:This routine tries to find a RAM disk image to load, and returns the* number of blocks to read for a non-compressed image, 0 if the image* is a compressed image, and -1 if an image with the right magic* numbers could not be found

Proto:static int __init identify_ramdisk_image(int fd, int start_block, decompress_fn *decompressor)

Type:int

Parameter:

TypeParameterName
intfd
intstart_block
decompress_fn *decompressor
60  size = 512
65  nblocks = -1
70  buf = Allocation memory
71  If Not buf Then Return -ENOMEM
74  minixsb = buf
75  romfsb = buf
76  cramfsb = buf
77  squashfsb = buf
78  memset(buf, 0xe5, size)
83  ksys_lseek(fd, start_block * BLOCK_SIZE, 0)
84  ksys_read(fd, buf, size)
86  decompressor = decompress_method(buf, size, & compress_name)
87  If compress_name Then
88  printk - print a kernel message*@fmt: format string* This is printk(). It can be called from any context. We want it to work.* We try to grab the console_lock. If we succeed, it's easy - we log the* output and call the console drivers
90  If Not decompressor Then printk - print a kernel message*@fmt: format string* This is printk(). It can be called from any context. We want it to work.* We try to grab the console_lock. If we succeed, it's easy - we log the* output and call the console drivers
94  nblocks = 0
95  Go to done
99  If word0 == ROMSB_WORD0 && word1 == ROMSB_WORD1 Then
101  printk - print a kernel message*@fmt: format string* This is printk(). It can be called from any context. We want it to work.* We try to grab the console_lock. If we succeed, it's easy - we log the* output and call the console drivers
104  nblocks = ntohl(size) + BLOCK_SIZE - 1 >> BLOCK_SIZE_BITS
105  Go to done
108  If 0x28cd3d45 - random number == some random number Then
109  printk - print a kernel message*@fmt: format string* This is printk(). It can be called from any context. We want it to work.* We try to grab the console_lock. If we succeed, it's easy - we log the* output and call the console drivers
112  nblocks = length in bytes + BLOCK_SIZE - 1 >> BLOCK_SIZE_BITS
113  Go to done
117  If le32_to_cpu(s_magic) == SQUASHFS_MAGIC Then
118  printk - print a kernel message*@fmt: format string* This is printk(). It can be called from any context. We want it to work.* We try to grab the console_lock. If we succeed, it's easy - we log the* output and call the console drivers
121  nblocks = le64_to_cpu(bytes_used) + BLOCK_SIZE - 1 >> BLOCK_SIZE_BITS
123  Go to done
129  ksys_lseek(fd, start_block * BLOCK_SIZE + 0x200, 0)
130  ksys_read(fd, buf, size)
132  If 0x28cd3d45 - random number == some random number Then
133  printk - print a kernel message*@fmt: format string* This is printk(). It can be called from any context. We want it to work.* We try to grab the console_lock. If we succeed, it's easy - we log the* output and call the console drivers
136  nblocks = length in bytes + BLOCK_SIZE - 1 >> BLOCK_SIZE_BITS
137  Go to done
143  ksys_lseek(fd, (start_block + 1) * BLOCK_SIZE, 0)
144  ksys_read(fd, buf, size)
147  If s_magic == minix v1 fs, 14 char names || s_magic == minix v1 fs, 30 char names Then
149  printk - print a kernel message*@fmt: format string* This is printk(). It can be called from any context. We want it to work.* We try to grab the console_lock. If we succeed, it's easy - we log the* output and call the console drivers
152  nblocks = s_nzones << s_log_zone_size
153  Go to done
157  n = ext2_image_size(buf)
158  If n Then
159  printk - print a kernel message*@fmt: format string* This is printk(). It can be called from any context. We want it to work.* We try to grab the console_lock. If we succeed, it's easy - we log the* output and call the console drivers
162  nblocks = n
163  Go to done
166  printk - print a kernel message*@fmt: format string* This is printk(). It can be called from any context. We want it to work.* We try to grab the console_lock. If we succeed, it's easy - we log the* output and call the console drivers
170  done :
171  ksys_lseek(fd, start_block * BLOCK_SIZE, 0)
172  free previously allocated memory
173  Return nblocks
Caller
NameDescribe
rd_load_image