1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _BCACHEFS_THREAD_WITH_FILE_H 3 #define _BCACHEFS_THREAD_WITH_FILE_H 4 5 #include "thread_with_file_types.h" 6 7 struct task_struct; 8 9 struct thread_with_file { 10 struct task_struct *task; 11 int ret; 12 bool done; 13 }; 14 15 void bch2_thread_with_file_exit(struct thread_with_file *); 16 int bch2_run_thread_with_file(struct thread_with_file *, 17 const struct file_operations *, 18 int (*fn)(void *)); 19 20 struct thread_with_stdio { 21 struct thread_with_file thr; 22 struct stdio_redirect stdio; 23 DARRAY(char) output2; 24 void (*exit)(struct thread_with_stdio *); 25 }; 26 27 static inline void thread_with_stdio_done(struct thread_with_stdio *thr) 28 { 29 thr->thr.done = true; 30 thr->stdio.done = true; 31 wake_up(&thr->stdio.input_wait); 32 wake_up(&thr->stdio.output_wait); 33 } 34 35 int bch2_run_thread_with_stdio(struct thread_with_stdio *, 36 void (*exit)(struct thread_with_stdio *), 37 int (*fn)(void *)); 38 int bch2_stdio_redirect_read(struct stdio_redirect *, char *, size_t); 39 int bch2_stdio_redirect_readline(struct stdio_redirect *, char *, size_t); 40 41 #endif /* _BCACHEFS_THREAD_WITH_FILE_H */ 42