Btrfs-progs: move ask_user() to utils.c

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
master
Wang Shilong 2013-09-18 16:27:35 +08:00 committed by Chris Mason
parent 77801d34d0
commit 39813fb7ac
3 changed files with 19 additions and 18 deletions

View File

@ -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)

18
utils.c
View File

@ -1957,3 +1957,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"));
}

View File

@ -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