|
|
ff86aa |
From 3edbaf6559eb81243326ebe79dc53b0759809a68 Mon Sep 17 00:00:00 2001
|
|
|
ff86aa |
From: Ray Strode <rstrode@redhat.com>
|
|
|
ff86aa |
Date: Fri, 24 Mar 2017 15:31:51 -0400
|
|
|
ff86aa |
Subject: [PATCH] Revert "Recreate boot log at each boot instead of appending"
|
|
|
ff86aa |
|
|
|
ff86aa |
This reverts commit 9abbd88835a181cda1427d61d92ef5685ad8a81b.
|
|
|
ff86aa |
---
|
|
|
ff86aa |
src/libply/ply-logger.c | 2 +-
|
|
|
ff86aa |
src/libply/ply-terminal-session.c | 5 ++---
|
|
|
ff86aa |
2 files changed, 3 insertions(+), 4 deletions(-)
|
|
|
ff86aa |
|
|
|
ff86aa |
diff --git a/src/libply/ply-logger.c b/src/libply/ply-logger.c
|
|
|
ff86aa |
index 740c30e..dfd5c0a 100644
|
|
|
ff86aa |
--- a/src/libply/ply-logger.c
|
|
|
ff86aa |
+++ b/src/libply/ply-logger.c
|
|
|
ff86aa |
@@ -13,61 +13,61 @@
|
|
|
ff86aa |
* GNU General Public License for more details.
|
|
|
ff86aa |
*
|
|
|
ff86aa |
* You should have received a copy of the GNU General Public License
|
|
|
ff86aa |
* along with this program; if not, write to the Free Software
|
|
|
ff86aa |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
ff86aa |
* 02111-1307, USA.
|
|
|
ff86aa |
*
|
|
|
ff86aa |
* Written by: Ray Strode <rstrode@redhat.com>
|
|
|
ff86aa |
*/
|
|
|
ff86aa |
#include "config.h"
|
|
|
ff86aa |
#include "ply-logger.h"
|
|
|
ff86aa |
|
|
|
ff86aa |
#include <assert.h>
|
|
|
ff86aa |
#include <ctype.h>
|
|
|
ff86aa |
#include <errno.h>
|
|
|
ff86aa |
#include <fcntl.h>
|
|
|
ff86aa |
#include <stdarg.h>
|
|
|
ff86aa |
#include <stdio.h>
|
|
|
ff86aa |
#include <stdlib.h>
|
|
|
ff86aa |
#include <string.h>
|
|
|
ff86aa |
#include <sys/fcntl.h>
|
|
|
ff86aa |
#include <sys/file.h>
|
|
|
ff86aa |
#include <sys/stat.h>
|
|
|
ff86aa |
#include <sys/types.h>
|
|
|
ff86aa |
#include <unistd.h>
|
|
|
ff86aa |
|
|
|
ff86aa |
#include "ply-utils.h"
|
|
|
ff86aa |
#include "ply-list.h"
|
|
|
ff86aa |
|
|
|
ff86aa |
#ifndef PLY_LOGGER_OPEN_FLAGS
|
|
|
ff86aa |
-#define PLY_LOGGER_OPEN_FLAGS (O_WRONLY | O_TRUNC | O_CREAT | O_NOFOLLOW | O_CLOEXEC)
|
|
|
ff86aa |
+#define PLY_LOGGER_OPEN_FLAGS (O_WRONLY | O_APPEND | O_CREAT | O_NOFOLLOW | O_CLOEXEC)
|
|
|
ff86aa |
#endif
|
|
|
ff86aa |
|
|
|
ff86aa |
#ifndef PLY_LOGGER_MAX_INJECTION_SIZE
|
|
|
ff86aa |
#define PLY_LOGGER_MAX_INJECTION_SIZE 4096
|
|
|
ff86aa |
#endif
|
|
|
ff86aa |
|
|
|
ff86aa |
#ifndef PLY_LOGGER_MAX_BUFFER_CAPACITY
|
|
|
ff86aa |
#define PLY_LOGGER_MAX_BUFFER_CAPACITY (8 * 4096)
|
|
|
ff86aa |
#endif
|
|
|
ff86aa |
|
|
|
ff86aa |
typedef struct
|
|
|
ff86aa |
{
|
|
|
ff86aa |
ply_logger_filter_handler_t handler;
|
|
|
ff86aa |
void *user_data;
|
|
|
ff86aa |
} ply_logger_filter_t;
|
|
|
ff86aa |
|
|
|
ff86aa |
struct _ply_logger
|
|
|
ff86aa |
{
|
|
|
ff86aa |
int output_fd;
|
|
|
ff86aa |
char *filename;
|
|
|
ff86aa |
|
|
|
ff86aa |
char *buffer;
|
|
|
ff86aa |
size_t buffer_size;
|
|
|
ff86aa |
size_t buffer_capacity;
|
|
|
ff86aa |
|
|
|
ff86aa |
ply_logger_flush_policy_t flush_policy;
|
|
|
ff86aa |
ply_list_t *filters;
|
|
|
ff86aa |
|
|
|
ff86aa |
uint32_t is_enabled : 1;
|
|
|
ff86aa |
uint32_t tracing_is_enabled : 1;
|
|
|
ff86aa |
diff --git a/src/libply/ply-terminal-session.c b/src/libply/ply-terminal-session.c
|
|
|
ff86aa |
index 379035c..143eed6 100644
|
|
|
ff86aa |
--- a/src/libply/ply-terminal-session.c
|
|
|
ff86aa |
+++ b/src/libply/ply-terminal-session.c
|
|
|
ff86aa |
@@ -531,60 +531,59 @@ ply_terminal_session_start_logging (ply_terminal_session_t *session)
|
|
|
ff86aa |
|
|
|
ff86aa |
assert (session_fd >= 0);
|
|
|
ff86aa |
|
|
|
ff86aa |
session->fd_watch = ply_event_loop_watch_fd (session->loop,
|
|
|
ff86aa |
session_fd,
|
|
|
ff86aa |
PLY_EVENT_LOOP_FD_STATUS_HAS_DATA,
|
|
|
ff86aa |
(ply_event_handler_t)
|
|
|
ff86aa |
ply_terminal_session_on_new_data,
|
|
|
ff86aa |
(ply_event_handler_t)
|
|
|
ff86aa |
ply_terminal_session_on_hangup,
|
|
|
ff86aa |
session);
|
|
|
ff86aa |
}
|
|
|
ff86aa |
|
|
|
ff86aa |
static void
|
|
|
ff86aa |
ply_terminal_session_stop_logging (ply_terminal_session_t *session)
|
|
|
ff86aa |
{
|
|
|
ff86aa |
assert (session != NULL);
|
|
|
ff86aa |
assert (session->logger != NULL);
|
|
|
ff86aa |
|
|
|
ff86aa |
ply_trace ("stopping logging of incoming console messages");
|
|
|
ff86aa |
if (ply_logger_is_logging (session->logger))
|
|
|
ff86aa |
ply_logger_toggle_logging (session->logger);
|
|
|
ff86aa |
|
|
|
ff86aa |
if (session->loop != NULL &&
|
|
|
ff86aa |
session->fd_watch != NULL)
|
|
|
ff86aa |
ply_event_loop_stop_watching_fd (session->loop,
|
|
|
ff86aa |
session->fd_watch);
|
|
|
ff86aa |
session->fd_watch = NULL;
|
|
|
ff86aa |
}
|
|
|
ff86aa |
|
|
|
ff86aa |
-bool
|
|
|
ff86aa |
+bool
|
|
|
ff86aa |
ply_terminal_session_open_log (ply_terminal_session_t *session,
|
|
|
ff86aa |
const char *filename)
|
|
|
ff86aa |
{
|
|
|
ff86aa |
bool log_is_opened;
|
|
|
ff86aa |
|
|
|
ff86aa |
assert (session != NULL);
|
|
|
ff86aa |
assert (filename != NULL);
|
|
|
ff86aa |
assert (session->logger != NULL);
|
|
|
ff86aa |
|
|
|
ff86aa |
ply_save_errno ();
|
|
|
ff86aa |
- unlink (filename);
|
|
|
ff86aa |
log_is_opened = ply_logger_open_file (session->logger, filename, true);
|
|
|
ff86aa |
if (log_is_opened)
|
|
|
ff86aa |
ply_logger_flush (session->logger);
|
|
|
ff86aa |
ply_restore_errno ();
|
|
|
ff86aa |
|
|
|
ff86aa |
return log_is_opened;
|
|
|
ff86aa |
}
|
|
|
ff86aa |
|
|
|
ff86aa |
-void
|
|
|
ff86aa |
+void
|
|
|
ff86aa |
ply_terminal_session_close_log (ply_terminal_session_t *session)
|
|
|
ff86aa |
{
|
|
|
ff86aa |
assert (session != NULL);
|
|
|
ff86aa |
assert (session->logger != NULL);
|
|
|
ff86aa |
|
|
|
ff86aa |
return ply_logger_close_file (session->logger);
|
|
|
ff86aa |
}
|
|
|
ff86aa |
|
|
|
ff86aa |
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
|
|
|
ff86aa |
--
|
|
|
ff86aa |
2.12.2
|
|
|
ff86aa |
|