From acf08c1872653886640d17734a5426f970240436 Mon Sep 17 00:00:00 2001 From: barrybingo Date: Sat, 18 Aug 2018 15:28:35 +0100 Subject: [PATCH 1/7] Linux 4.18 fix --- exfat_super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exfat_super.c b/exfat_super.c index 312de36..ad8f9f5 100644 --- a/exfat_super.c +++ b/exfat_super.c @@ -147,7 +147,7 @@ static time_t accum_days_in_year[] = { static void _exfat_truncate(struct inode *inode, loff_t old_size); /* Convert a FAT time/date pair to a UNIX date (seconds since 1 1 70). */ -void exfat_time_fat2unix(struct exfat_sb_info *sbi, struct timespec *ts, +void exfat_time_fat2unix(struct exfat_sb_info *sbi, struct timespec64 *ts, DATE_TIME_T *tp) { time_t year = tp->Year; @@ -166,7 +166,7 @@ void exfat_time_fat2unix(struct exfat_sb_info *sbi, struct timespec *ts, } /* Convert linear UNIX date to a FAT time/date pair. */ -void exfat_time_unix2fat(struct exfat_sb_info *sbi, struct timespec *ts, +void exfat_time_unix2fat(struct exfat_sb_info *sbi, struct timespec64 *ts, DATE_TIME_T *tp) { time_t second = ts->tv_sec; From e95c8847b07059d2f41cd924af5486feea25f26d Mon Sep 17 00:00:00 2001 From: barrybingo Date: Sat, 18 Aug 2018 15:36:14 +0100 Subject: [PATCH 2/7] Still compile for older kernels --- exfat_super.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/exfat_super.c b/exfat_super.c index ad8f9f5..3ac18b0 100644 --- a/exfat_super.c +++ b/exfat_super.c @@ -147,8 +147,13 @@ static time_t accum_days_in_year[] = { static void _exfat_truncate(struct inode *inode, loff_t old_size); /* Convert a FAT time/date pair to a UNIX date (seconds since 1 1 70). */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,18,01) void exfat_time_fat2unix(struct exfat_sb_info *sbi, struct timespec64 *ts, DATE_TIME_T *tp) +#else +void exfat_time_fat2unix(struct exfat_sb_info *sbi, struct timespec *ts, + DATE_TIME_T *tp) +#endif { time_t year = tp->Year; time_t ld; @@ -166,8 +171,13 @@ void exfat_time_fat2unix(struct exfat_sb_info *sbi, struct timespec64 *ts, } /* Convert linear UNIX date to a FAT time/date pair. */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,18,01) void exfat_time_unix2fat(struct exfat_sb_info *sbi, struct timespec64 *ts, DATE_TIME_T *tp) +#else +void exfat_time_unix2fat(struct exfat_sb_info *sbi, struct timespec *ts, + DATE_TIME_T *tp) +#endif { time_t second = ts->tv_sec; time_t day, month, year; From 01da14f70d89d2442c29841044ebbe3921de6121 Mon Sep 17 00:00:00 2001 From: barrybingo Date: Thu, 20 Sep 2018 14:01:39 +0100 Subject: [PATCH 3/7] Bump version --- exfat_version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exfat_version.h b/exfat_version.h index a93fa46..fbfdc86 100644 --- a/exfat_version.h +++ b/exfat_version.h @@ -16,4 +16,4 @@ /* */ /************************************************************************/ -#define EXFAT_VERSION "1.2.9" +#define EXFAT_VERSION "1.2.10" From dea60b8484ee55330e8ac64085591eedc4bf4a91 Mon Sep 17 00:00:00 2001 From: barrybingo Date: Thu, 20 Sep 2018 14:04:36 +0100 Subject: [PATCH 4/7] Simplify --- exfat_super.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/exfat_super.c b/exfat_super.c index 3ac18b0..79ff5f9 100644 --- a/exfat_super.c +++ b/exfat_super.c @@ -102,6 +102,12 @@ extern struct timezone sys_tz; #define current_time(x) (CURRENT_TIME_SEC) #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,18,0) +#define timespec_compat timespec64 +#else +#define timespec_compat timespec +#endif + #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) #define USE_NEW_IVERSION_API #define INC_IVERSION(x) (inode_inc_iversion(x)) @@ -147,13 +153,8 @@ static time_t accum_days_in_year[] = { static void _exfat_truncate(struct inode *inode, loff_t old_size); /* Convert a FAT time/date pair to a UNIX date (seconds since 1 1 70). */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,18,01) -void exfat_time_fat2unix(struct exfat_sb_info *sbi, struct timespec64 *ts, - DATE_TIME_T *tp) -#else -void exfat_time_fat2unix(struct exfat_sb_info *sbi, struct timespec *ts, +void exfat_time_fat2unix(struct exfat_sb_info *sbi, struct timespec_compat *ts, DATE_TIME_T *tp) -#endif { time_t year = tp->Year; time_t ld; @@ -171,13 +172,8 @@ void exfat_time_fat2unix(struct exfat_sb_info *sbi, struct timespec *ts, } /* Convert linear UNIX date to a FAT time/date pair. */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,18,01) -void exfat_time_unix2fat(struct exfat_sb_info *sbi, struct timespec64 *ts, - DATE_TIME_T *tp) -#else -void exfat_time_unix2fat(struct exfat_sb_info *sbi, struct timespec *ts, +void exfat_time_unix2fat(struct exfat_sb_info *sbi, struct timespec_compat *ts, DATE_TIME_T *tp) -#endif { time_t second = ts->tv_sec; time_t day, month, year; From f93a47e6414d567a1e7f6ab7f34b015b20f9a050 Mon Sep 17 00:00:00 2001 From: barrybingo Date: Mon, 31 Dec 2018 16:50:33 +0000 Subject: [PATCH 5/7] Fix for 4.20 --- exfat_oal.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/exfat_oal.c b/exfat_oal.c index 7435442..9a4f589 100644 --- a/exfat_oal.c +++ b/exfat_oal.c @@ -128,13 +128,23 @@ static time_t accum_days_in_year[] = { TIMESTAMP_T *tm_current(TIMESTAMP_T *tp) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0) + struct timespec64 ts; +#else struct timespec ts; +#endif time_t second, day, leap_day, month, year; #if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0) ts = CURRENT_TIME_SEC; #else + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0) + ktime_get_real_ts64(&ts); +#else ktime_get_real_ts(&ts); +#endif + #endif second = ts.tv_sec; From 8b59e1f338fdd87f1d5a9db2a119a3745bb467d5 Mon Sep 17 00:00:00 2001 From: Junde Yhi Date: Thu, 10 Jan 2019 21:19:49 +0800 Subject: [PATCH 6/7] exfat_{core,super}.c: fix build on 5.0-rc1, MS_* -> SB_* In torvalds/linux@e462ec50cb a new set of superblock flags was added to replace the original MS_* ones, and in torvalds/linux@e262e32d6b the MS_* flags are suppressed unless uapi/linux/mount.h is included. As is suggested, we should use the new API now. --- exfat_core.c | 6 +++++- exfat_core.h | 6 ++++++ exfat_super.c | 11 ++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/exfat_core.c b/exfat_core.c index 143b721..397afd6 100644 --- a/exfat_core.c +++ b/exfat_core.c @@ -1757,8 +1757,12 @@ void fs_error(struct super_block *sb) if (opts->errors == EXFAT_ERRORS_PANIC) panic("[EXFAT] Filesystem panic from previous error\n"); - else if ((opts->errors == EXFAT_ERRORS_RO) && !(sb->s_flags & MS_RDONLY)) { + else if ((opts->errors == EXFAT_ERRORS_RO) && !EXFAT_IS_SB_RDONLY(sb)) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) sb->s_flags |= MS_RDONLY; +#else + sb->s_flags |= SB_RDONLY; +#endif printk(KERN_ERR "[EXFAT] Filesystem has been set read-only\n"); } } diff --git a/exfat_core.h b/exfat_core.h index 52d05c7..3d023b7 100644 --- a/exfat_core.h +++ b/exfat_core.h @@ -45,6 +45,12 @@ #include "exfat_api.h" #include "exfat_cache.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) +#define EXFAT_IS_SB_RDONLY(sb) ((sb)->s_flags & MS_RDONLY) +#else +#define EXFAT_IS_SB_RDONLY(sb) ((sb)->s_flags & SB_RDONLY) +#endif + #ifdef CONFIG_EXFAT_KERNEL_DEBUG /* For Debugging Purpose */ /* IOCTL code 'f' used by diff --git a/exfat_super.c b/exfat_super.c index 79ff5f9..6452b54 100644 --- a/exfat_super.c +++ b/exfat_super.c @@ -2086,7 +2086,7 @@ static void exfat_write_super(struct super_block *sb) __set_sb_clean(sb); - if (!(sb->s_flags & MS_RDONLY)) + if (!EXFAT_IS_SB_RDONLY(sb)) FsSyncVol(sb, 1); __unlock_super(sb); @@ -2142,7 +2142,12 @@ static int exfat_statfs(struct dentry *dentry, struct kstatfs *buf) static int exfat_remount(struct super_block *sb, int *flags, char *data) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) *flags |= MS_NODIRATIME; +#else + *flags |= SB_NODIRATIME; +#endif + return 0; } @@ -2495,7 +2500,11 @@ static int exfat_fill_super(struct super_block *sb, void *data, int silent) mutex_init(&sbi->s_lock); #endif sb->s_fs_info = sbi; +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) sb->s_flags |= MS_NODIRATIME; +#else + sb->s_flags |= SB_NODIRATIME; +#endif sb->s_magic = EXFAT_SUPER_MAGIC; sb->s_op = &exfat_sops; sb->s_export_op = &exfat_export_ops; From 297a5739cd4a942a1d814d05a9cd9b542e7b8fc8 Mon Sep 17 00:00:00 2001 From: barrybingo Date: Wed, 15 Apr 2020 11:33:18 +0100 Subject: [PATCH 7/7] Newer kernels use time64_t to be y2038-safe and time_t is no longer a type. This is tested and works on 5.6.3 as well as 5.5.17. The _TIME_T seems to have been introduced in 2.6.12 and was removed in 412c53a680a97cb1ae2c0ab60230e193bee86387 --- exfat_oal.c | 3 +++ exfat_super.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/exfat_oal.c b/exfat_oal.c index 9a4f589..7febdd7 100644 --- a/exfat_oal.c +++ b/exfat_oal.c @@ -44,6 +44,9 @@ #include #include +#ifndef _TIME_T +typedef time64_t time_t; +#endif #include "exfat_config.h" #include "exfat_api.h" diff --git a/exfat_super.c b/exfat_super.c index 6452b54..80a6ad0 100644 --- a/exfat_super.c +++ b/exfat_super.c @@ -49,6 +49,9 @@ #include #include #include +#ifndef _TIME_T +typedef time64_t time_t; +#endif #include #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37) #include