diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-29 20:34:48 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-07-14 19:00:14 -0400 |
commit | 0c97c437e362fb825b7501bd5da801bac77981b4 (patch) | |
tree | 043eb2b235194e021568ffab24536473d197e71b /fs/bcachefs/error.c | |
parent | 36008d5d01ad155e14fd9df876d4356433613088 (diff) |
bcachefs: twf: convert bch2_stdio_redirect_readline() to darray
We now read the line from the buffer atomically, which means we have to
allow the buffer to grow past STDIO_REDIRECT_BUFSIZE if we're waiting
for a full line - this behaviour is necessary for
stdio_redirect_readline_timeout() in the next patch.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/error.c')
-rw-r--r-- | fs/bcachefs/error.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/fs/bcachefs/error.c b/fs/bcachefs/error.c index 3a9d0a03fecf..cfe791215915 100644 --- a/fs/bcachefs/error.c +++ b/fs/bcachefs/error.c @@ -109,18 +109,21 @@ static enum ask_yn bch2_fsck_ask_yn(struct bch_fs *c) if (!stdio) return YN_NO; - char buf[100]; + darray_char line = {}; int ret; do { bch2_print(c, " (y,n, or Y,N for all errors of this type) "); - int r = bch2_stdio_redirect_readline(stdio, buf, sizeof(buf) - 1); - if (r < 0) - return YN_NO; - buf[r] = '\0'; - } while ((ret = parse_yn_response(buf)) < 0); + int r = bch2_stdio_redirect_readline(stdio, &line); + if (r < 0) { + ret = YN_NO; + break; + } + darray_last(line) = '\0'; + } while ((ret = parse_yn_response(line.data)) < 0); + darray_exit(&line); return ret; } #else |