File: 020_enable-hurd.patch

package info (click to toggle)
monit 1%3A5.35.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,228 kB
  • sloc: ansic: 31,202; yacc: 4,634; sh: 4,071; lex: 1,190; pascal: 480; makefile: 285
file content (150 lines) | stat: -rw-r--r-- 4,770 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
Description: Support for GNU/Hurd
Author: Sergey B Kirpichev <skirpichev@gmail.com>
Reviewed-By: Fabio Augusto De Muzio Tobich <ftobich@debian.org>
Forwarded: https://bitbucket.org/tildeslash/monit/pull-request/3
Last-Update: 2021-08-30
Index: monit-5.35.2/configure.ac
===================================================================
--- monit-5.35.2.orig/configure.ac
+++ monit-5.35.2/configure.ac
@@ -606,6 +606,11 @@ then
    CFLAGS=`echo $CFLAGS|sed 's/-g//g'`
    CFLAGS="$CFLAGS -D_THREAD_SAFE -D_REENTRANT"
    LIBS="$LIBS -lodm -lperfstat -lm"
+elif test "$architecture" = "GNU"
+then
+   ARCH="HURD"
+   CFLAGS="$CFLAGS -D _REENTRANT"
+   LDFLAGS="$LDFLAGS -rdynamic"
 else
    AC_MSG_WARN([Architecture not supported: ${architecture}])
    CFLAGS="$CFLAGS -D _REENTRANT"
Index: monit-5.35.2/libmonit/configure.ac
===================================================================
--- monit-5.35.2.orig/libmonit/configure.ac
+++ monit-5.35.2/libmonit/configure.ac
@@ -283,6 +283,10 @@ then
    CFLAGS="$CFLAGS -D_THREAD_SAFE -D_REENTRANT"
    AC_DEFINE([AIX], 1, [Define to 1 if the system is AIX])
    LIBS="$LIBS -lcfg -lodm -lperfstat"
+elif test "$architecture" = "GNU"
+then
+   CFLAGS="$CFLAGS -D _REENTRANT"
+   AC_DEFINE([HURD], 1, [Define to 1 if the system is Hurd])
 else
    AC_MSG_ERROR([Architecture not supported: ${architecture}])
 fi
Index: monit-5.35.2/libmonit/src/Config.h
===================================================================
--- monit-5.35.2.orig/libmonit/src/Config.h
+++ monit-5.35.2/libmonit/src/Config.h
@@ -99,6 +99,12 @@
 typedef unsigned char uchar_t;
 #endif
 
+/**
+ * For systems without PATH_MAX define it with a resonable value
+ */
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
 
 #endif
 
Index: monit-5.35.2/libmonit/src/system/os/hurd/Link.inc
===================================================================
--- /dev/null
+++ monit-5.35.2/libmonit/src/system/os/hurd/Link.inc
@@ -0,0 +1 @@
+#include "../linux/Link.inc"
Index: monit-5.35.2/src/device/sysdep_HURD.c
===================================================================
--- /dev/null
+++ monit-5.35.2/src/device/sysdep_HURD.c
@@ -0,0 +1 @@
+#include "sysdep_LINUX.c"
Index: monit-5.35.2/src/monit.h
===================================================================
--- monit-5.35.2.orig/src/monit.h
+++ monit-5.35.2/src/monit.h
@@ -419,6 +419,11 @@ Sigfunc *signal(int signo, Sigfunc * fun
 #define SIG_ERR ((Sigfunc *)-1)
 #endif
 
+/* For systems without PATH_MAX define it with a resonable value */
+
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
 
 /** ------------------------------------------------- General purpose macros */
 
Index: monit-5.35.2/src/process/sysdep_HURD.c
===================================================================
--- /dev/null
+++ monit-5.35.2/src/process/sysdep_HURD.c
@@ -0,0 +1,20 @@
+#include "config.h"
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+/**
+ * On GNU/Hurd procps usually launched with -c (linux-compatibility switch):
+ * http://lists.debian.org/debian-hurd/2012/10/msg00070.html
+ * so, sysconf(_SC_CLK_TCK_) is useless here right now...
+ */
+#ifndef HZ
+# ifndef HURD
+#  define HZ sysconf(_SC_CLK_TCK)
+# else
+#  define HZ 100
+# endif
+#endif
+
+#include "sysdep_LINUX.c"
Index: monit-5.35.2/src/process/sysdep_LINUX.c
===================================================================
--- monit-5.35.2.orig/src/process/sysdep_LINUX.c
+++ monit-5.35.2/src/process/sysdep_LINUX.c
@@ -179,12 +179,17 @@ static double hz = 0.;
  * @return seconds since unix epoch
  */
 static time_t _getStartTime(void) {
-        struct sysinfo info;
-        if (sysinfo(&info) < 0) {
+        char buf[STRLEN];
+        double up = 0;
+        if (! file_readProc(buf, sizeof(buf), "uptime", -1, NULL)) {
                 Log_error("system statistic error -- cannot get system uptime: %s\n", STRERROR);
                 return 0;
         }
-        return Time_now() - info.uptime;
+        if (sscanf(buf, "%lf", &up) != 1) {
+                Log_error("system statistic error -- invalid uptime\n");
+                return 0;
+        }
+        return Time_now() - (time_t)up;
 }
 
 
Index: monit-5.35.2/src/net/Link.c
===================================================================
--- monit-5.35.2.orig/src/net/Link.c
+++ monit-5.35.2/src/net/Link.c
@@ -167,6 +167,8 @@ static void _updateValue(LinkData_T *dat
 #include "os/solaris/Link.inc"
 #elif defined AIX
 #include "os/aix/Link.inc"
+#elif defined HURD
+#include "os/hurd/Link.inc"
 #endif
 
 
Index: monit-5.35.2/src/net/os/hurd/Link.inc
===================================================================
--- /dev/null
+++ monit-5.35.2/src/net/os/hurd/Link.inc
@@ -0,0 +1 @@
+#include "../linux/Link.inc"