mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-24 23:22:27 +00:00
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>
This commit is contained in:
parent
77801d34d0
commit
39813fb7ac
@ -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
18
utils.c
@ -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"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user