Snap for 7357013 from b4b786ca611bc01daeab3a9e40db03885840ee20 to sc-release

Change-Id: Ie3a253beb86f8a9c9e8c50f94c45b8ad451397c9
diff --git a/AUTHORS b/AUTHORS
index 121cf6a..3487d44 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -2,7 +2,7 @@
 M: Li Guifu <bluce.liguifu@huawei.com>
 M: Miao Xie <miaoxie@huawei.com>
 M: Fang Wei <fangwei1@huawei.com>
-R: Gao Xiang <gaoxiang25@huawei.com>
+R: Gao Xiang <xiang@kernel.org>
 R: Chao Yu <yuchao0@huawei.com>
 S: Maintained
 L: linux-erofs@lists.ozlabs.org
diff --git a/Android.bp b/Android.bp
index 1e048e5..4494013 100644
--- a/Android.bp
+++ b/Android.bp
@@ -44,6 +44,13 @@
     ],
 }
 
+genrule {
+    name: "erofs-utils-version.h",
+    srcs: ["VERSION"],
+    out: ["erofs-utils-version.h"],
+    cmd: "sed -n '1p' $(in) | tr -d '\n' | sed 's/\\(.*\\)/#define PACKAGE_VERSION \"\\1\"/' > $(out)",
+}
+
 cc_defaults {
     name: "erofs-utils_defaults",
 
@@ -53,7 +60,7 @@
         "-Wno-ignored-qualifiers",
         "-Wno-pointer-arith",
         "-Wno-unused-parameter",
-        "-DPACKAGE_VERSION=\"1.1\"",
+        "-include erofs-utils-version.h",
         "-DHAVE_FALLOCATE",
         "-DHAVE_LINUX_TYPES_H",
         "-DHAVE_LIBSELINUX",
@@ -68,6 +75,7 @@
     include_dirs: [
         "external/e2fsprogs/lib/",
     ],
+    generated_headers: ["erofs-utils-version.h"],
     shared_libs: [
         "libcutils",
         "libext2_uuid",
diff --git a/ChangeLog b/ChangeLog
index 947761a..d8e89d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+erofs-utils (1.2.1-1) unstable; urgency=medium
+
+ * A quick maintenance release includes the following updates:
+   - fix reported build issues due to different configurations;
+   - (mkfs.erofs, AOSP) fix sub-directory prefix for canned fs_config;
+   - update some obsoleted email address;
+
+ -- Gao Xiang <xiang@kernel.org>  Sun, 10 Jan 2021 00:00:00 +0800
+
 erofs-utils (1.2-1) unstable; urgency=medium
 
  * This release includes the following features and bugfixes:
@@ -10,7 +19,7 @@
    - (mkfs.erofs, AOSP) support Android fs_config;
    - (experimental, disabled by default) add erofsfuse approach;
 
- -- Gao Xiang <xiang@kernel.org>  Tue, 06 Dec 2020 00:00:00 +0800
+ -- Gao Xiang <xiang@kernel.org>  Sun, 06 Dec 2020 00:00:00 +0800
 
 erofs-utils (1.1-1) unstable; urgency=low
 
diff --git a/METADATA b/METADATA
index 30119a6..a1390e0 100644
--- a/METADATA
+++ b/METADATA
@@ -5,7 +5,7 @@
     type: GIT
     value: "https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git"
   }
-  version: "v1.2"
+  version: "v1.2.1"
   license_type: RESTRICTED
   last_upgrade_date {
     year: 2020
diff --git a/README b/README
index 0001a67..b57550b 100644
--- a/README
+++ b/README
@@ -149,7 +149,7 @@
   Fang Wei                   <fangwei1@huawei.com>
 
 Cc:
-  Gao Xiang                  <gaoxiang25@huawei.com>
+  Gao Xiang                  <xiang@kernel.org>
   Chao Yu                    <yuchao0@huawei.com>
 
 Comments
diff --git a/VERSION b/VERSION
index aabe0d1..203a5b8 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-1.2
-2020-12-06
+1.2.1
+2021-01-10
diff --git a/configure.ac b/configure.ac
index d5fdfb8..28926c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,6 +96,7 @@
 # Checks for header files.
 AC_CHECK_HEADERS(m4_flatten([
 	dirent.h
+	execinfo.h
 	fcntl.h
 	getopt.h
 	inttypes.h
@@ -147,7 +148,7 @@
    #include <unistd.h>])
 
 # Checks for library functions.
-AC_CHECK_FUNCS([fallocate gettimeofday memset realpath strdup strerror strrchr strtoull])
+AC_CHECK_FUNCS([backtrace fallocate gettimeofday memset realpath strdup strerror strrchr strtoull])
 
 # Configure libuuid
 AS_IF([test "x$with_uuid" != "xno"], [
diff --git a/fuse/Makefile.am b/fuse/Makefile.am
index f14f6fd..e7757bc 100644
--- a/fuse/Makefile.am
+++ b/fuse/Makefile.am
@@ -5,6 +5,6 @@
 bin_PROGRAMS     = erofsfuse
 erofsfuse_SOURCES = dir.c main.c
 erofsfuse_CFLAGS = -Wall -Werror -I$(top_srcdir)/include
-erofsfuse_CFLAGS += -DFUSE_USE_VERSION=26 ${libfuse_CFLAGS}
-erofsfuse_LDADD = $(top_builddir)/lib/liberofs.la ${libfuse_LIBS} ${liblz4_LIBS}
+erofsfuse_CFLAGS += -DFUSE_USE_VERSION=26 ${libfuse_CFLAGS} ${libselinux_CFLAGS}
+erofsfuse_LDADD = $(top_builddir)/lib/liberofs.la ${libfuse_LIBS} ${liblz4_LIBS} ${libselinux_LIBS}
 
diff --git a/fuse/main.c b/fuse/main.c
index 1e24efe..c162912 100644
--- a/fuse/main.c
+++ b/fuse/main.c
@@ -6,7 +6,6 @@
  */
 #include <stdlib.h>
 #include <string.h>
-#include <execinfo.h>
 #include <signal.h>
 #include <libgen.h>
 #include <fuse.h>
@@ -168,6 +167,9 @@
 	return 1;
 }
 
+#if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE)
+#include <execinfo.h>
+
 static void signal_handle_sigsegv(int signal)
 {
 	void *array[10];
@@ -187,7 +189,7 @@
 	erofs_dump("========================================\n");
 	abort();
 }
-
+#endif
 
 int main(int argc, char *argv[])
 {
@@ -197,11 +199,13 @@
 	erofs_init_configure();
 	fprintf(stderr, "%s %s\n", basename(argv[0]), cfg.c_version);
 
+#if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE)
 	if (signal(SIGSEGV, signal_handle_sigsegv) == SIG_ERR) {
 		fprintf(stderr, "failed to initialize signals\n");
 		ret = -errno;
 		goto err;
 	}
+#endif
 
 	/* parse options */
 	ret = fuse_opt_parse(&args, &fusecfg, option_spec, optional_opt_func);
diff --git a/lib/config.c b/lib/config.c
index 3155112..3ecd481 100644
--- a/lib/config.c
+++ b/lib/config.c
@@ -11,6 +11,7 @@
 #include "erofs/internal.h"
 
 struct erofs_configure cfg;
+struct erofs_sb_info sbi;
 
 void erofs_init_configure(void)
 {
diff --git a/lib/inode.c b/lib/inode.c
index 3d634fc..d0b4d51 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -22,8 +22,6 @@
 #include "erofs/xattr.h"
 #include "erofs/exclude.h"
 
-struct erofs_sb_info sbi;
-
 #define S_SHIFT                 12
 static unsigned char erofs_ftype_by_mode[S_IFMT >> S_SHIFT] = {
 	[S_IFREG >> S_SHIFT]  = EROFS_FT_REG_FILE,
@@ -698,32 +696,42 @@
 	/* filesystem_config does not preserve file type bits */
 	mode_t stat_file_type_mask = st->st_mode & S_IFMT;
 	unsigned int uid = 0, gid = 0, mode = 0;
-	char *fspath;
+	const char *fspath;
+	char *decorated = NULL;
 
 	inode->capabilities = 0;
-	if (cfg.fs_config_file)
-		canned_fs_config(erofs_fspath(path),
-				 S_ISDIR(st->st_mode),
-				 cfg.target_out_path,
-				 &uid, &gid, &mode, &inode->capabilities);
-	else if (cfg.mount_point) {
-		if (asprintf(&fspath, "%s/%s", cfg.mount_point,
+	if (!cfg.fs_config_file && !cfg.mount_point)
+		return 0;
+
+	if (!cfg.mount_point ||
+	/* have to drop the mountpoint for rootdir of canned fsconfig */
+	    (cfg.fs_config_file && erofs_fspath(path)[0] == '\0')) {
+		fspath = erofs_fspath(path);
+	} else {
+		if (asprintf(&decorated, "%s/%s", cfg.mount_point,
 			     erofs_fspath(path)) <= 0)
 			return -ENOMEM;
+		fspath = decorated;
+	}
 
+	if (cfg.fs_config_file)
+		canned_fs_config(fspath, S_ISDIR(st->st_mode),
+				 cfg.target_out_path,
+				 &uid, &gid, &mode, &inode->capabilities);
+	else
 		fs_config(fspath, S_ISDIR(st->st_mode),
 			  cfg.target_out_path,
 			  &uid, &gid, &mode, &inode->capabilities);
-		free(fspath);
-	}
-	st->st_uid = uid;
-	st->st_gid = gid;
-	st->st_mode = mode | stat_file_type_mask;
 
 	erofs_dbg("/%s -> mode = 0x%x, uid = 0x%x, gid = 0x%x, "
 		  "capabilities = 0x%" PRIx64 "\n",
-		  erofs_fspath(path),
-		  mode, uid, gid, inode->capabilities);
+		  fspath, mode, uid, gid, inode->capabilities);
+
+	if (decorated)
+		free(decorated);
+	st->st_uid = uid;
+	st->st_gid = gid;
+	st->st_mode = mode | stat_file_type_mask;
 	return 0;
 }
 #else
diff --git a/lib/super.c b/lib/super.c
index 2d36692..025cefe 100644
--- a/lib/super.c
+++ b/lib/super.c
@@ -11,8 +11,6 @@
 #include "erofs/io.h"
 #include "erofs/print.h"
 
-struct erofs_sb_info sbi;
-
 static bool check_layout_compatibility(struct erofs_sb_info *sbi,
 				       struct erofs_super_block *dsb)
 {
diff --git a/mkfs/main.c b/mkfs/main.c
index c63b274..abd48be 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -24,7 +24,7 @@
 #include "erofs/exclude.h"
 
 #ifdef HAVE_LIBUUID
-#include <uuid/uuid.h>
+#include <uuid.h>
 #endif
 
 #define EROFS_SUPER_END (EROFS_SUPER_OFFSET + sizeof(struct erofs_super_block))