fs_config: align with new explicit fs_config target_out parameter
Bug: 21989305
Bug: 22048934
Change-Id: I82c16c70a776e13b3365672b2820ee965525de9a
Signed-off-by: Thierry Strudel <tstrudel@google.com>
diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c
index c089d25..669d080 100644
--- a/ext4_utils/make_ext4fs.c
+++ b/ext4_utils/make_ext4fs.c
@@ -123,7 +123,7 @@
that does not exist on disk (e.g. lost+found).
dir_path is an absolute path, with trailing slash, to the same directory
if the image were mounted at the specified mount point */
-static u32 build_directory_structure(const char *full_path, const char *dir_path,
+static u32 build_directory_structure(const char *full_path, const char *dir_path, const char *target_out_path,
u32 dir_inode, fs_config_func_t fs_config_func,
struct selabel_handle *sehnd, int verbose, time_t fixed_time)
{
@@ -201,7 +201,7 @@
unsigned int uid = 0;
unsigned int gid = 0;
int dir = S_ISDIR(stat.st_mode);
- fs_config_func(dentries[i].path, dir, &uid, &gid, &mode, &capabilities);
+ fs_config_func(dentries[i].path, dir, target_out_path, &uid, &gid, &mode, &capabilities);
dentries[i].mode = mode;
dentries[i].uid = uid;
dentries[i].gid = gid;
@@ -285,8 +285,8 @@
ret = asprintf(&subdir_dir_path, "%s/", dentries[i].path);
if (ret < 0)
critical_error_errno("asprintf");
- entry_inode = build_directory_structure(subdir_full_path,
- subdir_dir_path, inode, fs_config_func, sehnd, verbose, fixed_time);
+ entry_inode = build_directory_structure(subdir_full_path, subdir_dir_path, target_out_path,
+ inode, fs_config_func, sehnd, verbose, fixed_time);
free(subdir_full_path);
free(subdir_dir_path);
} else if (dentries[i].file_type == EXT4_FT_SYMLINK) {
@@ -404,7 +404,7 @@
reset_ext4fs_info();
info.len = len;
- return make_ext4fs_internal(fd, NULL, mountpoint, NULL, 0, 1, 0, 0, 0, sehnd, 0, -1, NULL);
+ return make_ext4fs_internal(fd, NULL, NULL, mountpoint, NULL, 0, 1, 0, 0, 0, sehnd, 0, -1, NULL);
}
int make_ext4fs(const char *filename, long long len,
@@ -422,7 +422,7 @@
return EXIT_FAILURE;
}
- status = make_ext4fs_internal(fd, NULL, mountpoint, NULL, 0, 0, 0, 1, 0, sehnd, 0, -1, NULL);
+ status = make_ext4fs_internal(fd, NULL, NULL, mountpoint, NULL, 0, 0, 0, 1, 0, sehnd, 0, -1, NULL);
close(fd);
return status;
@@ -488,7 +488,7 @@
return canonicalize_slashes(str, false);
}
-int make_ext4fs_internal(int fd, const char *_directory,
+int make_ext4fs_internal(int fd, const char *_directory, const char *_target_out_directory,
const char *_mountpoint, fs_config_func_t fs_config_func, int gzip,
int sparse, int crc, int wipe, int real_uuid,
struct selabel_handle *sehnd, int verbose, time_t fixed_time,
@@ -498,6 +498,7 @@
u16 root_mode;
char *mountpoint;
char *directory = NULL;
+ char *target_out_directory = NULL;
if (setjmp(setjmp_env))
return EXIT_FAILURE; /* Handle a call to longjmp() */
@@ -512,6 +513,10 @@
directory = canonicalize_rel_slashes(_directory);
}
+ if (_target_out_directory) {
+ target_out_directory = canonicalize_rel_slashes(_target_out_directory);
+ }
+
if (info.len <= 0)
info.len = get_file_size(fd);
@@ -600,7 +605,7 @@
root_inode_num = build_default_directory_structure(mountpoint, sehnd);
#else
if (directory)
- root_inode_num = build_directory_structure(directory, mountpoint, 0,
+ root_inode_num = build_directory_structure(directory, mountpoint, target_out_directory, 0,
fs_config_func, sehnd, verbose, fixed_time);
else
root_inode_num = build_default_directory_structure(mountpoint, sehnd);