MCPcopy Create free account
hub / github.com/bobranten/Ext4Fsd / ext3_check_dir_entry

Function ext3_check_dir_entry

Ext4Fsd/ext3/generic.c:2176–2204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2174}
2175
2176int ext3_check_dir_entry (const char * function, struct inode * dir,
2177 struct ext3_dir_entry_2 * de,
2178 struct buffer_head * bh,
2179 unsigned long offset)
2180{
2181 const char * error_msg = NULL;
2182 const int rlen = ext3_rec_len_from_disk(de->rec_len);
2183
2184 if (rlen < EXT3_DIR_REC_LEN(1))
2185 error_msg = "rec_len is smaller than minimal";
2186 else if (rlen % 4 != 0)
2187 error_msg = "rec_len % 4 != 0";
2188 else if (rlen < EXT3_DIR_REC_LEN(de->name_len))
2189 error_msg = "rec_len is too small for name_len";
2190 else if ((char *) de + rlen > bh->b_data + dir->i_sb->s_blocksize)
2191 error_msg = "directory entry across blocks";
2192 else if (le32_to_cpu(de->inode) >
2193 le32_to_cpu(EXT4_SB(dir->i_sb)->s_es->s_inodes_count))
2194 error_msg = "inode out of bounds";
2195
2196 if (error_msg != NULL) {
2197 DEBUG(DL_ERR, ("%s: bad entry in directory %u: %s - "
2198 "offset=%u, inode=%u, rec_len=%d, name_len=%d\n",
2199 function, dir->i_ino, error_msg, offset,
2200 (unsigned long) le32_to_cpu(de->inode),
2201 rlen, de->name_len));
2202 }
2203 return error_msg == NULL ? 1 : 0;
2204}
2205
2206
2207/*

Callers 6

add_dirent_to_bufFunction · 0.85
htree_dirblock_to_treeFunction · 0.85
ext3_dx_find_entryFunction · 0.85
ext3_delete_entryFunction · 0.85
ext3_is_dir_emptyFunction · 0.85
search_dirblockFunction · 0.85

Calls 2

ext3_rec_len_from_diskFunction · 0.85
EXT4_SBFunction · 0.85

Tested by

no test coverage detected