Blob Blame History Raw
From 3edbaf6559eb81243326ebe79dc53b0759809a68 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 24 Mar 2017 15:31:51 -0400
Subject: [PATCH] Revert "Recreate boot log at each boot instead of appending"

This reverts commit 9abbd88835a181cda1427d61d92ef5685ad8a81b.
---
 src/libply/ply-logger.c           | 2 +-
 src/libply/ply-terminal-session.c | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

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