• R/O
  • SSH
  • HTTPS

akari: Commit


Commit MetaInfo

Revisión622 (tree)
Tiempo2020-01-02 12:42:54
Autorkumaneko

Log Message

(empty log message)

Cambiar Resumen

Diferencia

--- trunk/akari/policy_io.c (revision 621)
+++ trunk/akari/policy_io.c (revision 622)
@@ -518,7 +518,11 @@
518518 __printf(3, 4);
519519 static void ccs_addprintf(char *buffer, int len, const char *fmt, ...);
520520 static void ccs_check_profile(void);
521+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
521522 static void ccs_convert_time(time_t time, struct ccs_time *stamp);
523+#else
524+static void ccs_convert_time(time64_t time, struct ccs_time *stamp);
525+#endif
522526 static void ccs_init_policy_namespace(struct ccs_policy_namespace *ns);
523527 static void ccs_io_printf(struct ccs_io_buffer *head, const char *fmt, ...)
524528 __printf(2, 3);
@@ -668,6 +672,7 @@
668672
669673 #endif
670674
675+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
671676 /**
672677 * ccs_convert_time - Convert time_t to YYYY/MM/DD hh/mm/ss.
673678 *
@@ -707,7 +712,29 @@
707712 stamp->month = ++m;
708713 stamp->day = ++time;
709714 }
715+#else
716+/**
717+ * ccs_convert_time - Convert time_t to YYYY/MM/DD hh/mm/ss.
718+ *
719+ * @time: Seconds since 1970/01/01 00:00:00.
720+ * @stamp: Pointer to "struct ccs_time".
721+ *
722+ * Returns nothing.
723+ */
724+static void ccs_convert_time(time64_t time, struct ccs_time *stamp)
725+{
726+ struct tm tm;
710727
728+ time64_to_tm(time, 0, &tm);
729+ stamp->sec = tm.tm_sec;
730+ stamp->min = tm.tm_min;
731+ stamp->hour = tm.tm_hour;
732+ stamp->day = tm.tm_mday;
733+ stamp->month = tm.tm_mon + 1;
734+ stamp->year = tm.tm_year + 1900;
735+}
736+#endif
737+
711738 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 23)
712739 #if !defined(RHEL_VERSION) || RHEL_VERSION != 3
713740
@@ -1237,11 +1264,15 @@
12371264 /* Length of "stuct list_head ccs_log". */
12381265 static unsigned int ccs_log_count;
12391266
1240-/* Timestamp counter for last updated. */
1267+/* Counter for number of updates. */
12411268 static unsigned int ccs_stat_updated[CCS_MAX_POLICY_STAT];
12421269
1243-/* Counter for number of updates. */
1270+/* Timestamp counter for last updated. */
1271+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
12441272 static unsigned int ccs_stat_modified[CCS_MAX_POLICY_STAT];
1273+#else
1274+static time64_t ccs_stat_modified[CCS_MAX_POLICY_STAT];
1275+#endif
12451276
12461277 /* Operations for /proc/ccs/self_domain interface. */
12471278 static
@@ -5118,18 +5149,19 @@
51185149 {
51195150 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
51205151 struct timeval tv;
5121- do_gettimeofday(&tv);
5152+#endif
5153+
51225154 /*
51235155 * I don't use atomic operations because race condition is not fatal.
51245156 */
51255157 ccs_stat_updated[index]++;
5158+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
5159+ do_gettimeofday(&tv);
51265160 ccs_stat_modified[index] = tv.tv_sec;
5161+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
5162+ ccs_stat_modified[index] = get_seconds();
51275163 #else
5128- /*
5129- * I don't use atomic operations because race condition is not fatal.
5130- */
5131- ccs_stat_updated[index]++;
5132- ccs_stat_modified[index] = get_seconds();
5164+ ccs_stat_modified[index] = ktime_get_real_seconds();
51335165 #endif
51345166 }
51355167
@@ -5354,8 +5386,10 @@
53545386 do_gettimeofday(&tv);
53555387 ccs_convert_time(tv.tv_sec, &stamp);
53565388 }
5389+#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
5390+ ccs_convert_time(get_seconds(), &stamp);
53575391 #else
5358- ccs_convert_time(get_seconds(), &stamp);
5392+ ccs_convert_time(ktime_get_real_seconds(), &stamp);
53595393 #endif
53605394 pos = snprintf(buffer, ccs_buffer_len - 1,
53615395 "#%04u/%02u/%02u %02u:%02u:%02u# profile=%u mode=%s "
Show on old repository browser