ports/filesystems/e2fsprogs-core/files/patch-e2fsck__unix.c
Robert Clausecker 6e2da9672f filesystems: add new category for file systems and related utilities
The filesystems category houses file systems and file system utilities.
It is added mainly to turn the sysutils/fusefs-* pseudo-category into
a proper one, but is also useful for the sundry of other file systems
related ports found in the tree.

Ports that seem like they belong there are moved to the new category.
Two ports, sysutils/fusefs-funionfs and sysutils/fusefs-fusepak are
not moved as they currently don't fetch and don't have TIMESTAMP set
in their distinfo, but that is required to be able to push a rename
of the port by the pre-receive hook.

Approved by:	portmgr (rene)
Reviewed by:	mat
Pull Request:	https://github.com/freebsd/freebsd-ports/pull/302
PR:		281988
2024-11-06 16:17:35 +01:00

78 lines
1.8 KiB
C

// SIGINFO is a Berkeley extension, so we need to
// remove the #define _XOPEN_SOURCE 600
// It would hide all non-POSIX declarations, including SIGINFO.
--- e2fsck/unix.c.orig 2024-05-21 02:52:47 UTC
+++ e2fsck/unix.c
@@ -9,8 +9,6 @@
* %End-Header%
*/
-#define _XOPEN_SOURCE 600 /* for inclusion of sa_handler in Solaris */
-
#include "config.h"
#include <stdio.h>
#ifdef HAVE_STDLIB_H
@@ -37,7 +35,7 @@ extern int optind;
#include <sys/ioctl.h>
#endif
#ifdef HAVE_MALLOC_H
-#include <malloc.h>
+#include <stdlib.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -608,6 +606,24 @@ static int e2fsck_update_progress(e2fsck_t ctx, int pa
return 0;
}
+static int e2fsck_progress_once(e2fsck_t ctx, int pass, unsigned long cur, unsigned long max)
+{
+ char buf[80];
+ float percent;
+
+ if (pass == 0)
+ return 0;
+
+ percent = calc_percent(&e2fsck_tbl, pass, cur, max);
+ e2fsck_simple_progress(ctx, ctx->device_name,
+ percent, 0);
+
+ printf("\n");
+ ctx->progress = 0;
+ return 0;
+}
+
+
#define PATH_SET "PATH=/sbin"
/*
@@ -641,6 +657,17 @@ static void signal_progress_on(int sig EXT2FS_ATTR((un
ctx->progress = e2fsck_update_progress;
}
+static void signal_progress_now(int sig EXT2FS_ATTR((unused)))
+{
+ e2fsck_t ctx = e2fsck_global_ctx;
+
+ if (!ctx)
+ return;
+
+ ctx->progress = e2fsck_progress_once;
+ ctx->progress_fd = 0;
+}
+
static void signal_progress_off(int sig EXT2FS_ATTR((unused)))
{
e2fsck_t ctx = e2fsck_global_ctx;
@@ -1127,6 +1154,10 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t
sigaction(SIGUSR1, &sa, 0);
sa.sa_handler = signal_progress_off;
sigaction(SIGUSR2, &sa, 0);
+ sa.sa_handler = signal_progress_now;
+ if (!getenv("e2fsprogs_inhibit_SIGINFO")) {
+ sigaction(SIGINFO, &sa, 0);
+ }
#endif
/* Update our PATH to include /sbin if we need to run badblocks */