Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux 4.18/4.20 fix #137

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion exfat_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Expand Down
6 changes: 6 additions & 0 deletions exfat_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions exfat_oal.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@

#include <linux/semaphore.h>
#include <linux/time.h>
#ifndef _TIME_T
typedef time64_t time_t;
#endif

#include "exfat_config.h"
#include "exfat_api.h"
Expand Down Expand Up @@ -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;
Expand Down
24 changes: 21 additions & 3 deletions exfat_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/time.h>
#ifndef _TIME_T
typedef time64_t time_t;
#endif
#include <linux/slab.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
#include <linux/smp_lock.h>
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion exfat_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
/* */
/************************************************************************/

#define EXFAT_VERSION "1.2.9"
#define EXFAT_VERSION "1.2.10"