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_oal.c b/exfat_oal.c index 7435442..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" @@ -128,13 +131,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; diff --git a/exfat_super.c b/exfat_super.c index 312de36..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 @@ -102,6 +105,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,7 +156,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 timespec_compat *ts, DATE_TIME_T *tp) { time_t year = tp->Year; @@ -166,7 +175,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 timespec_compat *ts, DATE_TIME_T *tp) { time_t second = ts->tv_sec; @@ -2080,7 +2089,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); @@ -2136,7 +2145,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; } @@ -2489,7 +2503,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; 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"