From f9f0109d4f1497ae49577540aa153878a9a42b06 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 13 Jun 2024 00:18:23 +0800 Subject: [PATCH] erofs-utils: lib: use filesystem UUID if the device name is not specified The device name is not always valid. Signed-off-by: Gao Xiang Link: https://lore.kernel.org/r/20240612161826.711279-2-hsiangkao@linux.alibaba.com --- 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.34.1