Lines Matching +full:offset +full:- +full:x

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Squashfs - a compressed read only filesystem for Linux
14 * Inodes in Squashfs are identified by a 48-bit inode which encodes the
16 * offset into that block where the inode is placed (<block, offset>).
51 inode->i_ino = le32_to_cpu(sqsh_ino->inode_number); in squashfs_new_inode()
52 if (inode->i_ino == 0) in squashfs_new_inode()
53 return -EINVAL; in squashfs_new_inode()
55 err = squashfs_get_id(sb, le16_to_cpu(sqsh_ino->uid), &i_uid); in squashfs_new_inode()
59 err = squashfs_get_id(sb, le16_to_cpu(sqsh_ino->guid), &i_gid); in squashfs_new_inode()
65 inode_set_mtime(inode, le32_to_cpu(sqsh_ino->mtime), 0); in squashfs_new_inode()
68 inode->i_mode = le16_to_cpu(sqsh_ino->mode); in squashfs_new_inode()
69 inode->i_size = 0; in squashfs_new_inode()
84 return ERR_PTR(-ENOMEM); in squashfs_iget()
85 if (!(inode->i_state & I_NEW)) in squashfs_iget()
105 struct super_block *sb = inode->i_sb; in squashfs_read_inode()
106 struct squashfs_sb_info *msblk = sb->s_fs_info; in squashfs_read_inode()
107 u64 block = SQUASHFS_INODE_BLK(ino) + msblk->inode_table; in squashfs_read_inode()
108 int err, type, offset = SQUASHFS_INODE_OFFSET(ino); in squashfs_read_inode() local
119 &offset, sizeof(*sqshb_ino)); in squashfs_read_inode()
127 block = SQUASHFS_INODE_BLK(ino) + msblk->inode_table; in squashfs_read_inode()
128 offset = SQUASHFS_INODE_OFFSET(ino); in squashfs_read_inode()
130 type = le16_to_cpu(sqshb_ino->inode_type); in squashfs_read_inode()
138 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
143 frag = le32_to_cpu(sqsh_ino->fragment); in squashfs_read_inode()
145 frag_offset = le32_to_cpu(sqsh_ino->offset); in squashfs_read_inode()
158 inode->i_size = le32_to_cpu(sqsh_ino->file_size); in squashfs_read_inode()
159 inode->i_fop = &generic_ro_fops; in squashfs_read_inode()
160 inode->i_mode |= S_IFREG; in squashfs_read_inode()
161 inode->i_blocks = ((inode->i_size - 1) >> 9) + 1; in squashfs_read_inode()
162 squashfs_i(inode)->fragment_block = frag_blk; in squashfs_read_inode()
163 squashfs_i(inode)->fragment_size = frag_size; in squashfs_read_inode()
164 squashfs_i(inode)->fragment_offset = frag_offset; in squashfs_read_inode()
165 squashfs_i(inode)->start = le32_to_cpu(sqsh_ino->start_block); in squashfs_read_inode()
166 squashfs_i(inode)->block_list_start = block; in squashfs_read_inode()
167 squashfs_i(inode)->offset = offset; in squashfs_read_inode()
168 inode->i_data.a_ops = &squashfs_aops; in squashfs_read_inode()
170 TRACE("File inode %x:%x, start_block %llx, block_list_start " in squashfs_read_inode()
171 "%llx, offset %x\n", SQUASHFS_INODE_BLK(ino), in squashfs_read_inode()
172 offset, squashfs_i(inode)->start, block, offset); in squashfs_read_inode()
181 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
186 frag = le32_to_cpu(sqsh_ino->fragment); in squashfs_read_inode()
188 frag_offset = le32_to_cpu(sqsh_ino->offset); in squashfs_read_inode()
200 xattr_id = le32_to_cpu(sqsh_ino->xattr); in squashfs_read_inode()
201 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink)); in squashfs_read_inode()
202 inode->i_size = le64_to_cpu(sqsh_ino->file_size); in squashfs_read_inode()
203 inode->i_op = &squashfs_inode_ops; in squashfs_read_inode()
204 inode->i_fop = &generic_ro_fops; in squashfs_read_inode()
205 inode->i_mode |= S_IFREG; in squashfs_read_inode()
206 inode->i_blocks = (inode->i_size - in squashfs_read_inode()
207 le64_to_cpu(sqsh_ino->sparse) + 511) >> 9; in squashfs_read_inode()
209 squashfs_i(inode)->fragment_block = frag_blk; in squashfs_read_inode()
210 squashfs_i(inode)->fragment_size = frag_size; in squashfs_read_inode()
211 squashfs_i(inode)->fragment_offset = frag_offset; in squashfs_read_inode()
212 squashfs_i(inode)->start = le64_to_cpu(sqsh_ino->start_block); in squashfs_read_inode()
213 squashfs_i(inode)->block_list_start = block; in squashfs_read_inode()
214 squashfs_i(inode)->offset = offset; in squashfs_read_inode()
215 inode->i_data.a_ops = &squashfs_aops; in squashfs_read_inode()
217 TRACE("File inode %x:%x, start_block %llx, block_list_start " in squashfs_read_inode()
218 "%llx, offset %x\n", SQUASHFS_INODE_BLK(ino), in squashfs_read_inode()
219 offset, squashfs_i(inode)->start, block, offset); in squashfs_read_inode()
225 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
230 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink)); in squashfs_read_inode()
231 inode->i_size = le16_to_cpu(sqsh_ino->file_size); in squashfs_read_inode()
232 inode->i_op = &squashfs_dir_inode_ops; in squashfs_read_inode()
233 inode->i_fop = &squashfs_dir_ops; in squashfs_read_inode()
234 inode->i_mode |= S_IFDIR; in squashfs_read_inode()
235 squashfs_i(inode)->start = le32_to_cpu(sqsh_ino->start_block); in squashfs_read_inode()
236 squashfs_i(inode)->offset = le16_to_cpu(sqsh_ino->offset); in squashfs_read_inode()
237 squashfs_i(inode)->dir_idx_cnt = 0; in squashfs_read_inode()
238 squashfs_i(inode)->parent = le32_to_cpu(sqsh_ino->parent_inode); in squashfs_read_inode()
240 TRACE("Directory inode %x:%x, start_block %llx, offset %x\n", in squashfs_read_inode()
241 SQUASHFS_INODE_BLK(ino), offset, in squashfs_read_inode()
242 squashfs_i(inode)->start, in squashfs_read_inode()
243 le16_to_cpu(sqsh_ino->offset)); in squashfs_read_inode()
249 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
254 xattr_id = le32_to_cpu(sqsh_ino->xattr); in squashfs_read_inode()
255 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink)); in squashfs_read_inode()
256 inode->i_size = le32_to_cpu(sqsh_ino->file_size); in squashfs_read_inode()
257 inode->i_op = &squashfs_dir_inode_ops; in squashfs_read_inode()
258 inode->i_fop = &squashfs_dir_ops; in squashfs_read_inode()
259 inode->i_mode |= S_IFDIR; in squashfs_read_inode()
260 squashfs_i(inode)->start = le32_to_cpu(sqsh_ino->start_block); in squashfs_read_inode()
261 squashfs_i(inode)->offset = le16_to_cpu(sqsh_ino->offset); in squashfs_read_inode()
262 squashfs_i(inode)->dir_idx_start = block; in squashfs_read_inode()
263 squashfs_i(inode)->dir_idx_offset = offset; in squashfs_read_inode()
264 squashfs_i(inode)->dir_idx_cnt = le16_to_cpu(sqsh_ino->i_count); in squashfs_read_inode()
265 squashfs_i(inode)->parent = le32_to_cpu(sqsh_ino->parent_inode); in squashfs_read_inode()
267 TRACE("Long directory inode %x:%x, start_block %llx, offset " in squashfs_read_inode()
268 "%x\n", SQUASHFS_INODE_BLK(ino), offset, in squashfs_read_inode()
269 squashfs_i(inode)->start, in squashfs_read_inode()
270 le16_to_cpu(sqsh_ino->offset)); in squashfs_read_inode()
277 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
282 inode->i_size = le32_to_cpu(sqsh_ino->symlink_size); in squashfs_read_inode()
283 if (inode->i_size > PAGE_SIZE) { in squashfs_read_inode()
285 return -EINVAL; in squashfs_read_inode()
288 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink)); in squashfs_read_inode()
289 inode->i_op = &squashfs_symlink_inode_ops; in squashfs_read_inode()
291 inode->i_data.a_ops = &squashfs_symlink_aops; in squashfs_read_inode()
292 inode->i_mode |= S_IFLNK; in squashfs_read_inode()
293 squashfs_i(inode)->start = block; in squashfs_read_inode()
294 squashfs_i(inode)->offset = offset; in squashfs_read_inode()
300 &offset, inode->i_size); in squashfs_read_inode()
304 &offset, sizeof(xattr)); in squashfs_read_inode()
310 TRACE("Symbolic link inode %x:%x, start_block %llx, offset " in squashfs_read_inode()
311 "%x\n", SQUASHFS_INODE_BLK(ino), offset, in squashfs_read_inode()
312 block, offset); in squashfs_read_inode()
320 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
326 inode->i_mode |= S_IFCHR; in squashfs_read_inode()
328 inode->i_mode |= S_IFBLK; in squashfs_read_inode()
329 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink)); in squashfs_read_inode()
330 rdev = le32_to_cpu(sqsh_ino->rdev); in squashfs_read_inode()
331 init_special_inode(inode, inode->i_mode, new_decode_dev(rdev)); in squashfs_read_inode()
333 TRACE("Device inode %x:%x, rdev %x\n", in squashfs_read_inode()
334 SQUASHFS_INODE_BLK(ino), offset, rdev); in squashfs_read_inode()
342 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
348 inode->i_mode |= S_IFCHR; in squashfs_read_inode()
350 inode->i_mode |= S_IFBLK; in squashfs_read_inode()
351 xattr_id = le32_to_cpu(sqsh_ino->xattr); in squashfs_read_inode()
352 inode->i_op = &squashfs_inode_ops; in squashfs_read_inode()
353 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink)); in squashfs_read_inode()
354 rdev = le32_to_cpu(sqsh_ino->rdev); in squashfs_read_inode()
355 init_special_inode(inode, inode->i_mode, new_decode_dev(rdev)); in squashfs_read_inode()
357 TRACE("Device inode %x:%x, rdev %x\n", in squashfs_read_inode()
358 SQUASHFS_INODE_BLK(ino), offset, rdev); in squashfs_read_inode()
365 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
371 inode->i_mode |= S_IFIFO; in squashfs_read_inode()
373 inode->i_mode |= S_IFSOCK; in squashfs_read_inode()
374 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink)); in squashfs_read_inode()
375 init_special_inode(inode, inode->i_mode, 0); in squashfs_read_inode()
382 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
388 inode->i_mode |= S_IFIFO; in squashfs_read_inode()
390 inode->i_mode |= S_IFSOCK; in squashfs_read_inode()
391 xattr_id = le32_to_cpu(sqsh_ino->xattr); in squashfs_read_inode()
392 inode->i_op = &squashfs_inode_ops; in squashfs_read_inode()
393 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink)); in squashfs_read_inode()
394 init_special_inode(inode, inode->i_mode, 0); in squashfs_read_inode()
399 return -EINVAL; in squashfs_read_inode()
402 if (xattr_id != SQUASHFS_INVALID_XATTR && msblk->xattr_id_table) { in squashfs_read_inode()
404 &squashfs_i(inode)->xattr_count, in squashfs_read_inode()
405 &squashfs_i(inode)->xattr_size, in squashfs_read_inode()
406 &squashfs_i(inode)->xattr); in squashfs_read_inode()
409 inode->i_blocks += ((squashfs_i(inode)->xattr_size - 1) >> 9) in squashfs_read_inode()
412 squashfs_i(inode)->xattr_count = 0; in squashfs_read_inode()
417 ERROR("Unable to read inode 0x%llx\n", ino); in squashfs_read_inode()