On 2017/11/21 6:19, Dan Williams wrote:
On Mon, Nov 13, 2017 at 11:46 PM, QI Fuli <qi.f...@jp.fujitsu.com> wrote:
This patch is used to provide helper functions needed for nvdimm daemon.
These util functions can be used by other features as well in the future.

Signed-off-by: QI Fuli <qi.f...@jp.fujitsu.com>
---
  nvdimmd/util.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  nvdimmd/util.h | 33 ++++++++++++++++++++++++
  2 files changed, 113 insertions(+)
  create mode 100644 nvdimmd/util.c
  create mode 100644 nvdimmd/util.h

diff --git a/nvdimmd/util.c b/nvdimmd/util.c
new file mode 100644
index 0000000..ef6819e
--- /dev/null
+++ b/nvdimmd/util.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2017, FUJITSU LIMITED. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 2.1, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ * more details.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include "util.h"
+
+void logrotate(char *file)
+{
+       time_t c_time;
+       char buf[4096], tstamp[32];
+
+       c_time = time(NULL);
+       strftime(tstamp, sizeof(tstamp), ".%Y%m%d%H%M%S", localtime(&c_time));
+       strcpy(buf, file);
+       strcat(buf, tstamp);
+       rename(file, buf);
+}
Why does the monitor need to rotate logs? This should be the
responsibility of whatever is consuming  the nvdimmd events.
When I wrote it, I thought that users can rotate nvdimmd logs without using other tools.
If you think it is not necessary, I will remove it in next version.

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reply via email to