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 err = squashfs_get_id(sb, le16_to_cpu(sqsh_ino->uid), &i_uid); in squashfs_new_inode()
55 err = squashfs_get_id(sb, le16_to_cpu(sqsh_ino->guid), &i_gid); in squashfs_new_inode()
61 inode->i_ino = le32_to_cpu(sqsh_ino->inode_number); in squashfs_new_inode()
62 inode->i_mtime.tv_sec = le32_to_cpu(sqsh_ino->mtime); in squashfs_new_inode()
63 inode->i_atime.tv_sec = inode->i_mtime.tv_sec; in squashfs_new_inode()
64 inode->i_ctime.tv_sec = inode->i_mtime.tv_sec; in squashfs_new_inode()
65 inode->i_mode = le16_to_cpu(sqsh_ino->mode); in squashfs_new_inode()
66 inode->i_size = 0; in squashfs_new_inode()
81 return ERR_PTR(-ENOMEM); in squashfs_iget()
82 if (!(inode->i_state & I_NEW)) in squashfs_iget()
102 struct super_block *sb = inode->i_sb; in squashfs_read_inode()
103 struct squashfs_sb_info *msblk = sb->s_fs_info; in squashfs_read_inode()
104 u64 block = SQUASHFS_INODE_BLK(ino) + msblk->inode_table; in squashfs_read_inode()
105 int err, type, offset = SQUASHFS_INODE_OFFSET(ino); in squashfs_read_inode() local
116 &offset, sizeof(*sqshb_ino)); in squashfs_read_inode()
124 block = SQUASHFS_INODE_BLK(ino) + msblk->inode_table; in squashfs_read_inode()
125 offset = SQUASHFS_INODE_OFFSET(ino); in squashfs_read_inode()
127 type = le16_to_cpu(sqshb_ino->inode_type); in squashfs_read_inode()
135 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
140 frag = le32_to_cpu(sqsh_ino->fragment); in squashfs_read_inode()
142 frag_offset = le32_to_cpu(sqsh_ino->offset); in squashfs_read_inode()
155 inode->i_size = le32_to_cpu(sqsh_ino->file_size); in squashfs_read_inode()
156 inode->i_fop = &generic_ro_fops; in squashfs_read_inode()
157 inode->i_mode |= S_IFREG; in squashfs_read_inode()
158 inode->i_blocks = ((inode->i_size - 1) >> 9) + 1; in squashfs_read_inode()
159 squashfs_i(inode)->fragment_block = frag_blk; in squashfs_read_inode()
160 squashfs_i(inode)->fragment_size = frag_size; in squashfs_read_inode()
161 squashfs_i(inode)->fragment_offset = frag_offset; in squashfs_read_inode()
162 squashfs_i(inode)->start = le32_to_cpu(sqsh_ino->start_block); in squashfs_read_inode()
163 squashfs_i(inode)->block_list_start = block; in squashfs_read_inode()
164 squashfs_i(inode)->offset = offset; in squashfs_read_inode()
165 inode->i_data.a_ops = &squashfs_aops; in squashfs_read_inode()
167 TRACE("File inode %x:%x, start_block %llx, block_list_start " in squashfs_read_inode()
168 "%llx, offset %x\n", SQUASHFS_INODE_BLK(ino), in squashfs_read_inode()
169 offset, squashfs_i(inode)->start, block, offset); in squashfs_read_inode()
178 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
183 frag = le32_to_cpu(sqsh_ino->fragment); in squashfs_read_inode()
185 frag_offset = le32_to_cpu(sqsh_ino->offset); in squashfs_read_inode()
197 xattr_id = le32_to_cpu(sqsh_ino->xattr); in squashfs_read_inode()
198 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink)); in squashfs_read_inode()
199 inode->i_size = le64_to_cpu(sqsh_ino->file_size); in squashfs_read_inode()
200 inode->i_op = &squashfs_inode_ops; in squashfs_read_inode()
201 inode->i_fop = &generic_ro_fops; in squashfs_read_inode()
202 inode->i_mode |= S_IFREG; in squashfs_read_inode()
203 inode->i_blocks = (inode->i_size - in squashfs_read_inode()
204 le64_to_cpu(sqsh_ino->sparse) + 511) >> 9; in squashfs_read_inode()
206 squashfs_i(inode)->fragment_block = frag_blk; in squashfs_read_inode()
207 squashfs_i(inode)->fragment_size = frag_size; in squashfs_read_inode()
208 squashfs_i(inode)->fragment_offset = frag_offset; in squashfs_read_inode()
209 squashfs_i(inode)->start = le64_to_cpu(sqsh_ino->start_block); in squashfs_read_inode()
210 squashfs_i(inode)->block_list_start = block; in squashfs_read_inode()
211 squashfs_i(inode)->offset = offset; in squashfs_read_inode()
212 inode->i_data.a_ops = &squashfs_aops; in squashfs_read_inode()
214 TRACE("File inode %x:%x, start_block %llx, block_list_start " in squashfs_read_inode()
215 "%llx, offset %x\n", SQUASHFS_INODE_BLK(ino), in squashfs_read_inode()
216 offset, squashfs_i(inode)->start, block, offset); in squashfs_read_inode()
222 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
227 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink)); in squashfs_read_inode()
228 inode->i_size = le16_to_cpu(sqsh_ino->file_size); in squashfs_read_inode()
229 inode->i_op = &squashfs_dir_inode_ops; in squashfs_read_inode()
230 inode->i_fop = &squashfs_dir_ops; in squashfs_read_inode()
231 inode->i_mode |= S_IFDIR; in squashfs_read_inode()
232 squashfs_i(inode)->start = le32_to_cpu(sqsh_ino->start_block); in squashfs_read_inode()
233 squashfs_i(inode)->offset = le16_to_cpu(sqsh_ino->offset); in squashfs_read_inode()
234 squashfs_i(inode)->dir_idx_cnt = 0; in squashfs_read_inode()
235 squashfs_i(inode)->parent = le32_to_cpu(sqsh_ino->parent_inode); in squashfs_read_inode()
237 TRACE("Directory inode %x:%x, start_block %llx, offset %x\n", in squashfs_read_inode()
238 SQUASHFS_INODE_BLK(ino), offset, in squashfs_read_inode()
239 squashfs_i(inode)->start, in squashfs_read_inode()
240 le16_to_cpu(sqsh_ino->offset)); in squashfs_read_inode()
246 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
251 xattr_id = le32_to_cpu(sqsh_ino->xattr); in squashfs_read_inode()
252 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink)); in squashfs_read_inode()
253 inode->i_size = le32_to_cpu(sqsh_ino->file_size); in squashfs_read_inode()
254 inode->i_op = &squashfs_dir_inode_ops; in squashfs_read_inode()
255 inode->i_fop = &squashfs_dir_ops; in squashfs_read_inode()
256 inode->i_mode |= S_IFDIR; in squashfs_read_inode()
257 squashfs_i(inode)->start = le32_to_cpu(sqsh_ino->start_block); in squashfs_read_inode()
258 squashfs_i(inode)->offset = le16_to_cpu(sqsh_ino->offset); in squashfs_read_inode()
259 squashfs_i(inode)->dir_idx_start = block; in squashfs_read_inode()
260 squashfs_i(inode)->dir_idx_offset = offset; in squashfs_read_inode()
261 squashfs_i(inode)->dir_idx_cnt = le16_to_cpu(sqsh_ino->i_count); in squashfs_read_inode()
262 squashfs_i(inode)->parent = le32_to_cpu(sqsh_ino->parent_inode); in squashfs_read_inode()
264 TRACE("Long directory inode %x:%x, start_block %llx, offset " in squashfs_read_inode()
265 "%x\n", SQUASHFS_INODE_BLK(ino), offset, in squashfs_read_inode()
266 squashfs_i(inode)->start, in squashfs_read_inode()
267 le16_to_cpu(sqsh_ino->offset)); in squashfs_read_inode()
274 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
279 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink)); in squashfs_read_inode()
280 inode->i_size = le32_to_cpu(sqsh_ino->symlink_size); in squashfs_read_inode()
281 inode->i_op = &squashfs_symlink_inode_ops; in squashfs_read_inode()
283 inode->i_data.a_ops = &squashfs_symlink_aops; in squashfs_read_inode()
284 inode->i_mode |= S_IFLNK; in squashfs_read_inode()
285 squashfs_i(inode)->start = block; in squashfs_read_inode()
286 squashfs_i(inode)->offset = offset; in squashfs_read_inode()
292 &offset, inode->i_size); in squashfs_read_inode()
296 &offset, sizeof(xattr)); in squashfs_read_inode()
302 TRACE("Symbolic link inode %x:%x, start_block %llx, offset " in squashfs_read_inode()
303 "%x\n", SQUASHFS_INODE_BLK(ino), offset, in squashfs_read_inode()
304 block, offset); in squashfs_read_inode()
312 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
318 inode->i_mode |= S_IFCHR; in squashfs_read_inode()
320 inode->i_mode |= S_IFBLK; in squashfs_read_inode()
321 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink)); in squashfs_read_inode()
322 rdev = le32_to_cpu(sqsh_ino->rdev); in squashfs_read_inode()
323 init_special_inode(inode, inode->i_mode, new_decode_dev(rdev)); in squashfs_read_inode()
325 TRACE("Device inode %x:%x, rdev %x\n", in squashfs_read_inode()
326 SQUASHFS_INODE_BLK(ino), offset, rdev); in squashfs_read_inode()
334 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
340 inode->i_mode |= S_IFCHR; in squashfs_read_inode()
342 inode->i_mode |= S_IFBLK; in squashfs_read_inode()
343 xattr_id = le32_to_cpu(sqsh_ino->xattr); in squashfs_read_inode()
344 inode->i_op = &squashfs_inode_ops; in squashfs_read_inode()
345 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink)); in squashfs_read_inode()
346 rdev = le32_to_cpu(sqsh_ino->rdev); in squashfs_read_inode()
347 init_special_inode(inode, inode->i_mode, new_decode_dev(rdev)); in squashfs_read_inode()
349 TRACE("Device inode %x:%x, rdev %x\n", in squashfs_read_inode()
350 SQUASHFS_INODE_BLK(ino), offset, rdev); in squashfs_read_inode()
357 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
363 inode->i_mode |= S_IFIFO; in squashfs_read_inode()
365 inode->i_mode |= S_IFSOCK; in squashfs_read_inode()
366 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink)); in squashfs_read_inode()
367 init_special_inode(inode, inode->i_mode, 0); in squashfs_read_inode()
374 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, in squashfs_read_inode()
380 inode->i_mode |= S_IFIFO; in squashfs_read_inode()
382 inode->i_mode |= S_IFSOCK; in squashfs_read_inode()
383 xattr_id = le32_to_cpu(sqsh_ino->xattr); in squashfs_read_inode()
384 inode->i_op = &squashfs_inode_ops; in squashfs_read_inode()
385 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink)); in squashfs_read_inode()
386 init_special_inode(inode, inode->i_mode, 0); in squashfs_read_inode()
391 return -EINVAL; in squashfs_read_inode()
394 if (xattr_id != SQUASHFS_INVALID_XATTR && msblk->xattr_id_table) { in squashfs_read_inode()
396 &squashfs_i(inode)->xattr_count, in squashfs_read_inode()
397 &squashfs_i(inode)->xattr_size, in squashfs_read_inode()
398 &squashfs_i(inode)->xattr); in squashfs_read_inode()
401 inode->i_blocks += ((squashfs_i(inode)->xattr_size - 1) >> 9) in squashfs_read_inode()
404 squashfs_i(inode)->xattr_count = 0; in squashfs_read_inode()
409 ERROR("Unable to read inode 0x%llx\n", ino); in squashfs_read_inode()