From patchwork Thu Mar 29 09:11:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gu Jinxiang X-Patchwork-Id: 10314797 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0F24F60212 for ; Thu, 29 Mar 2018 09:21:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 099A62A2D5 for ; Thu, 29 Mar 2018 09:21:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2BE72A2D7; Thu, 29 Mar 2018 09:21:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 875B72A2D5 for ; Thu, 29 Mar 2018 09:21:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751249AbeC2JVr (ORCPT ); Thu, 29 Mar 2018 05:21:47 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:1658 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750753AbeC2JVq (ORCPT ); Thu, 29 Mar 2018 05:21:46 -0400 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="38317900" Received: from bogon (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 29 Mar 2018 17:21:45 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 38A2348AE772 for ; Thu, 29 Mar 2018 17:21:43 +0800 (CST) Received: from ubuntu.g08.fujitsu.local (10.167.226.132) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 29 Mar 2018 17:21:41 +0800 From: Gu Jinxiang To: Subject: [PATCH] btrfs-progs: Do not add extra slash if given path end with it Date: Thu, 29 Mar 2018 17:11:19 +0800 Message-ID: <1522314679-762-1-git-send-email-gujx@cn.fujitsu.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.167.226.132] X-yoursite-MailScanner-ID: 38A2348AE772.A35C9 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: gujx@cn.fujitsu.com Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When use a given path end with a slash like below, the output of path will have double slash. Do not add extra slash if there is already one in the given path. $ btrfs filesystem du ./test/ output: Total Exclusive Set shared Filename 0.00B 0.00B - /home/gujx/device/tmp/test//foo Signed-off-by: Gu Jinxiang --- cmds-fi-du.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmds-fi-du.c b/cmds-fi-du.c index 8a44665c..74f57320 100644 --- a/cmds-fi-du.c +++ b/cmds-fi-du.c @@ -449,7 +449,7 @@ static int du_add_file(const char *filename, int dirfd, } pathtmp = pathp; - if (pathp == path) + if (pathp == path || *(pathp-1) == '/') ret = sprintf(pathp, "%s", filename); else ret = sprintf(pathp, "/%s", filename);