Path: blob/main/filesystems/e2fsprogs-core/files/patch-e2fsck__unix.c
18159 views
// SIGINFO is a Berkeley extension, so we need to1// remove the #define _XOPEN_SOURCE 6002// It would hide all non-POSIX declarations, including SIGINFO.34--- e2fsck/unix.c.orig 2024-05-21 02:52:47 UTC5+++ e2fsck/unix.c6@@ -9,8 +9,6 @@7* %End-Header%8*/910-#define _XOPEN_SOURCE 600 /* for inclusion of sa_handler in Solaris */11-12#include "config.h"13#include <stdio.h>14#ifdef HAVE_STDLIB_H15@@ -37,7 +35,7 @@ extern int optind;16#include <sys/ioctl.h>17#endif18#ifdef HAVE_MALLOC_H19-#include <malloc.h>20+#include <stdlib.h>21#endif22#ifdef HAVE_SYS_TYPES_H23#include <sys/types.h>24@@ -608,6 +606,24 @@ static int e2fsck_update_progress(e2fsck_t ctx, int pa25return 0;26}2728+static int e2fsck_progress_once(e2fsck_t ctx, int pass, unsigned long cur, unsigned long max)29+{30+ char buf[80];31+ float percent;32+33+ if (pass == 0)34+ return 0;35+36+ percent = calc_percent(&e2fsck_tbl, pass, cur, max);37+ e2fsck_simple_progress(ctx, ctx->device_name,38+ percent, 0);39+40+ printf("\n");41+ ctx->progress = 0;42+ return 0;43+}44+45+46#define PATH_SET "PATH=/sbin"4748/*49@@ -641,6 +657,17 @@ static void signal_progress_on(int sig EXT2FS_ATTR((un50ctx->progress = e2fsck_update_progress;51}5253+static void signal_progress_now(int sig EXT2FS_ATTR((unused)))54+{55+ e2fsck_t ctx = e2fsck_global_ctx;56+57+ if (!ctx)58+ return;59+60+ ctx->progress = e2fsck_progress_once;61+ ctx->progress_fd = 0;62+}63+64static void signal_progress_off(int sig EXT2FS_ATTR((unused)))65{66e2fsck_t ctx = e2fsck_global_ctx;67@@ -1127,6 +1154,10 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t68sigaction(SIGUSR1, &sa, 0);69sa.sa_handler = signal_progress_off;70sigaction(SIGUSR2, &sa, 0);71+ sa.sa_handler = signal_progress_now;72+ if (!getenv("e2fsprogs_inhibit_SIGINFO")) {73+ sigaction(SIGINFO, &sa, 0);74+ }75#endif7677/* Update our PATH to include /sbin if we need to run badblocks */787980