1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 2019 Samsung Electronics Co., Ltd.
6 #ifndef __KSMBD_TIME_WRAPPERS_H
7 #define __KSMBD_TIME_WRAPPERS_H
10 * A bunch of ugly hacks to workaoround all the API differences
11 * between different kernel versions.
14 #define NTFS_TIME_OFFSET ((u64)(369 * 365 + 89) * 24 * 3600 * 10000000)
16 /* Convert the Unix UTC into NT UTC. */
17 static inline u64 ksmbd_UnixTimeToNT(struct timespec64 t)
19 /* Convert to 100ns intervals and then add the NTFS time offset. */
20 return (u64)t.tv_sec * 10000000 + t.tv_nsec / 100 + NTFS_TIME_OFFSET;
23 struct timespec64 ksmbd_NTtimeToUnix(__le64 ntutc);
25 #define KSMBD_TIME_TO_TM time64_to_tm
27 static inline long long ksmbd_systime(void)
31 ktime_get_real_ts64(&ts);
32 return ksmbd_UnixTimeToNT(ts);
34 #endif /* __KSMBD_TIME_WRAPPERS_H */