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

Fix the compilation problem after Linux kernel 5.0 #151

Open
wants to merge 4 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
5 changes: 5 additions & 0 deletions exfat_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1757,8 +1757,13 @@ void fs_error(struct super_block *sb)

if (opts->errors == EXFAT_ERRORS_PANIC)
panic("[EXFAT] Filesystem panic from previous error\n");
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0)
else if ((opts->errors == EXFAT_ERRORS_RO) && !(sb->s_flags & SB_RDONLY)) {
sb->s_flags |= SB_RDONLY;
#else
else if ((opts->errors == EXFAT_ERRORS_RO) && !(sb->s_flags & MS_RDONLY)) {
sb->s_flags |= MS_RDONLY;
#endif
printk(KERN_ERR "[EXFAT] Filesystem has been set read-only\n");
}
}
Expand Down
8 changes: 4 additions & 4 deletions exfat_oal.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,20 @@ extern struct timezone sys_tz;
} while (0)

/* Linear day numbers of the respective 1sts in non-leap years. */
static time_t accum_days_in_year[] = {
static ktime_t accum_days_in_year[] = {
/* Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec */
0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0,
};

TIMESTAMP_T *tm_current(TIMESTAMP_T *tp)
{
struct timespec ts;
time_t second, day, leap_day, month, year;
struct timespec64 ts;
ktime_t second, day, leap_day, month, year;

#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0)
ts = CURRENT_TIME_SEC;
#else
ktime_get_real_ts(&ts);
ktime_get_real_ts64(&ts);
#endif

second = ts.tv_sec;
Expand Down
28 changes: 20 additions & 8 deletions exfat_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,19 @@ extern struct timezone sys_tz;
} while (0)

/* Linear day numbers of the respective 1sts in non-leap years. */
static time_t accum_days_in_year[] = {
static ktime_t accum_days_in_year[] = {
/* Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec */
0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0,
};

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;
time_t ld;
ktime_t year = tp->Year;
ktime_t ld;

MAKE_LEAP_YEAR(ld, year);

Expand All @@ -166,12 +166,12 @@ 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;
time_t day, month, year;
time_t ld;
ktime_t second = ts->tv_sec;
ktime_t day, month, year;
ktime_t ld;

second -= sys_tz.tz_minuteswest * SECS_PER_MIN;

Expand Down Expand Up @@ -2080,7 +2080,11 @@ static void exfat_write_super(struct super_block *sb)

__set_sb_clean(sb);

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0)
if (!(sb->s_flags & SB_RDONLY))
#else
if (!(sb->s_flags & MS_RDONLY))
#endif
FsSyncVol(sb, 1);

__unlock_super(sb);
Expand Down Expand Up @@ -2136,7 +2140,11 @@ 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(5,0,0)
*flags |= SB_NODIRATIME;
#else
*flags |= MS_NODIRATIME;
#endif
return 0;
}

Expand Down Expand Up @@ -2489,7 +2497,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(5,0,0)
sb->s_flags |= SB_NODIRATIME;
#else
sb->s_flags |= MS_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.3.0"