Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEB46C43331 for ; Wed, 13 Nov 2019 06:02:17 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6B326206BA for ; Wed, 13 Nov 2019 06:02:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.ozlabs.org header.i=@lists.ozlabs.org header.b="mMskmVOQ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=aol.com header.i=@aol.com header.b="jSznvBw4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B326206BA Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=lists.ozlabs.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47CYsx6VgnzF76f for ; Wed, 13 Nov 2019 17:02:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.ozlabs.org; s=201707; t=1573624933; bh=XD22ERSiGCRDfA2q0rOyr5k3Vz4Z1UgUjo5KE0cIQY8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=mMskmVOQM0bLeXqsg8H0CP3PTgyIN2Pt8NmE/u11Gdja3obhhk9Lt7lpQZCxhcwId +iqIcdBoNMLs/HY1deQR4HZDlJ7PeOy4QlHwGVyqGRrRqdWjqutDCbdUH7klotgVzN iMrYi2TbU2YoCVjWxCK4XLiSTnwBTRCWosgqyPegs1mbi/7z2vLXMF3yO7yY4zPgiJ LTtI3M8t4e2SLE0mKjmlqSaMcwWcq40mDWx8juKpQGVXNXVqe7NnX5+cmOpFVoWuOk 3z8F+Edl5iy2Hub1a/wye65UcyZnf7L94EYilBOWtoKhEjPwTAg+SsZyDX/ATD4Ob6 0/1aZAt5rjmGg== Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aol.com (client-ip=98.137.65.206; helo=sonic311-25.consmr.mail.gq1.yahoo.com; envelope-from=hsiangkao@aol.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=aol.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aol.com header.i=@aol.com header.b="jSznvBw4"; dkim-atps=neutral Received: from sonic311-25.consmr.mail.gq1.yahoo.com (sonic311-25.consmr.mail.gq1.yahoo.com [98.137.65.206]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 47CYsj6vp4zF760 for ; Wed, 13 Nov 2019 17:01:59 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1573624916; bh=N/N4atbVXhW1Fe9A3cf7uq0Vx50hSsRxCdI7adUCkOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject; b=jSznvBw4JukwiSlWotrEKH6kS9c+470KNpd0fNMEqbxOja5lhqvuya6NlwrH/fhU+nWQVYtE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UdI3UbTvLudVoIHc6m3ovK kYENi_mbMPcSnosBYmZYF14tj81efzUjEbgRqbwGhhz415ZHEz8p7nMTespwn7LRUuzg_lB32Cyj 9W_cSSvS7gniG6J.tDIvkMq7xHVXb8aRr4SnmMzwdk18tsoJg016D0gBUHOqJvLE06BXvoK7ZZsj 2nGngylBFmxaARWF5i6KDBnahZS_.YYgGulSkJEiMiwMj6OysoJP_P2wHNPEPK2oEQoDOZh.rYZP bV2aZHpYUdw4Khza81AuKG3gjAvg349QEf2_PHpiG58F9JIz0nlQK1RnJXKyWiP.yDCYVeZmpe_6 bnh8QzKjF3zqlNVdYJ4KExXBjthA4WyKl1XPgZ8iltvNHPEyD2EnHcHaGzoelgbdR.PuY6UkhPzZ vnGr.ootSmvtHv_R5ULJj8FqsmfpM9dND.piFuvfMRo7SAXFKc.ixlEcWN8uCMgp2T5WWw555aNp E583Ue2SARoDnm4FkVEuu8xkOYrfvQTnVkRqgHPAwEfOcsKRWNiHN3WM7xaAjoHKO9U4Xti8S03Z jTWQUlZgq3y2TMX9.mar9D_CuTO4QnRrmZRJ9Abm9Tl5ckp3BSBHB1Ux7lup7M2uR_Ee7zKhnvMG HMWOFKsq48lpxqPk- Received: from sonic.gate.mail.ne1.yahoo.com by sonic311.consmr.mail.gq1.yahoo.com with HTTP; Wed, 13 Nov 2019 06:01:56 +0000 Received: by smtp417.mail.ir2.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 419ee3d756c724f02396d02693011f1a; Wed, 13 Nov 2019 06:01:53 +0000 (UTC) To: Li Guifu , Chao Yu , linux-erofs@lists.ozlabs.org Subject: [PATCH v4] erofs-utils: support 128-bit filesystem UUID Date: Wed, 13 Nov 2019 14:01:41 +0800 Message-Id: <20191113060141.9502-1-hsiangkao@aol.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191113035221.30265-1-hsiangkao@aol.com> References: <20191113035221.30265-1-hsiangkao@aol.com> X-BeenThere: linux-erofs@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Linux EROFS file system List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Gao Xiang via Linux-erofs Reply-To: Gao Xiang Cc: Miao Xie Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" Complete filesystem UUID feature on userspace side. Cc: Chao Yu Cc: Li Guifu Signed-off-by: Gao Xiang --- changes since v3: - fix configure.ac script and fully passed travis CI https://travis-ci.org/erofs/erofs-utils-ci/builds/611213382 configure.ac | 41 ++++++++++++++++++++++++++++++++++++++++ include/erofs/internal.h | 1 + mkfs/Makefile.am | 3 ++- mkfs/main.c | 20 ++++++++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index a93767f..c7dbe0e 100644 --- a/configure.ac +++ b/configure.ac @@ -20,6 +20,15 @@ AC_PROG_INSTALL LT_INIT +# Test presence of pkg-config +AC_MSG_CHECKING([pkg-config m4 macros]) +if test m4_ifdef([PKG_CHECK_MODULES], [yes], [no]) = "yes"; then + AC_MSG_RESULT([yes]); +else + AC_MSG_RESULT([no]); + AC_MSG_ERROR([pkg-config is required. See pkg-config.freedesktop.org]) +fi + dnl EROFS_UTILS_PARSE_DIRECTORY dnl Input: $1 = a string to a relative or absolute directory dnl Output: $2 = the variable to set with the absolute directory @@ -54,6 +63,10 @@ AC_ARG_ENABLE(lz4, [AS_HELP_STRING([--disable-lz4], [disable LZ4 compression support @<:@default=enabled@:>@])], [enable_lz4="$enableval"], [enable_lz4="yes"]) +AC_ARG_WITH(uuid, + [AS_HELP_STRING([--without-uuid], + [Ignore presence of libuuid and disable uuid support @<:@default=enabled@:>@])]) + # Checks for libraries. # Use customized LZ4 library path when specified. AC_ARG_WITH(lz4-incdir, @@ -123,6 +136,30 @@ AC_CHECK_DECL(lseek64,[AC_DEFINE(HAVE_LSEEK64_PROTOTYPE, 1, # Checks for library functions. AC_CHECK_FUNCS([fallocate gettimeofday memset realpath strdup strerror strrchr strtoull]) +# Configure libuuid +AS_IF([test "x$with_uuid" != "xno"], [ + PKG_CHECK_MODULES([libuuid], [uuid]) + # Paranoia: don't trust the result reported by pkgconfig before trying out + saved_LIBS="$LIBS" + saved_CPPFLAGS=${CPPFLAGS} + CPPFLAGS="${libuuid_CFLAGS} ${CPPFLAGS}" + LIBS="${libuuid_LIBS} $LIBS" + AC_MSG_CHECKING([libuuid usability]) + AC_TRY_LINK([ +#include +], [ +uuid_t tmp; + +uuid_generate(tmp); +return 0; +], [have_uuid="yes" + AC_MSG_RESULT([yes])], [ + have_uuid="no" + AC_MSG_RESULT([no]) + AC_MSG_ERROR([libuuid doesn't work properly])]) + LIBS="${saved_LIBS}" + CPPFLAGS="${saved_CPPFLAGS}"], [have_uuid="no"]) + # Configure lz4 test -z $LZ4_LIBS && LZ4_LIBS='-llz4' @@ -169,6 +206,10 @@ if test "x$enable_lz4" = "xyes"; then CFLAGS=${saved_CPPFLAGS} fi +if test "x$have_uuid" = "xyes"; then + AC_DEFINE([HAVE_LIBUUID], 1, [Define to 1 if libuuid is found]) +fi + AM_CONDITIONAL([ENABLE_LZ4], [test "x${have_lz4}" = "xyes"]) AM_CONDITIONAL([ENABLE_LZ4HC], [test "x${have_lz4hc}" = "xyes"]) diff --git a/include/erofs/internal.h b/include/erofs/internal.h index 9e2bb9c..e13adda 100644 --- a/include/erofs/internal.h +++ b/include/erofs/internal.h @@ -56,6 +56,7 @@ struct erofs_sb_info { u32 feature_incompat; u64 build_time; u32 build_time_nsec; + u8 uuid[16]; }; /* global sbi */ diff --git a/mkfs/Makefile.am b/mkfs/Makefile.am index 257f864..9ce06d6 100644 --- a/mkfs/Makefile.am +++ b/mkfs/Makefile.am @@ -3,7 +3,8 @@ AUTOMAKE_OPTIONS = foreign bin_PROGRAMS = mkfs.erofs +AM_CPPFLAGS = ${libuuid_CFLAGS} mkfs_erofs_SOURCES = main.c mkfs_erofs_CFLAGS = -Wall -Werror -I$(top_srcdir)/include -mkfs_erofs_LDADD = $(top_builddir)/lib/liberofs.la +mkfs_erofs_LDADD = $(top_builddir)/lib/liberofs.la ${libuuid_LIBS} diff --git a/mkfs/main.c b/mkfs/main.c index 9187c43..7493a48 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -22,6 +22,10 @@ #include "erofs/compress.h" #include "erofs/xattr.h" +#ifdef HAVE_LIBUUID +#include +#endif + #define EROFS_SUPER_END (EROFS_SUPER_OFFSET + sizeof(struct erofs_super_block)) static struct option long_options[] = { @@ -234,6 +238,7 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh, *blocks = erofs_mapbh(NULL, true); sb.blocks = cpu_to_le32(*blocks); sb.root_nid = cpu_to_le16(root_nid); + memcpy(sb.uuid, sbi.uuid, sizeof(sb.uuid)); buf = calloc(sb_blksize, 1); if (!buf) { @@ -305,6 +310,20 @@ static int erofs_mkfs_superblock_csum_set(void) return 0; } +static void erofs_mkfs_generate_uuid(void) +{ + char uuid_str[37] = "not available"; + +#ifdef HAVE_LIBUUID + do { + uuid_generate(sbi.uuid); + } while (uuid_is_null(sbi.uuid)); + + uuid_unparse_lower(sbi.uuid, uuid_str); +#endif + erofs_info("filesystem UUID: %s", uuid_str); +} + int main(int argc, char **argv) { int err = 0; @@ -376,6 +395,7 @@ int main(int argc, char **argv) goto exit; } + erofs_mkfs_generate_uuid(); erofs_inode_manager_init(); err = erofs_build_shared_xattrs_from_path(cfg.c_src_path); -- 2.17.1