@@ -149,7 +149,9 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
149149
150150 if ((o -> object .flags & OBJECT_COMPRESSED_XZ ) &&
151151 o -> object .type != OBJECT_DATA ) {
152- error (offset , "Found compressed object that isn't of type DATA, which is not allowed." );
152+ error (offset ,
153+ "Found compressed object of type %s that isn't of type data, which is not allowed." ,
154+ journal_object_type_to_string (o -> object .type ));
153155 return - EBADMSG ;
154156 }
155157
@@ -291,8 +293,8 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
291293 if ((le64toh (o -> object .size ) - offsetof(HashTableObject , items )) % sizeof (HashItem ) != 0 ||
292294 (le64toh (o -> object .size ) - offsetof(HashTableObject , items )) / sizeof (HashItem ) <= 0 ) {
293295 error (offset ,
294- "Invalid %s hash table size: %" PRIu64 ,
295- o -> object .type == OBJECT_DATA_HASH_TABLE ? "data" : "field" ,
296+ "Invalid %s size: %" PRIu64 ,
297+ journal_object_type_to_string ( o -> object .type ) ,
296298 le64toh (o -> object .size ));
297299 return - EBADMSG ;
298300 }
@@ -302,7 +304,7 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
302304 !VALID64 (le64toh (o -> hash_table .items [i ].head_hash_offset ))) {
303305 error (offset ,
304306 "Invalid %s hash table item (%" PRIu64 "/%" PRIu64 ") head_hash_offset: " OFSfmt ,
305- o -> object .type == OBJECT_DATA_HASH_TABLE ? "data" : "field" ,
307+ journal_object_type_to_string ( o -> object .type ) ,
306308 i , journal_file_hash_table_n_items (o ),
307309 le64toh (o -> hash_table .items [i ].head_hash_offset ));
308310 return - EBADMSG ;
@@ -311,7 +313,7 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
311313 !VALID64 (le64toh (o -> hash_table .items [i ].tail_hash_offset ))) {
312314 error (offset ,
313315 "Invalid %s hash table item (%" PRIu64 "/%" PRIu64 ") tail_hash_offset: " OFSfmt ,
314- o -> object .type == OBJECT_DATA_HASH_TABLE ? "data" : "field" ,
316+ journal_object_type_to_string ( o -> object .type ) ,
315317 i , journal_file_hash_table_n_items (o ),
316318 le64toh (o -> hash_table .items [i ].tail_hash_offset ));
317319 return - EBADMSG ;
@@ -321,7 +323,7 @@ static int journal_file_object_verify(JournalFile *f, uint64_t offset, Object *o
321323 (o -> hash_table .items [i ].tail_hash_offset != 0 )) {
322324 error (offset ,
323325 "Invalid %s hash table item (%" PRIu64 "/%" PRIu64 "): head_hash_offset=" OFSfmt " tail_hash_offset=" OFSfmt ,
324- o -> object .type == OBJECT_DATA_HASH_TABLE ? "data" : "field" ,
326+ journal_object_type_to_string ( o -> object .type ) ,
325327 i , journal_file_hash_table_n_items (o ),
326328 le64toh (o -> hash_table .items [i ].head_hash_offset ),
327329 le64toh (o -> hash_table .items [i ].tail_hash_offset ));
@@ -569,7 +571,7 @@ static int verify_data(
569571
570572 q = le64toh (o -> entry_array .items [j ]);
571573 if (q <= last ) {
572- error (p , "Data object's entry array not sorted" );
574+ error (p , "Data object's entry array not sorted (%" PRIu64 " <= %" PRIu64 ")" , q , last );
573575 return - EBADMSG ;
574576 }
575577 last = q ;
@@ -655,7 +657,10 @@ static int verify_data_hash_table(
655657 }
656658
657659 if (last != le64toh (f -> data_hash_table [i ].tail_hash_offset )) {
658- error (p , "Tail hash pointer mismatch in hash table" );
660+ error (p ,
661+ "Tail hash pointer mismatch in hash table (%" PRIu64 " != %" PRIu64 ")" ,
662+ last ,
663+ le64toh (f -> data_hash_table [i ].tail_hash_offset ));
659664 return - EBADMSG ;
660665 }
661666 }
@@ -987,12 +992,15 @@ int journal_file_verify(
987992
988993 r = journal_file_move_to_object (f , OBJECT_UNUSED , p , & o );
989994 if (r < 0 ) {
990- error (p , "Invalid object" );
995+ error_errno (p , r , "Invalid object: %m " );
991996 goto fail ;
992997 }
993998
994999 if (p > le64toh (f -> header -> tail_object_offset )) {
995- error (offsetof(Header , tail_object_offset ), "Invalid tail object pointer" );
1000+ error (offsetof(Header , tail_object_offset ),
1001+ "Invalid tail object pointer (%" PRIu64 " > %" PRIu64 ")" ,
1002+ p ,
1003+ le64toh (f -> header -> tail_object_offset ));
9961004 r = - EBADMSG ;
9971005 goto fail ;
9981006 }
@@ -1008,7 +1016,7 @@ int journal_file_verify(
10081016 if (!!(o -> object .flags & OBJECT_COMPRESSED_XZ ) +
10091017 !!(o -> object .flags & OBJECT_COMPRESSED_LZ4 ) +
10101018 !!(o -> object .flags & OBJECT_COMPRESSED_ZSTD ) > 1 ) {
1011- error (p , "Object has multiple compression flags set" );
1019+ error (p , "Object has multiple compression flags set (flags: 0x%x)" , o -> object . flags );
10121020 r = - EINVAL ;
10131021 goto fail ;
10141022 }
@@ -1057,21 +1065,30 @@ int journal_file_verify(
10571065 goto fail ;
10581066
10591067 if (le64toh (o -> entry .realtime ) < last_tag_realtime ) {
1060- error (p , "Older entry after newer tag" );
1068+ error (p ,
1069+ "Older entry after newer tag (%" PRIu64 " < %" PRIu64 ")" ,
1070+ le64toh (o -> entry .realtime ),
1071+ last_tag_realtime );
10611072 r = - EBADMSG ;
10621073 goto fail ;
10631074 }
10641075
10651076 if (!entry_seqnum_set &&
10661077 le64toh (o -> entry .seqnum ) != le64toh (f -> header -> head_entry_seqnum )) {
1067- error (p , "Head entry sequence number incorrect" );
1078+ error (p ,
1079+ "Head entry sequence number incorrect (%" PRIu64 " != %" PRIu64 ")" ,
1080+ le64toh (o -> entry .seqnum ),
1081+ le64toh (f -> header -> head_entry_seqnum ));
10681082 r = - EBADMSG ;
10691083 goto fail ;
10701084 }
10711085
10721086 if (entry_seqnum_set &&
10731087 entry_seqnum >= le64toh (o -> entry .seqnum )) {
1074- error (p , "Entry sequence number out of synchronization" );
1088+ error (p ,
1089+ "Entry sequence number out of synchronization (%" PRIu64 " >= %" PRIu64 ")" ,
1090+ entry_seqnum ,
1091+ le64toh (o -> entry .seqnum ));
10751092 r = - EBADMSG ;
10761093 goto fail ;
10771094 }
@@ -1082,7 +1099,10 @@ int journal_file_verify(
10821099 if (entry_monotonic_set &&
10831100 sd_id128_equal (entry_boot_id , o -> entry .boot_id ) &&
10841101 entry_monotonic > le64toh (o -> entry .monotonic )) {
1085- error (p , "Entry timestamp out of synchronization" );
1102+ error (p ,
1103+ "Entry timestamp out of synchronization (%" PRIu64 " > %" PRIu64 ")" ,
1104+ entry_monotonic ,
1105+ le64toh (o -> entry .monotonic ));
10861106 r = - EBADMSG ;
10871107 goto fail ;
10881108 }
@@ -1093,7 +1113,10 @@ int journal_file_verify(
10931113
10941114 if (!entry_realtime_set &&
10951115 le64toh (o -> entry .realtime ) != le64toh (f -> header -> head_entry_realtime )) {
1096- error (p , "Head entry realtime timestamp incorrect" );
1116+ error (p ,
1117+ "Head entry realtime timestamp incorrect (%" PRIu64 " != %" PRIu64 ")" ,
1118+ le64toh (o -> entry .realtime ),
1119+ le64toh (f -> header -> head_entry_realtime ));
10971120 r = - EBADMSG ;
10981121 goto fail ;
10991122 }
@@ -1147,13 +1170,19 @@ int journal_file_verify(
11471170 }
11481171
11491172 if (le64toh (o -> tag .seqnum ) != n_tags + 1 ) {
1150- error (p , "Tag sequence number out of synchronization" );
1173+ error (p ,
1174+ "Tag sequence number out of synchronization (%" PRIu64 " != %" PRIu64 ")" ,
1175+ le64toh (o -> tag .seqnum ),
1176+ n_tags + 1 );
11511177 r = - EBADMSG ;
11521178 goto fail ;
11531179 }
11541180
11551181 if (le64toh (o -> tag .epoch ) < last_epoch ) {
1156- error (p , "Epoch sequence out of synchronization" );
1182+ error (p ,
1183+ "Epoch sequence out of synchronization (%" PRIu64 " < %" PRIu64 ")" ,
1184+ le64toh (o -> tag .epoch ),
1185+ last_epoch );
11571186 r = - EBADMSG ;
11581187 goto fail ;
11591188 }
@@ -1166,7 +1195,10 @@ int journal_file_verify(
11661195
11671196 rt = f -> fss_start_usec + le64toh (o -> tag .epoch ) * f -> fss_interval_usec ;
11681197 if (entry_realtime_set && entry_realtime >= rt + f -> fss_interval_usec ) {
1169- error (p , "tag/entry realtime timestamp out of synchronization" );
1198+ error (p ,
1199+ "tag/entry realtime timestamp out of synchronization (%" PRIu64 " >= %" PRIu64 ")" ,
1200+ entry_realtime ,
1201+ rt + f -> fss_interval_usec );
11701202 r = - EBADMSG ;
11711203 goto fail ;
11721204 }
@@ -1240,74 +1272,103 @@ int journal_file_verify(
12401272 };
12411273
12421274 if (!found_last && le64toh (f -> header -> tail_object_offset ) != 0 ) {
1243- error (le64toh (f -> header -> tail_object_offset ), "Tail object pointer dead" );
1275+ error (le64toh (f -> header -> tail_object_offset ),
1276+ "Tail object pointer dead (%" PRIu64 " != 0)" ,
1277+ le64toh (f -> header -> tail_object_offset ));
12441278 r = - EBADMSG ;
12451279 goto fail ;
12461280 }
12471281
12481282 if (n_objects != le64toh (f -> header -> n_objects )) {
1249- error (offsetof(Header , n_objects ), "Object number mismatch" );
1283+ error (offsetof(Header , n_objects ),
1284+ "Object number mismatch (%" PRIu64 " != %" PRIu64 ")" ,
1285+ n_objects ,
1286+ le64toh (f -> header -> n_objects ));
12501287 r = - EBADMSG ;
12511288 goto fail ;
12521289 }
12531290
12541291 if (n_entries != le64toh (f -> header -> n_entries )) {
1255- error (offsetof(Header , n_entries ), "Entry number mismatch" );
1292+ error (offsetof(Header , n_entries ),
1293+ "Entry number mismatch (%" PRIu64 " != %" PRIu64 ")" ,
1294+ n_entries ,
1295+ le64toh (f -> header -> n_entries ));
12561296 r = - EBADMSG ;
12571297 goto fail ;
12581298 }
12591299
12601300 if (JOURNAL_HEADER_CONTAINS (f -> header , n_data ) &&
12611301 n_data != le64toh (f -> header -> n_data )) {
1262- error (offsetof(Header , n_data ), "Data number mismatch" );
1302+ error (offsetof(Header , n_data ),
1303+ "Data number mismatch (%" PRIu64 " != %" PRIu64 ")" ,
1304+ n_data ,
1305+ le64toh (f -> header -> n_data ));
12631306 r = - EBADMSG ;
12641307 goto fail ;
12651308 }
12661309
12671310 if (JOURNAL_HEADER_CONTAINS (f -> header , n_fields ) &&
12681311 n_fields != le64toh (f -> header -> n_fields )) {
1269- error (offsetof(Header , n_fields ), "Field number mismatch" );
1312+ error (offsetof(Header , n_fields ),
1313+ "Field number mismatch (%" PRIu64 " != %" PRIu64 ")" ,
1314+ n_fields ,
1315+ le64toh (f -> header -> n_fields ));
12701316 r = - EBADMSG ;
12711317 goto fail ;
12721318 }
12731319
12741320 if (JOURNAL_HEADER_CONTAINS (f -> header , n_tags ) &&
12751321 n_tags != le64toh (f -> header -> n_tags )) {
1276- error (offsetof(Header , n_tags ), "Tag number mismatch" );
1322+ error (offsetof(Header , n_tags ),
1323+ "Tag number mismatch (%" PRIu64 " != %" PRIu64 ")" ,
1324+ n_tags ,
1325+ le64toh (f -> header -> n_tags ));
12771326 r = - EBADMSG ;
12781327 goto fail ;
12791328 }
12801329
12811330 if (JOURNAL_HEADER_CONTAINS (f -> header , n_entry_arrays ) &&
12821331 n_entry_arrays != le64toh (f -> header -> n_entry_arrays )) {
1283- error (offsetof(Header , n_entry_arrays ), "Entry array number mismatch" );
1332+ error (offsetof(Header , n_entry_arrays ),
1333+ "Entry array number mismatch (%" PRIu64 " != %" PRIu64 ")" ,
1334+ n_entry_arrays ,
1335+ le64toh (f -> header -> n_entry_arrays ));
12841336 r = - EBADMSG ;
12851337 goto fail ;
12861338 }
12871339
12881340 if (!found_main_entry_array && le64toh (f -> header -> entry_array_offset ) != 0 ) {
1289- error (0 , "Missing entry array" );
1341+ error (0 , "Missing main entry array" );
12901342 r = - EBADMSG ;
12911343 goto fail ;
12921344 }
12931345
12941346 if (entry_seqnum_set &&
12951347 entry_seqnum != le64toh (f -> header -> tail_entry_seqnum )) {
1296- error (offsetof(Header , tail_entry_seqnum ), "Invalid tail seqnum" );
1348+ error (offsetof(Header , tail_entry_seqnum ),
1349+ "Tail entry sequence number incorrect (%" PRIu64 " != %" PRIu64 ")" ,
1350+ entry_seqnum ,
1351+ le64toh (f -> header -> tail_entry_seqnum ));
12971352 r = - EBADMSG ;
12981353 goto fail ;
12991354 }
13001355
13011356 if (entry_monotonic_set &&
13021357 (sd_id128_equal (entry_boot_id , f -> header -> boot_id ) &&
13031358 entry_monotonic != le64toh (f -> header -> tail_entry_monotonic ))) {
1304- error (0 , "Invalid tail monotonic timestamp" );
1359+ error (0 ,
1360+ "Invalid tail monotonic timestamp (%" PRIu64 " != %" PRIu64 ")" ,
1361+ entry_monotonic ,
1362+ le64toh (f -> header -> tail_entry_monotonic ));
13051363 r = - EBADMSG ;
13061364 goto fail ;
13071365 }
13081366
13091367 if (entry_realtime_set && entry_realtime != le64toh (f -> header -> tail_entry_realtime )) {
1310- error (0 , "Invalid tail realtime timestamp" );
1368+ error (0 ,
1369+ "Invalid tail realtime timestamp (%" PRIu64 " != %" PRIu64 ")" ,
1370+ entry_realtime ,
1371+ le64toh (f -> header -> tail_entry_realtime ));
13111372 r = - EBADMSG ;
13121373 goto fail ;
13131374 }
0 commit comments