Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 559CFC27C53 for ; Wed, 12 Jun 2024 16:19:17 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=kqeeavzV; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4VzrMl1jvrz3dTb for ; Thu, 13 Jun 2024 02:19:15 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=kqeeavzV; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.alibaba.com (client-ip=115.124.30.133; helo=out30-133.freemail.mail.aliyun.com; envelope-from=hsiangkao@linux.alibaba.com; receiver=lists.ozlabs.org) Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4VzrM65kcXz3dK1 for ; Thu, 13 Jun 2024 02:18:41 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1718209115; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=P2GiRpaIhCkFId5QR4OigI0Ro6bAqWQfKy2kN7ULgHc=; b=kqeeavzV09P07/XNXSFNaXMMoZk2VOU51H2UqKDQyZtMvjq45EiOXUIqY0IVo/NC742OwJA1ekBpsbRYSI/eTz7q34UCCcxfvfmgLH0J10HVPqMmwFO0Fk7F2RjSneY8tYbo0tThMV0b/ZCz1QYl8chWaCv9t+ybrJp66sGYKiA= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R601e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067109;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=2;SR=0;TI=SMTPD_---0W8LOtT6_1718209112; Received: from x31i01179.sqa.na131.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0W8LOtT6_1718209112) by smtp.aliyun-inc.com; Thu, 13 Jun 2024 00:18:34 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Subject: [PATCH 2/5] erofs-utils: lib: use filesystem UUID if the device name is not specified Date: Thu, 13 Jun 2024 00:18:23 +0800 Message-Id: <20240612161826.711279-2-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240612161826.711279-1-hsiangkao@linux.alibaba.com> References: <20240612161826.711279-1-hsiangkao@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , Cc: Gao Xiang Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" The device name is not always valid. Signed-off-by: Gao Xiang --- lib/rebuild.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/rebuild.c b/lib/rebuild.c index 618067a..c25d222 100644 --- a/lib/rebuild.c +++ b/lib/rebuild.c @@ -15,6 +15,7 @@ #include "erofs/xattr.h" #include "erofs/blobchunk.h" #include "erofs/internal.h" +#include "liberofs_uuid.h" #ifdef HAVE_LINUX_AUFS_TYPE_H #include @@ -375,16 +376,17 @@ int erofs_rebuild_load_tree(struct erofs_inode *root, struct erofs_sb_info *sbi) { struct erofs_inode inode = {}; struct erofs_rebuild_dir_context ctx; + char uuid_str[37]; + char *fsid = sbi->devname; int ret; - if (!sbi->devname) { - erofs_err("failed to find a device for rebuilding"); - return -EINVAL; + if (!fsid) { + erofs_uuid_unparse_lower(sbi->uuid, uuid_str); + fsid = uuid_str; } - ret = erofs_read_superblock(sbi); if (ret) { - erofs_err("failed to read superblock of %s", sbi->devname); + erofs_err("failed to read superblock of %s", fsid); return ret; } @@ -392,7 +394,7 @@ int erofs_rebuild_load_tree(struct erofs_inode *root, struct erofs_sb_info *sbi) inode.sbi = sbi; ret = erofs_read_inode_from_disk(&inode); if (ret) { - erofs_err("failed to read root inode of %s", sbi->devname); + erofs_err("failed to read root inode of %s", fsid); return ret; } inode.i_srcpath = strdup("/"); -- 2.39.3