- p = percent(pass, cur, max);
- fprintf(console, "\r%s: fsck %3.1f%% complete...\r%n", device, p, &m);
- fflush(console);
-
- if (m > clear)
- clear = m;
- }
-
- if (clear > 0) {
- unsigned j;
-
- fputc('\r', console);
- for (j = 0; j < (unsigned) clear; j++)
- fputc(' ', console);
- fputc('\r', console);
- fflush(console);
+ /* send progress to fsckd */
+ progress.devnum = device_num;
+ progress.cur = cur;
+ progress.max = max;
+ progress.pass = pass;
+
+ r = send(fsckd_fd, &progress, sizeof(FsckProgress), 0);
+ if (r < 0 || (size_t) r < sizeof(FsckProgress))
+ log_warning_errno(errno, "Cannot communicate fsck progress to fsckd: %m");
+
+ /* get fsckd requests, only read when we have coherent size data */
+ r = ioctl(fsckd_fd, FIONREAD, &buflen);
+ if (r == 0 && (size_t) buflen >= sizeof(FsckdMessage)) {
+ r = recv(fsckd_fd, &fsckd_message, sizeof(FsckdMessage), 0);
+ if (r > 0 && fsckd_message.cancel == 1) {
+ log_info("Request to cancel fsck from fsckd");
+ kill(fsck_pid, SIGTERM);
+ }
+ }