MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / test_rfs

Function test_rfs

src/rfs.c:79–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79static int test_rfs(const disk_t *disk_car, const struct reiserfs_super_block *sb, const partition_t *partition, const int verbose)
80{
81 if (memcmp(sb->s_magic,REISERFS_SUPER_MAGIC,sizeof(REISERFS_SUPER_MAGIC)) != 0 &&
82 memcmp(sb->s_magic,REISERFS2_SUPER_MAGIC,sizeof(REISERFS2_SUPER_MAGIC)) != 0 &&
83 memcmp(sb->s_magic,REISERFS3_SUPER_MAGIC,sizeof(REISERFS3_SUPER_MAGIC)) != 0)
84 return 1;
85 /*
86 * sanity checks.
87 */
88
89 if (le32(sb->s_block_count) < le32(sb->s_free_blocks))
90 return (1);
91
92 if (le32(sb->s_block_count) < REISERFS_MIN_BLOCK_AMOUNT)
93 return (1);
94
95 if ((le16(sb->s_state) != REISERFS_VALID_FS) &&
96 (le16(sb->s_state) != REISERFS_ERROR_FS))
97 return (1);
98
99 if (le16(sb->s_oid_maxsize) % 2!=0) /* must be even */
100 return (1);
101
102 if (le16(sb->s_oid_maxsize) < le16(sb->s_oid_cursize))
103 return (1);
104
105 if ((le16(sb->s_blocksize) != 4096) && (le16(sb->s_blocksize) != 8192))
106 return (1);
107
108 if(partition==NULL)
109 return 0;
110 if(verbose>0)
111 log_info("\nReiserFS Marker at %u/%u/%u\n",
112 offset2cylinder(disk_car,partition->part_offset),
113 offset2head(disk_car,partition->part_offset),
114 offset2sector(disk_car,partition->part_offset));
115 return 0;
116}
117
118static int test_rfs4(const disk_t *disk_car, const struct reiser4_master_sb *sb, const partition_t *partition, const int verbose)
119{

Callers 2

check_rfsFunction · 0.85
recover_rfsFunction · 0.85

Calls 3

offset2cylinderFunction · 0.85
offset2headFunction · 0.85
offset2sectorFunction · 0.85

Tested by

no test coverage detected