diff --git a/dir.c b/dir.c index fae98c47e572..8fdc3f3e416f 100644 --- a/dir.c +++ b/dir.c @@ -441,15 +441,21 @@ int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir, { struct super_block *sb = inode->i_sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) - struct timespec64 ts = current_time(inode); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) + struct timespec64 ts; #else - struct timespec64 ts = CURRENT_TIME_SEC; + struct timespec ts; #endif sector_t sector; struct exfat_dentry *ep; struct buffer_head *bh; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) + ts = current_time(inode); +#else + ts = CURRENT_TIME_SEC; +#endif + /* * We cannot use exfat_get_dentry_set here because file ep is not * initialized yet. diff --git a/exfat_fs.h b/exfat_fs.h index 0f44bb9e9b51..60650f97673d 100644 --- a/exfat_fs.h +++ b/exfat_fs.h @@ -186,9 +186,15 @@ struct exfat_dir_entry { unsigned short attr; loff_t size; unsigned int num_subdirs; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) struct timespec64 atime; struct timespec64 mtime; struct timespec64 crtime; +#else + struct timespec atime; + struct timespec mtime; + struct timespec crtime; +#endif struct exfat_dentry_namebuf namebuf; }; @@ -296,7 +302,11 @@ struct exfat_inode_info { struct rw_semaphore truncate_lock; struct inode vfs_inode; /* File creation time */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) struct timespec64 i_crtime; +#else + struct timespec i_crtime; +#endif }; static inline struct exfat_sb_info *EXFAT_SB(struct super_block *sb) @@ -514,11 +524,19 @@ void exfat_msg(struct super_block *sb, const char *lv, const char *fmt, ...) #define exfat_info(sb, fmt, ...) \ exfat_msg(sb, KERN_INFO, fmt, ##__VA_ARGS__) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts, u8 tz, __le16 time, __le16 date, u8 time_cs); void exfat_truncate_atime(struct timespec64 *ts); void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts, u8 *tz, __le16 *time, __le16 *date, u8 *time_cs); +#else +void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec *ts, + u8 tz, __le16 time, __le16 date, u8 time_cs); +void exfat_truncate_atime(struct timespec *ts); +void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec *ts, + u8 *tz, __le16 *time, __le16 *date, u8 *time_cs); +#endif u16 exfat_calc_chksum16(void *data, int len, u16 chksum, int type); u32 exfat_calc_chksum32(void *data, int len, u32 chksum, int type); void exfat_update_bh(struct buffer_head *bh, int sync); diff --git a/file.c b/file.c index b0a30b34c6c1..99026432a114 100644 --- a/file.c +++ b/file.c @@ -160,7 +160,11 @@ int __exfat_truncate(struct inode *inode, loff_t new_size) /* update the directory entry */ if (!evict) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) struct timespec64 ts; +#else + struct timespec ts; +#endif struct exfat_dentry *ep, *ep2; struct exfat_entry_set_cache *es; int err; diff --git a/misc.c b/misc.c index 1fe22cb55126..62b5957cab47 100644 --- a/misc.c +++ b/misc.c @@ -71,7 +71,11 @@ void exfat_msg(struct super_block *sb, const char *level, const char *fmt, ...) #define SECS_PER_MIN (60) #define TIMEZONE_SEC(x) ((x) * 15 * SECS_PER_MIN) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) static void exfat_adjust_tz(struct timespec64 *ts, u8 tz_off) +#else +static void exfat_adjust_tz(struct timespec *ts, u8 tz_off) +#endif { if (tz_off <= 0x3F) ts->tv_sec -= TIMEZONE_SEC(tz_off); @@ -80,8 +84,13 @@ static void exfat_adjust_tz(struct timespec64 *ts, u8 tz_off) } /* Convert a EXFAT time/date pair to a UNIX date (seconds since 1 1 70). */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts, u8 tz, __le16 time, __le16 date, u8 time_cs) +#else +void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec *ts, + u8 tz, __le16 time, __le16 date, u8 time_cs) +#endif { u16 t = le16_to_cpu(time); u16 d = le16_to_cpu(date); @@ -106,8 +115,13 @@ void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts, } /* Convert linear UNIX date to a EXFAT time/date pair. */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts, u8 *tz, __le16 *time, __le16 *date, u8 *time_cs) +#else +void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec *ts, + u8 *tz, __le16 *time, __le16 *date, u8 *time_cs) +#endif { struct tm tm; u16 t, d; @@ -136,7 +150,11 @@ void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts, } /* atime has only a 2-second resolution */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) void exfat_truncate_atime(struct timespec64 *ts) +#else +void exfat_truncate_atime(struct timespec *ts) +#endif { ts->tv_sec = round_down(ts->tv_sec, 2); ts->tv_nsec = 0;