linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
To: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Cc: David Sterba <dsterba@suse.cz>,
	Mike Fleetwood <mike.fleetwood@googlemail.com>
Subject: [PATCH 2/2] btrfs-progs: move test_isdir() to utils.c
Date: Fri, 1 Aug 2014 11:58:00 +0900	[thread overview]
Message-ID: <53DB0238.90103@jp.fujitsu.com> (raw)
In-Reply-To: <53DAFF05.9000205@jp.fujitsu.com>

From: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>

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 <takeuchi_satoru@jp.fujitsu.com>
Cc: David Sterba <dsterba@suse.cz>
Cc: Mike Fleetwood <mike.fleetwood@googlemail.com>

---
 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 <qgroupid>] [<dest>/]<name>",
 	"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:
-- 
1.9.3


      reply	other threads:[~2014-08-01  2:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-01  2:44 [PATCH 1/2 v3] btrfs-progs: introduce test_issubvolname() for simplicity Satoru Takeuchi
2014-08-01  2:58 ` Satoru Takeuchi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53DB0238.90103@jp.fujitsu.com \
    --to=takeuchi_satoru@jp.fujitsu.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=mike.fleetwood@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).