fs_config: align with new explicit fs_config target_out parameter

Bug: 21989305
Bug: 22048934
Change-Id: I5b49d521562245cae00fa9701c92dc0a1fa3dd80
Signed-off-by: Thierry Strudel <tstrudel@google.com>
diff --git a/squashfs-tools/android.c b/squashfs-tools/android.c
index aaf91b5..4881d50 100644
--- a/squashfs-tools/android.c
+++ b/squashfs-tools/android.c
@@ -43,10 +43,10 @@
     strcat(*mounted_path, subpath);
 }
 
-void android_fs_config(const char *path, struct stat *stat) {
+void android_fs_config(const char *path, struct stat *stat, const char *target_out_path) {
     unsigned long capabilities = 0;
-    fs_config(path, S_ISDIR(stat->st_mode), &stat->st_uid, &stat->st_gid, &stat->st_mode,
-            &capabilities);
+    fs_config(path, S_ISDIR(stat->st_mode), target_out_path,
+              &stat->st_uid, &stat->st_gid, &stat->st_mode, &capabilities);
 }
 
 
diff --git a/squashfs-tools/android.h b/squashfs-tools/android.h
index b290b8e..c2e7018 100644
--- a/squashfs-tools/android.h
+++ b/squashfs-tools/android.h
@@ -18,7 +18,7 @@
 #define _ANDROID_H_
 
 void alloc_mounted_path(const char *mount_point, const char *subpath, char **mounted_path);
-void android_fs_config(const char *path, struct stat *stat);
+void android_fs_config(const char *path, struct stat *stat, const char *target_out_path);
 struct selabel_handle *get_sehnd(const char *context_file);
 char *set_selabel(const char *path, unsigned int mode, struct selabel_handle *sehnd);
 
diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
index 9e80d0a..67592b2 100644
--- a/squashfs-tools/mksquashfs.c
+++ b/squashfs-tools/mksquashfs.c
@@ -83,6 +83,7 @@
 int android_config = FALSE;
 char *context_file = NULL;
 char *mount_point = NULL;
+char *target_out_path = NULL;
 #endif
 /* ANDROID CHANGES END */
 
@@ -3054,10 +3055,10 @@
 		if (mount_point) {
 			char *mounted_path;
 			alloc_mounted_path(mount_point, subpathname(dir_ent), &mounted_path);
-			android_fs_config(mounted_path, &inode_info->buf);
+			android_fs_config(mounted_path, &inode_info->buf, target_out_path);
 			free(mounted_path);
 		} else {
-			android_fs_config(pathname(dir_ent), &inode_info->buf);
+			android_fs_config(pathname(dir_ent), &inode_info->buf, target_out_path);
 		}
 	}
 #endif
@@ -3158,9 +3159,9 @@
 #ifdef ANDROID
 		if (android_config)
 			if (mount_point)
-				android_fs_config(mount_point, &buf);
+				android_fs_config(mount_point, &buf, target_out_path);
 			else
-				android_fs_config(pathname, &buf);
+				android_fs_config(pathname, &buf, target_out_path);
 #endif
 /* ANDROID CHANGES END */
 		dir_ent->inode = lookup_inode(&buf);
@@ -5603,6 +5604,14 @@
 			}
 			mount_point = argv[i];
 		}
+		else if(strcmp(argv[i], "-product-out") == 0) {
+			if(++i == argc) {
+				ERROR("%s: -product-out: missing path name\n",
+					argv[0]);
+				exit(1);
+			}
+			target_out_path = argv[i];
+		}
 #endif
 /* ANDROID CHANGES END */
 
@@ -5673,6 +5682,8 @@
 			ERROR("-mount-point <name>\tNeed to be provided when "
 				"android-fs-config or context-file\n\t\t\tare "
 				"enabled and source directory is not mount point\n");
+			ERROR("-product-out <path>\tPRODUCT_OUT directory to "
+                                "read device specific FS rules files from\n");
 #endif
 /* ANDROID CHANGES END */
 			ERROR("\nFilesystem filter options:\n");