@@ -321,11 +321,10 @@ static bool ipf_update_all_data_and_mht_nodes(pf_context_t* pf) {
321
321
return ret ;
322
322
}
323
323
324
- static bool ipf_read_node (pf_context_t * pf , pf_handle_t handle , uint64_t node_number , void * buffer ,
325
- uint32_t node_size ) {
326
- uint64_t offset = node_number * node_size ;
324
+ static bool ipf_read_node (pf_context_t * pf , uint64_t node_number , void * buffer ) {
325
+ uint64_t offset = node_number * PF_NODE_SIZE ;
327
326
328
- pf_status_t status = g_cb_read (handle , buffer , offset , node_size );
327
+ pf_status_t status = g_cb_read (pf -> file , buffer , offset , PF_NODE_SIZE );
329
328
if (PF_FAILURE (status )) {
330
329
pf -> last_error = status ;
331
330
return false;
@@ -334,9 +333,10 @@ static bool ipf_read_node(pf_context_t* pf, pf_handle_t handle, uint64_t node_nu
334
333
return true;
335
334
}
336
335
337
- static bool ipf_write_file (pf_context_t * pf , pf_handle_t handle , uint64_t offset , void * buffer ,
338
- uint32_t size ) {
339
- pf_status_t status = g_cb_write (handle , buffer , offset , size );
336
+ static bool ipf_write_node (pf_context_t * pf , uint64_t node_number , void * buffer ) {
337
+ uint64_t offset = node_number * PF_NODE_SIZE ;
338
+
339
+ pf_status_t status = g_cb_write (pf -> file , buffer , offset , PF_NODE_SIZE );
340
340
if (PF_FAILURE (status )) {
341
341
pf -> last_error = status ;
342
342
return false;
@@ -345,11 +345,6 @@ static bool ipf_write_file(pf_context_t* pf, pf_handle_t handle, uint64_t offset
345
345
return true;
346
346
}
347
347
348
- static bool ipf_write_node (pf_context_t * pf , pf_handle_t handle , uint64_t node_number , void * buffer ,
349
- uint32_t node_size ) {
350
- return ipf_write_file (pf , handle , node_number * node_size , buffer , node_size );
351
- }
352
-
353
348
// this is a very 'specific' function, tied to the architecture of the file layout,
354
349
// returning the node numbers according to the data offset in the file
355
350
static void get_node_numbers (uint64_t offset , uint64_t * mht_node_number , uint64_t * data_node_number ,
@@ -408,22 +403,21 @@ static bool ipf_write_all_changes_to_disk(pf_context_t* pf) {
408
403
data_to_write = (uint8_t * )& file_node -> encrypted ;
409
404
node_number = file_node -> physical_node_number ;
410
405
411
- if (!ipf_write_node (pf , pf -> file , node_number , data_to_write , PF_NODE_SIZE )) {
406
+ if (!ipf_write_node (pf , node_number , data_to_write )) {
412
407
return false;
413
408
}
414
409
415
410
file_node -> need_writing = false;
416
411
}
417
412
418
- if (!ipf_write_node (pf , pf -> file , /*node_number=*/ 1 , & pf -> root_mht .encrypted ,
419
- PF_NODE_SIZE )) {
413
+ if (!ipf_write_node (pf , /*node_number=*/ 1 , & pf -> root_mht .encrypted )) {
420
414
return false;
421
415
}
422
416
423
417
pf -> root_mht .need_writing = false;
424
418
}
425
419
426
- if (!ipf_write_node (pf , pf -> file , /*node_number=*/ 0 , & pf -> file_metadata , PF_NODE_SIZE )) {
420
+ if (!ipf_write_node (pf , /*node_number=*/ 0 , & pf -> file_metadata )) {
427
421
return false;
428
422
}
429
423
@@ -666,8 +660,8 @@ static file_node_t* ipf_read_data_node(pf_context_t* pf, uint64_t offset) {
666
660
file_data_node -> physical_node_number = physical_node_number ;
667
661
file_data_node -> parent = file_mht_node ;
668
662
669
- if (!ipf_read_node (pf , pf -> file , file_data_node -> physical_node_number ,
670
- file_data_node -> encrypted .cipher , PF_NODE_SIZE )) {
663
+ if (!ipf_read_node (pf , file_data_node -> physical_node_number ,
664
+ file_data_node -> encrypted .cipher )) {
671
665
free (file_data_node );
672
666
return NULL ;
673
667
}
@@ -731,8 +725,8 @@ static file_node_t* ipf_read_mht_node(pf_context_t* pf, uint64_t mht_node_number
731
725
file_mht_node -> physical_node_number = physical_node_number ;
732
726
file_mht_node -> parent = parent_file_mht_node ;
733
727
734
- if (!ipf_read_node (pf , pf -> file , file_mht_node -> physical_node_number ,
735
- file_mht_node -> encrypted .cipher , PF_NODE_SIZE )) {
728
+ if (!ipf_read_node (pf , file_mht_node -> physical_node_number ,
729
+ file_mht_node -> encrypted .cipher )) {
736
730
free (file_mht_node );
737
731
return NULL ;
738
732
}
@@ -805,8 +799,7 @@ static bool ipf_init_existing_file(pf_context_t* pf, const char* path) {
805
799
pf_status_t status ;
806
800
807
801
// read meta-data node
808
- if (!ipf_read_node (pf , pf -> file , /*node_number=*/ 0 , (uint8_t * )& pf -> file_metadata ,
809
- PF_NODE_SIZE )) {
802
+ if (!ipf_read_node (pf , /*node_number=*/ 0 , (uint8_t * )& pf -> file_metadata )) {
810
803
return false;
811
804
}
812
805
@@ -850,8 +843,7 @@ static bool ipf_init_existing_file(pf_context_t* pf, const char* path) {
850
843
851
844
if (pf -> encrypted_part_plain .size > MD_USER_DATA_SIZE ) {
852
845
// read the root node of the mht
853
- if (!ipf_read_node (pf , pf -> file , /*node_number=*/ 1 , & pf -> root_mht .encrypted .cipher ,
854
- PF_NODE_SIZE ))
846
+ if (!ipf_read_node (pf , /*node_number=*/ 1 , & pf -> root_mht .encrypted .cipher ))
855
847
return false;
856
848
857
849
// this also verifies the root mht gmac against the gmac in the meta-data encrypted part
0 commit comments