1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2001 Will Dyson <will_dyson@pobox.com>
14 * Validates the correctness of the befs inode
15 * Returns BEFS_OK if the inode should be used, otherwise
16 * returns BEFS_BAD_INODE
19 befs_check_inode(struct super_block
*sb
, befs_inode
*raw_inode
,
22 u32 magic1
= fs32_to_cpu(sb
, raw_inode
->magic1
);
23 befs_inode_addr ino_num
= fsrun_to_cpu(sb
, raw_inode
->inode_num
);
24 u32 flags
= fs32_to_cpu(sb
, raw_inode
->flags
);
26 /* check magic header. */
27 if (magic1
!= BEFS_INODE_MAGIC1
) {
29 "Inode has a bad magic header - inode = %lu",
30 (unsigned long)inode
);
31 return BEFS_BAD_INODE
;
35 * Sanity check2: inodes store their own block address. Check it.
37 if (inode
!= iaddr2blockno(sb
, &ino_num
)) {
38 befs_error(sb
, "inode blocknr field disagrees with vfs "
39 "VFS: %lu, Inode %lu", (unsigned long)
40 inode
, (unsigned long)iaddr2blockno(sb
, &ino_num
));
41 return BEFS_BAD_INODE
;
48 if (!(flags
& BEFS_INODE_IN_USE
)) {
49 befs_error(sb
, "inode is not used - inode = %lu",
50 (unsigned long)inode
);
51 return BEFS_BAD_INODE
;