Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports
Path: blob/main/filesystems/e2fsprogs-core/files/patch-e2fsck__unix.c
18159 views
1
// SIGINFO is a Berkeley extension, so we need to
2
// remove the #define _XOPEN_SOURCE 600
3
// It would hide all non-POSIX declarations, including SIGINFO.
4
5
--- e2fsck/unix.c.orig 2024-05-21 02:52:47 UTC
6
+++ e2fsck/unix.c
7
@@ -9,8 +9,6 @@
8
* %End-Header%
9
*/
10
11
-#define _XOPEN_SOURCE 600 /* for inclusion of sa_handler in Solaris */
12
-
13
#include "config.h"
14
#include <stdio.h>
15
#ifdef HAVE_STDLIB_H
16
@@ -37,7 +35,7 @@ extern int optind;
17
#include <sys/ioctl.h>
18
#endif
19
#ifdef HAVE_MALLOC_H
20
-#include <malloc.h>
21
+#include <stdlib.h>
22
#endif
23
#ifdef HAVE_SYS_TYPES_H
24
#include <sys/types.h>
25
@@ -608,6 +606,24 @@ static int e2fsck_update_progress(e2fsck_t ctx, int pa
26
return 0;
27
}
28
29
+static int e2fsck_progress_once(e2fsck_t ctx, int pass, unsigned long cur, unsigned long max)
30
+{
31
+ char buf[80];
32
+ float percent;
33
+
34
+ if (pass == 0)
35
+ return 0;
36
+
37
+ percent = calc_percent(&e2fsck_tbl, pass, cur, max);
38
+ e2fsck_simple_progress(ctx, ctx->device_name,
39
+ percent, 0);
40
+
41
+ printf("\n");
42
+ ctx->progress = 0;
43
+ return 0;
44
+}
45
+
46
+
47
#define PATH_SET "PATH=/sbin"
48
49
/*
50
@@ -641,6 +657,17 @@ static void signal_progress_on(int sig EXT2FS_ATTR((un
51
ctx->progress = e2fsck_update_progress;
52
}
53
54
+static void signal_progress_now(int sig EXT2FS_ATTR((unused)))
55
+{
56
+ e2fsck_t ctx = e2fsck_global_ctx;
57
+
58
+ if (!ctx)
59
+ return;
60
+
61
+ ctx->progress = e2fsck_progress_once;
62
+ ctx->progress_fd = 0;
63
+}
64
+
65
static void signal_progress_off(int sig EXT2FS_ATTR((unused)))
66
{
67
e2fsck_t ctx = e2fsck_global_ctx;
68
@@ -1127,6 +1154,10 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t
69
sigaction(SIGUSR1, &sa, 0);
70
sa.sa_handler = signal_progress_off;
71
sigaction(SIGUSR2, &sa, 0);
72
+ sa.sa_handler = signal_progress_now;
73
+ if (!getenv("e2fsprogs_inhibit_SIGINFO")) {
74
+ sigaction(SIGINFO, &sa, 0);
75
+ }
76
#endif
77
78
/* Update our PATH to include /sbin if we need to run badblocks */
79
80