From patchwork Fri Aug 1 02:58:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Satoru Takeuchi X-Patchwork-Id: 4660181 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8A0979F32F for ; Fri, 1 Aug 2014 02:58:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 96D17201B9 for ; Fri, 1 Aug 2014 02:58:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A06C42018A for ; Fri, 1 Aug 2014 02:58:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752102AbaHAC62 (ORCPT ); Thu, 31 Jul 2014 22:58:28 -0400 Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:50861 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751663AbaHAC62 (ORCPT ); Thu, 31 Jul 2014 22:58:28 -0400 Received: from kw-mxq.gw.nic.fujitsu.com (unknown [10.0.237.131]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id 949DF3EE1E0 for ; Fri, 1 Aug 2014 11:58:26 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (s2.gw.fujitsu.co.jp [10.0.50.92]) by kw-mxq.gw.nic.fujitsu.com (Postfix) with ESMTP id 970B9AC0879 for ; Fri, 1 Aug 2014 11:58:25 +0900 (JST) Received: from g01jpfmpwyt03.exch.g01.fujitsu.local (g01jpfmpwyt03.exch.g01.fujitsu.local [10.128.193.57]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 2C0091DB803C for ; Fri, 1 Aug 2014 11:58:25 +0900 (JST) Received: from g01jpexchyt36.g01.fujitsu.local (unknown [10.128.193.4]) by g01jpfmpwyt03.exch.g01.fujitsu.local (Postfix) with ESMTP id 1D30E46E488; Fri, 1 Aug 2014 11:58:24 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v2.0.1 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20120718-4 Message-ID: <53DB0238.90103@jp.fujitsu.com> Date: Fri, 1 Aug 2014 11:58:00 +0900 From: Satoru Takeuchi User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: "linux-btrfs@vger.kernel.org" CC: David Sterba , Mike Fleetwood Subject: [PATCH 2/2] btrfs-progs: move test_isdir() to utils.c References: <53DAFF05.9000205@jp.fujitsu.com> In-Reply-To: <53DAFF05.9000205@jp.fujitsu.com> X-SecurityPolicyCheck-GC: OK by FENCE-Mail Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Satoru Takeuchi Since test_isdir() is a utility function, it's better to move it to utils.c. In addition, "const char *" is more appropriate type as its "path" argument because this argument is not changed in this function. Signed-off-by: Satoru Takeuchi Cc: David Sterba Cc: Mike Fleetwood --- cmds-subvolume.c | 19 ------------------- utils.c | 19 +++++++++++++++++++ utils.h | 1 + 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/cmds-subvolume.c b/cmds-subvolume.c index c075fb2..e420bba 100644 --- a/cmds-subvolume.c +++ b/cmds-subvolume.c @@ -42,25 +42,6 @@ static const char * const subvolume_cmd_group_usage[] = { NULL }; -/* - * test if path is a directory - * this function return - * 0-> path exists but it is not a directory - * 1-> path exists and it is a directory - * -1 -> path is unaccessible - */ -static int test_isdir(char *path) -{ - struct stat st; - int res; - - res = stat(path, &st); - if(res < 0 ) - return -1; - - return S_ISDIR(st.st_mode); -} - static const char * const cmd_subvol_create_usage[] = { "btrfs subvolume create [-i ] [/]", "Create a subvolume", diff --git a/utils.c b/utils.c index d98aac8..059ed34 100644 --- a/utils.c +++ b/utils.c @@ -2697,3 +2697,22 @@ int test_issubvolname(const char *name) return name[0] != '\0' && !strchr(name, '/') && strcmp(name, ".") && strcmp(name, ".."); } + +/* + * test if path is a directory + * this function return + * 0-> path exists but it is not a directory + * 1-> path exists and it is a directory + * -1 -> path is unaccessible + */ +int test_isdir(const char *path) +{ + struct stat st; + int res; + + res = stat(path, &st); + if(res < 0 ) + return -1; + + return S_ISDIR(st.st_mode); +} diff --git a/utils.h b/utils.h index dad7d41..90fc1fe 100644 --- a/utils.h +++ b/utils.h @@ -134,6 +134,7 @@ int fsid_to_mntpt(__u8 *fsid, char *mntpt, int *mnt_cnt); int test_minimum_size(const char *file, u32 leafsize); int test_issubvolname(const char *name); +int test_isdir(const char *path); /* * Btrfs minimum size calculation is complicated, it should include at least: