Dr. Werner Fink 2021-12-03 07:29:41 +00:00 committed by Git OBS Bridge
parent c53fe95a8d
commit 2a813f915b

View File

@ -1,32 +1,99 @@
From fcb9e0c20bc4fee9152f58a6746334f6f1bbe9b1 Mon Sep 17 00:00:00 2001 diff --git blogctl.8 blogctl.8
From: Werner Fink <werner@suse.de> index 93f29b4..cbbfc06 100644
Date: Thu, 2 Dec 2021 15:59:55 +0100 --- blogctl.8
Subject: [PATCH] On s390/x and PPC64 gcc misses unused arg0 +++ blogctl.8
@@ -53,6 +53,14 @@ This let the daemon disconnect from system console.
Signed-off-by: Werner Fink <werner@suse.de> .TP
--- .B reactivate
blogger.c | 4 ++++ Whereas this cause the daemon reconnect to system console.
1 file changed, 4 insertions(+) +.TP
+.B final
diff --git blogger.c blogger.c +Let rename the daemon an open log file
index d1e1ae2..ce2b9ee 100644 +.I /var/log/boot.log
--- blogger.c +to the new name
+++ blogger.c +.I /var/log/boot.old
@@ -17,10 +17,14 @@ +as well as mask it own program name in the process table
#include <unistd.h> +with the @ character.
#include "libblogger.h" .SH SEE ALSO
.BR blogd (8),
.BR systemd (1),
diff --git blogd.c blogd.c
index 9f322e9..0ca0f9e 100644
--- blogd.c
+++ blogd.c
@@ -221,7 +221,6 @@ static volatile pid_t pid = -1;
+volatile char *arg0; static void flush_handler (void) attribute((noinline));
+ static void exit_handler (void) attribute((noinline));
int main(int argc, char * argv[]) -volatile char *arg0;
/*
* Now do the job
@@ -230,6 +229,7 @@ int main(int argc, char *argv[])
{ {
int c, lvl = 'n'; char ptsname[NAME_MAX+1];
const char *tty, *stt;
+ volatile char *arg0;
struct console *c;
struct termios o;
struct winsize w;
@@ -248,6 +248,7 @@ int main(int argc, char *argv[])
warn("could not tell system to show its status");
+ arg0 = (volatile char*)argv[0]; arg0 = (volatile char*)argv[0];
+ remember_arg0(arg0);
while ((arg = getopt(argc, argv, "f")) != -1) {
switch (arg) {
diff --git libconsole/console.c libconsole/console.c
index b3a499b..89ae1e5 100644
--- libconsole/console.c
+++ libconsole/console.c
@@ -50,7 +50,17 @@
#endif
int final = 0;
-extern volatile char *arg0;
+static volatile char *_arg0;
+ +
while ((c = getopt(argc, argv, "ndfsu")) != -1) { +/*
switch (c) { + * Avoid trouble if linked with e.g. blogger as there
case B_NOTICE: + * is no external arg0 but linker on ppc64 and s390/x
-- + * seems to expect this.
2.26.2 + */
+void remember_arg0(volatile char *arg0)
+{
+ _arg0 = arg0;
+}
/*
* Used to ignore some signals during epoll_pwait(2) or ppoll(2)
@@ -1044,13 +1054,13 @@ static void socket_handler(int fd)
enqry = ANSWER_ACK;
safeout(fd, enqry, strlen(enqry)+1, SSIZE_MAX);
- if (!final) {
+ if (!final && _arg0) {
int ret;
final = 1;
- if (arg0[0] != '@')
- arg0[0] = '@';
+ if (_arg0[0] != '@')
+ _arg0[0] = '@';
ret = rename(BOOT_LOGFILE, BOOT_OLDLOGFILE);
if (ret < 0) {
diff --git libconsole/libconsole.h libconsole/libconsole.h
index d14fda5..7151d16 100644
--- libconsole/libconsole.h
+++ libconsole/libconsole.h
@@ -122,6 +122,7 @@ extern int evmax;
extern volatile sig_atomic_t signaled;
extern volatile sig_atomic_t nsigsys;
+extern void remember_arg0(volatile char *arg0);
extern ssize_t safein (int fd, void *ptr, size_t s);
extern void safeout (int fd, const void *ptr, size_t s, ssize_t max);