aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/tomoyo/util.c')
-rw-r--r--security/tomoyo/util.c39
1 files changed, 9 insertions, 30 deletions
diff --git a/security/tomoyo/util.c b/security/tomoyo/util.c
index 580b318910f1..d3d9d9f1edb0 100644
--- a/security/tomoyo/util.c
+++ b/security/tomoyo/util.c
@@ -87,38 +87,17 @@ const u8 tomoyo_index2category[TOMOYO_MAX_MAC_INDEX] = {
87 * @stamp: Pointer to "struct tomoyo_time". 87 * @stamp: Pointer to "struct tomoyo_time".
88 * 88 *
89 * Returns nothing. 89 * Returns nothing.
90 *
91 * This function does not handle Y2038 problem.
92 */ 90 */
93void tomoyo_convert_time(time_t time, struct tomoyo_time *stamp) 91void tomoyo_convert_time(time64_t time64, struct tomoyo_time *stamp)
94{ 92{
95 static const u16 tomoyo_eom[2][12] = { 93 struct tm tm;
96 { 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, 94 time64_to_tm(time64, 0, &tm);
97 { 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } 95 stamp->sec = tm.tm_sec;
98 }; 96 stamp->min = tm.tm_min;
99 u16 y; 97 stamp->hour = tm.tm_hour;
100 u8 m; 98 stamp->day = tm.tm_mday;
101 bool r; 99 stamp->month = tm.tm_mon + 1;
102 stamp->sec = time % 60; 100 stamp->year = tm.tm_year + 1900;
103 time /= 60;
104 stamp->min = time % 60;
105 time /= 60;
106 stamp->hour = time % 24;
107 time /= 24;
108 for (y = 1970; ; y++) {
109 const unsigned short days = (y & 3) ? 365 : 366;
110 if (time < days)
111 break;
112 time -= days;
113 }
114 r = (y & 3) == 0;
115 for (m = 0; m < 11 && time >= tomoyo_eom[r][m]; m++)
116 ;
117 if (m)
118 time -= tomoyo_eom[r][m - 1];
119 stamp->year = y;
120 stamp->month = ++m;
121 stamp->day = ++time;
122} 101}
123 102
124/** 103/**