From mboxrd@z Thu Jan 1 00:00:00 1970 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=-20.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_SANE_1 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 92845C433E0 for ; Thu, 31 Dec 2020 16:31:49 +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 CAD21223E0 for ; Thu, 31 Dec 2020 16:31:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CAD21223E0 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 bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4D6DFH0WYRzDqL5 for ; Fri, 1 Jan 2021 03:31:47 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.ozlabs.org; s=201707; t=1609432307; bh=xXIgT9asUyjh0PUJO4W4AXek2QizkTh37MWXohnlvx0=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=LTXBfx5AHHnzKYLAsM6oouz1fpX1BiRSLVI5M4F9mbdUphjLbGN0ipnBZAdDPERyq biduLdIwi0MzKvv0MDVjCFMFnk5cJtHiWLjRJnjQinmqjFMeTwatYzQsGibMrcxp/P fl3SUVfAv82+bTIVOcEc7l60XRxGwZtOsOR5lkCK11sNKstBYaw59LpkS6no9aHaWL i6qc2SmWFX6mDjzGwE4BdoE3u2Z4xUnUOy6tRDQ0OsKXsLO8kEMyPPzKNtVUO0OJ/V Ms+t0GzKnDxH0RzfJOCc2THLhIBu01egq9T9TCaR0YelVcIgrJZxiUdN9rRYA/3vAo IAs0ifyL5B38g== Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aliyun.com (client-ip=115.124.30.39; helo=out30-39.freemail.mail.aliyun.com; envelope-from=bluce.lee@aliyun.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aliyun.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=aliyun.com header.i=@aliyun.com header.a=rsa-sha256 header.s=s1024 header.b=d/2EIhUr; dkim-atps=neutral Received: from out30-39.freemail.mail.aliyun.com (out30-39.freemail.mail.aliyun.com [115.124.30.39]) (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 4D6DF52ZybzDqK3 for ; Fri, 1 Jan 2021 03:31:35 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aliyun.com; s=s1024; t=1609432284; h=Subject:To:From:Message-ID:Date:MIME-Version:Content-Type; bh=6WTgHt6mSB3yeN7e4hPr/1nBM4SGqjk7dZc3wPxGbWM=; b=d/2EIhUr0ry2G+RSfC/rz8zHS3eNgJOTEvTRd59D1RobTNzsyp1SALh5jxnJTtjwYwTYJp7ApTYM0HWe26/sRdZO7mrLI3dg3EaB6RHzOBcI1TjKdt8++6xT6njXPENUIvn9FOEL6Bv3VbqS/n0rlDdGK65ESjAP478ilWKkR4c= X-Alimail-AntiSpam: AC=CONTINUE; BC=0.07389534|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_system_inform|0.0681609-0.000559044-0.93128; FP=0|0|0|0|0|-1|-1|-1; HT=e01e04394; MF=bluce.lee@aliyun.com; NM=1; PH=DS; RN=6; RT=6; SR=0; TI=SMTPD_---0UKKd4u-_1609432282; Received: from 192.168.3.32(mailfrom:bluce.lee@aliyun.com fp:SMTPD_---0UKKd4u-_1609432282) by smtp.aliyun-inc.com(127.0.0.1); Fri, 01 Jan 2021 00:31:22 +0800 Subject: Re: [PATCH v2] AOSP: erofs-utils: fix sub-directory prefix for canned fs_config To: Gao Xiang , linux-erofs@lists.ozlabs.org, Yue Hu , Huang Jianan References: <20201226062736.29920-1-hsiangkao@aol.com> <20201228105146.2939914-1-hsiangkao@redhat.com> Message-ID: Date: Fri, 1 Jan 2021 00:31:22 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <20201228105146.2939914-1-hsiangkao@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Li GuiFu via Linux-erofs Reply-To: Li GuiFu Cc: Yue Hu Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" Thank for your works, Yue Hu, Jianan, Gao Xiang On 2020/12/28 18:51, Gao Xiang wrote: > From: Gao Xiang > > "failed to find [%s] in canned fs_config" was observed by using > "--fs-config-file" option as reported by Yue Hu [1]. > > The root cause was that the mountpoint prefix to subdirectories is > also needed if "--mount-point" presents. However, such prefix cannot > be added by just using erofs_fspath(). > > One exception is that the root directory itself needs to be handled > specially for canned fs_config. For such case, the prefix of the root > directory has to be dropped instead. > > [1] https://lkml.kernel.org/r/20201222020430.12512-1-zbestahu@gmail.com > > Link: https://lore.kernel.org/r/20201226062736.29920-1-hsiangkao@aol.com > Fixes: 8a9e8046f170 ("AOSP: erofs-utils: add fs_config support") > Reported-by: Yue Hu > Signed-off-by: Gao Xiang > --- > changes since v2: > - fix IS_ROOT misuse reported by Jianan, very sorry about this since > I know little about canned fs_config. > > (please kindly test again...) > > lib/inode.c | 39 +++++++++++++++++++++++++-------------- > 1 file changed, 25 insertions(+), 14 deletions(-) > > diff --git a/lib/inode.c b/lib/inode.c > index 0c4839d..e6159c9 100644 > --- a/lib/inode.c > +++ b/lib/inode.c > @@ -696,32 +696,43 @@ int erofs_droid_inode_fsconfig(struct erofs_inode *inode, > /* 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 && !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; > + } > + erofs_fspath has been written for three times, and called always. What do you think refact it ? Do it with fspath = erofs_fspath(path); if need decorated: fspath = decorated