@@ -13,7 +13,7 @@ use zerocopy::{Immutable, IntoBytes};
13
13
use crate :: {
14
14
erofs:: { composefs:: OverlayMetacopy , format, reader:: round_up} ,
15
15
fsverity:: FsVerityHashValue ,
16
- image ,
16
+ tree ,
17
17
} ;
18
18
19
19
#[ derive( Clone , Copy , Debug ) ]
@@ -83,7 +83,7 @@ struct Directory<'a> {
83
83
84
84
#[ derive( Debug ) ]
85
85
struct Leaf < ' a , ObjectID : FsVerityHashValue > {
86
- content : & ' a image :: LeafContent < ObjectID > ,
86
+ content : & ' a tree :: LeafContent < ObjectID > ,
87
87
nlink : usize ,
88
88
}
89
89
@@ -94,7 +94,7 @@ enum InodeContent<'a, ObjectID: FsVerityHashValue> {
94
94
}
95
95
96
96
struct Inode < ' a , ObjectID : FsVerityHashValue > {
97
- stat : & ' a image :: Stat ,
97
+ stat : & ' a tree :: Stat ,
98
98
xattrs : InodeXAttrs ,
99
99
content : InodeContent < ' a , ObjectID > ,
100
100
}
@@ -266,23 +266,23 @@ impl<'a> Directory<'a> {
266
266
impl < ObjectID : FsVerityHashValue > Leaf < ' _ , ObjectID > {
267
267
fn inode_meta ( & self ) -> ( format:: DataLayout , u32 , u64 , usize ) {
268
268
let ( layout, u, size) = match & self . content {
269
- image :: LeafContent :: Regular ( image :: RegularFile :: Inline ( data) ) => {
269
+ tree :: LeafContent :: Regular ( tree :: RegularFile :: Inline ( data) ) => {
270
270
if data. is_empty ( ) {
271
271
( format:: DataLayout :: FlatPlain , 0 , data. len ( ) as u64 )
272
272
} else {
273
273
( format:: DataLayout :: FlatInline , 0 , data. len ( ) as u64 )
274
274
}
275
275
}
276
- image :: LeafContent :: Regular ( image :: RegularFile :: External ( .., size) ) => {
276
+ tree :: LeafContent :: Regular ( tree :: RegularFile :: External ( .., size) ) => {
277
277
( format:: DataLayout :: ChunkBased , 31 , * size)
278
278
}
279
- image :: LeafContent :: CharacterDevice ( rdev) | image :: LeafContent :: BlockDevice ( rdev) => {
279
+ tree :: LeafContent :: CharacterDevice ( rdev) | tree :: LeafContent :: BlockDevice ( rdev) => {
280
280
( format:: DataLayout :: FlatPlain , * rdev as u32 , 0 )
281
281
}
282
- image :: LeafContent :: Fifo | image :: LeafContent :: Socket => {
282
+ tree :: LeafContent :: Fifo | tree :: LeafContent :: Socket => {
283
283
( format:: DataLayout :: FlatPlain , 0 , 0 )
284
284
}
285
- image :: LeafContent :: Symlink ( target) => {
285
+ tree :: LeafContent :: Symlink ( target) => {
286
286
( format:: DataLayout :: FlatInline , 0 , target. len ( ) as u64 )
287
287
}
288
288
} ;
@@ -291,9 +291,9 @@ impl<ObjectID: FsVerityHashValue> Leaf<'_, ObjectID> {
291
291
292
292
fn write_inline ( & self , output : & mut impl Output ) {
293
293
output. write ( match self . content {
294
- image :: LeafContent :: Regular ( image :: RegularFile :: Inline ( data) ) => data,
295
- image :: LeafContent :: Regular ( image :: RegularFile :: External ( ..) ) => b"\xff \xff \xff \xff " , // null chunk
296
- image :: LeafContent :: Symlink ( target) => target. as_bytes ( ) ,
294
+ tree :: LeafContent :: Regular ( tree :: RegularFile :: Inline ( data) ) => data,
295
+ tree :: LeafContent :: Regular ( tree :: RegularFile :: External ( ..) ) => b"\xff \xff \xff \xff " , // null chunk
296
+ tree :: LeafContent :: Symlink ( target) => target. as_bytes ( ) ,
297
297
_ => & [ ] ,
298
298
} ) ;
299
299
}
@@ -304,12 +304,12 @@ impl<ObjectID: FsVerityHashValue> Inode<'_, ObjectID> {
304
304
match & self . content {
305
305
InodeContent :: Directory ( ..) => format:: FileType :: Directory ,
306
306
InodeContent :: Leaf ( leaf) => match & leaf. content {
307
- image :: LeafContent :: Regular ( ..) => format:: FileType :: RegularFile ,
308
- image :: LeafContent :: CharacterDevice ( ..) => format:: FileType :: CharacterDevice ,
309
- image :: LeafContent :: BlockDevice ( ..) => format:: FileType :: BlockDevice ,
310
- image :: LeafContent :: Fifo => format:: FileType :: Fifo ,
311
- image :: LeafContent :: Socket => format:: FileType :: Socket ,
312
- image :: LeafContent :: Symlink ( ..) => format:: FileType :: Symlink ,
307
+ tree :: LeafContent :: Regular ( ..) => format:: FileType :: RegularFile ,
308
+ tree :: LeafContent :: CharacterDevice ( ..) => format:: FileType :: CharacterDevice ,
309
+ tree :: LeafContent :: BlockDevice ( ..) => format:: FileType :: BlockDevice ,
310
+ tree :: LeafContent :: Fifo => format:: FileType :: Fifo ,
311
+ tree :: LeafContent :: Socket => format:: FileType :: Socket ,
312
+ tree :: LeafContent :: Symlink ( ..) => format:: FileType :: Symlink ,
313
313
} ,
314
314
}
315
315
}
@@ -397,16 +397,16 @@ impl<ObjectID: FsVerityHashValue> Inode<'_, ObjectID> {
397
397
398
398
struct InodeCollector < ' a , ObjectID : FsVerityHashValue > {
399
399
inodes : Vec < Inode < ' a , ObjectID > > ,
400
- hardlinks : HashMap < * const image :: Leaf < ObjectID > , usize > ,
400
+ hardlinks : HashMap < * const tree :: Leaf < ObjectID > , usize > ,
401
401
}
402
402
403
403
impl < ' a , ObjectID : FsVerityHashValue > InodeCollector < ' a , ObjectID > {
404
- fn push_inode ( & mut self , stat : & ' a image :: Stat , content : InodeContent < ' a , ObjectID > ) -> usize {
404
+ fn push_inode ( & mut self , stat : & ' a tree :: Stat , content : InodeContent < ' a , ObjectID > ) -> usize {
405
405
let mut xattrs = InodeXAttrs :: default ( ) ;
406
406
407
407
// We need to record extra xattrs for some files. These come first.
408
408
if let InodeContent :: Leaf ( Leaf {
409
- content : image :: LeafContent :: Regular ( image :: RegularFile :: External ( id, ..) ) ,
409
+ content : tree :: LeafContent :: Regular ( tree :: RegularFile :: External ( id, ..) ) ,
410
410
..
411
411
} ) = content
412
412
{
@@ -442,7 +442,7 @@ impl<'a, ObjectID: FsVerityHashValue> InodeCollector<'a, ObjectID> {
442
442
inode
443
443
}
444
444
445
- fn collect_leaf ( & mut self , leaf : & ' a Rc < image :: Leaf < ObjectID > > ) -> usize {
445
+ fn collect_leaf ( & mut self , leaf : & ' a Rc < tree :: Leaf < ObjectID > > ) -> usize {
446
446
let nlink = Rc :: strong_count ( leaf) ;
447
447
448
448
if nlink > 1 {
@@ -481,7 +481,7 @@ impl<'a, ObjectID: FsVerityHashValue> InodeCollector<'a, ObjectID> {
481
481
entries. insert ( point, entry) ;
482
482
}
483
483
484
- fn collect_dir ( & mut self , dir : & ' a image :: Directory < ObjectID > , parent : usize ) -> usize {
484
+ fn collect_dir ( & mut self , dir : & ' a tree :: Directory < ObjectID > , parent : usize ) -> usize {
485
485
// The root inode number needs to fit in a u16. That more or less compels us to write the
486
486
// directory inode before the inode of the children of the directory. Reserve a slot.
487
487
let me = self . push_inode ( & dir. stat , InodeContent :: Directory ( Directory :: default ( ) ) ) ;
@@ -490,8 +490,8 @@ impl<'a, ObjectID: FsVerityHashValue> InodeCollector<'a, ObjectID> {
490
490
491
491
for ( name, inode) in dir. sorted_entries ( ) {
492
492
let child = match inode {
493
- image :: Inode :: Directory ( dir) => self . collect_dir ( dir, me) ,
494
- image :: Inode :: Leaf ( leaf) => self . collect_leaf ( leaf) ,
493
+ tree :: Inode :: Directory ( dir) => self . collect_dir ( dir, me) ,
494
+ tree :: Inode :: Leaf ( leaf) => self . collect_leaf ( leaf) ,
495
495
} ;
496
496
entries. push ( DirEnt {
497
497
name : name. as_bytes ( ) ,
@@ -509,7 +509,7 @@ impl<'a, ObjectID: FsVerityHashValue> InodeCollector<'a, ObjectID> {
509
509
me
510
510
}
511
511
512
- pub fn collect ( fs : & ' a image :: FileSystem < ObjectID > ) -> Vec < Inode < ' a , ObjectID > > {
512
+ pub fn collect ( fs : & ' a tree :: FileSystem < ObjectID > ) -> Vec < Inode < ' a , ObjectID > > {
513
513
let mut this = Self {
514
514
inodes : vec ! [ ] ,
515
515
hardlinks : HashMap :: new ( ) ,
@@ -688,7 +688,7 @@ impl Output for FirstPass {
688
688
}
689
689
}
690
690
691
- pub fn mkfs_erofs < ObjectID : FsVerityHashValue > ( fs : & image :: FileSystem < ObjectID > ) -> Box < [ u8 ] > {
691
+ pub fn mkfs_erofs < ObjectID : FsVerityHashValue > ( fs : & tree :: FileSystem < ObjectID > ) -> Box < [ u8 ] > {
692
692
// Create the intermediate representation: flattened inodes and shared xattrs
693
693
let mut inodes = InodeCollector :: collect ( fs) ;
694
694
let xattrs = share_xattrs ( & mut inodes) ;
0 commit comments