linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 3/4] Btrfs-progs: move ask_user() to utils.c
Date: Wed, 18 Sep 2013 16:27:35 +0800	[thread overview]
Message-ID: <1379492856-30639-4-git-send-email-wangsl.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <1379492856-30639-1-git-send-email-wangsl.fnst@cn.fujitsu.com>

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
---
 chunk-recover.c | 18 ------------------
 utils.c         | 18 ++++++++++++++++++
 utils.h         |  1 +
 3 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/chunk-recover.c b/chunk-recover.c
index 9af4887..e44ca72 100644
--- a/chunk-recover.c
+++ b/chunk-recover.c
@@ -1307,24 +1307,6 @@ fail_close_fd:
 	return ret;
 }
 
-/*
- * This reads a line from the stdin and only returns non-zero if the
- * first whitespace delimited token is a case insensitive match with yes
- * or y.
- */
-static int ask_user(char *question)
-{
-	char buf[30] = {0,};
-	char *saveptr = NULL;
-	char *answer;
-
-	printf("%s [y/N]: ", question);
-
-	return fgets(buf, sizeof(buf) - 1, stdin) &&
-	       (answer = strtok_r(buf, " \t\n\r", &saveptr)) &&
-	       (!strcasecmp(answer, "yes") || !strcasecmp(answer, "y"));
-}
-
 static int btrfs_get_device_extents(u64 chunk_object,
 				    struct list_head *orphan_devexts,
 				    struct list_head *ret_list)
diff --git a/utils.c b/utils.c
index e3738d3..2bfd59a 100644
--- a/utils.c
+++ b/utils.c
@@ -1955,3 +1955,21 @@ int is_vol_small(char *file)
 		return 0;
 	}
 }
+
+/*
+ * This reads a line from the stdin and only returns non-zero if the
+ * first whitespace delimited token is a case insensitive match with yes
+ * or y.
+ */
+int ask_user(char *question)
+{
+	char buf[30] = {0,};
+	char *saveptr = NULL;
+	char *answer;
+
+	printf("%s [y/N]: ", question);
+
+	return fgets(buf, sizeof(buf) - 1, stdin) &&
+	       (answer = strtok_r(buf, " \t\n\r", &saveptr)) &&
+	       (!strcasecmp(answer, "yes") || !strcasecmp(answer, "y"));
+}
diff --git a/utils.h b/utils.h
index 6c2553a..2cb9d9b 100644
--- a/utils.h
+++ b/utils.h
@@ -80,4 +80,5 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
 int is_vol_small(char *file);
 int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
 			   int verify);
+int ask_user(char *question);
 #endif
-- 
1.8.3.1


  parent reply	other threads:[~2013-09-18  8:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-18  8:27 [PATCH 0/4] add super-recover tool to recover bad supers Wang Shilong
2013-09-18  8:27 ` [PATCH 1/4] Btrfs-progs: do not run ioctls in check_mounted_where() Wang Shilong
2013-09-18  8:27 ` [PATCH 2/4] Btrfs-progs: pass flag to control whether run ioctl in btrfs_scan_for_fsid() Wang Shilong
2013-09-18  8:27 ` Wang Shilong [this message]
2013-09-18  8:27 ` [PATCH 4/4] Btrfs-progs: add super-recover to recover bad supers Wang Shilong
2013-09-18 15:13   ` David Sterba
2013-09-18 15:31     ` Wang Shilong
2013-09-18 16:31       ` David Sterba
2013-09-21  1:16         ` Wang Shilong
2013-09-23 12:10           ` [offlist] " David Sterba
2013-09-18 15:18 ` [PATCH 0/4] add super-recover tool " David Sterba

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=1379492856-30639-4-git-send-email-wangsl.fnst@cn.fujitsu.com \
    --to=wangsl.fnst@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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).