@@ -604,11 +604,12 @@ static int calc_pnode_num_from_parent(const struct ubifs_info *c,
604
604
* @lpt_first: LEB number of first LPT LEB
605
605
* @lpt_lebs: number of LEBs for LPT is passed and returned here
606
606
* @big_lpt: use big LPT model is passed and returned here
607
+ * @hash: hash of the LPT is returned here
607
608
*
608
609
* This function returns %0 on success and a negative error code on failure.
609
610
*/
610
611
int ubifs_create_dflt_lpt (struct ubifs_info * c , int * main_lebs , int lpt_first ,
611
- int * lpt_lebs , int * big_lpt )
612
+ int * lpt_lebs , int * big_lpt , u8 * hash )
612
613
{
613
614
int lnum , err = 0 , node_sz , iopos , i , j , cnt , len , alen , row ;
614
615
int blnum , boffs , bsz , bcnt ;
@@ -617,6 +618,7 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first,
617
618
void * buf = NULL , * p ;
618
619
struct ubifs_lpt_lprops * ltab = NULL ;
619
620
int * lsave = NULL ;
621
+ struct shash_desc * desc ;
620
622
621
623
err = calc_dflt_lpt_geom (c , main_lebs , big_lpt );
622
624
if (err )
@@ -630,6 +632,10 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first,
630
632
/* Needed by 'ubifs_pack_lsave()' */
631
633
c -> main_first = c -> leb_cnt - * main_lebs ;
632
634
635
+ desc = ubifs_hash_get_desc (c );
636
+ if (IS_ERR (desc ))
637
+ return PTR_ERR (desc );
638
+
633
639
lsave = kmalloc_array (c -> lsave_cnt , sizeof (int ), GFP_KERNEL );
634
640
pnode = kzalloc (sizeof (struct ubifs_pnode ), GFP_KERNEL );
635
641
nnode = kzalloc (sizeof (struct ubifs_nnode ), GFP_KERNEL );
@@ -677,6 +683,10 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first,
677
683
678
684
/* Add first pnode */
679
685
ubifs_pack_pnode (c , p , pnode );
686
+ err = ubifs_shash_update (c , desc , p , c -> pnode_sz );
687
+ if (err )
688
+ goto out ;
689
+
680
690
p += c -> pnode_sz ;
681
691
len = c -> pnode_sz ;
682
692
pnode -> num += 1 ;
@@ -711,6 +721,10 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first,
711
721
len = 0 ;
712
722
}
713
723
ubifs_pack_pnode (c , p , pnode );
724
+ err = ubifs_shash_update (c , desc , p , c -> pnode_sz );
725
+ if (err )
726
+ goto out ;
727
+
714
728
p += c -> pnode_sz ;
715
729
len += c -> pnode_sz ;
716
730
/*
@@ -830,6 +844,10 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first,
830
844
if (err )
831
845
goto out ;
832
846
847
+ err = ubifs_shash_final (c , desc , hash );
848
+ if (err )
849
+ goto out ;
850
+
833
851
c -> nhead_lnum = lnum ;
834
852
c -> nhead_offs = ALIGN (len , c -> min_io_size );
835
853
@@ -853,6 +871,7 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first,
853
871
dbg_lp ("LPT lsave is at %d:%d" , c -> lsave_lnum , c -> lsave_offs );
854
872
out :
855
873
c -> ltab = NULL ;
874
+ kfree (desc );
856
875
kfree (lsave );
857
876
vfree (ltab );
858
877
vfree (buf );
0 commit comments