@@ -372,28 +372,24 @@ static char *canonicalize_rel_slashes(const char *str)
372372}
373373
374374int make_ext4fs_internal (int fd , const char * _directory ,
375- const char * _mountpoint , fs_config_func_t fs_config_func , int gzip ,
375+ fs_config_func_t fs_config_func , int gzip ,
376376 int sparse , int crc , int wipe ,
377377 int verbose , time_t fixed_time ,
378378 FILE * block_list_file )
379379{
380380 u32 root_inode_num ;
381381 u16 root_mode ;
382- char * mountpoint ;
383382 char * directory = NULL ;
384383
385384 if (setjmp (setjmp_env ))
386385 return EXIT_FAILURE ; /* Handle a call to longjmp() */
387386
388- if (_mountpoint == NULL ) {
389- mountpoint = strdup ("" );
390- } else {
391- mountpoint = canonicalize_abs_slashes (_mountpoint );
387+ if (_directory == NULL ) {
388+ fprintf (stderr , "Need a source directory\n" );
389+ return EXIT_FAILURE ;
392390 }
393391
394- if (_directory ) {
395- directory = canonicalize_rel_slashes (_directory );
396- }
392+ directory = canonicalize_rel_slashes (_directory );
397393
398394 if (info .len <= 0 )
399395 info .len = get_file_size (fd );
@@ -477,11 +473,8 @@ int make_ext4fs_internal(int fd, const char *_directory,
477473 if (info .feat_compat & EXT4_FEATURE_COMPAT_RESIZE_INODE )
478474 ext4_create_resize_inode ();
479475
480- if (directory )
481- root_inode_num = build_directory_structure (directory , mountpoint , 0 ,
482- fs_config_func , verbose , fixed_time );
483- else
484- root_inode_num = build_default_directory_structure (mountpoint );
476+ root_inode_num = build_directory_structure (directory , "" , 0 ,
477+ fs_config_func , verbose , fixed_time );
485478
486479 root_mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH ;
487480 inode_set_permissions (root_inode_num , root_mode , 0 , 0 , 0 );
@@ -491,12 +484,11 @@ int make_ext4fs_internal(int fd, const char *_directory,
491484 ext4_queue_sb ();
492485
493486 if (block_list_file ) {
494- size_t dirlen = directory ? strlen (directory ) : 0 ;
487+ size_t dirlen = strlen (directory );
495488 struct block_allocation * p = get_saved_allocation_chain ();
496489 while (p ) {
497- if (directory && strncmp (p -> filename , directory , dirlen ) == 0 ) {
498- // substitute mountpoint for the leading directory in the filename, in the output file
499- fprintf (block_list_file , "%s%s" , mountpoint , p -> filename + dirlen );
490+ if (strncmp (p -> filename , directory , dirlen ) == 0 ) {
491+ fprintf (block_list_file , "%s" , p -> filename + dirlen );
500492 } else {
501493 fprintf (block_list_file , "%s" , p -> filename );
502494 }
@@ -522,7 +514,6 @@ int make_ext4fs_internal(int fd, const char *_directory,
522514 sparse_file_destroy (ext4_sparse_file );
523515 ext4_sparse_file = NULL ;
524516
525- free (mountpoint );
526517 free (directory );
527518
528519 return 0 ;
0 commit comments