Skip to content

Commit

Permalink
fs: sdfat: Fix compilation on Linux >= 4.16
Browse files Browse the repository at this point in the history
  • Loading branch information
KNnut authored and cryptomilk committed Jan 23, 2019
1 parent d5b9695 commit 4f65bdd
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 53 deletions.
6 changes: 3 additions & 3 deletions core.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ static s32 __fs_set_vol_flags(struct super_block *sb, u16 new_flag, s32 always_s
/* skip updating volume dirty flag,
* if this volume has been mounted with read-only
*/
if (sb->s_flags & MS_RDONLY)
if (SDFAT_IS_SB_RDONLY(sb))
return 0;

if (!fsi->pbr_bh) {
Expand Down Expand Up @@ -1956,10 +1956,10 @@ s32 fscore_lookup(struct inode *inode, u8 *path, FILE_ID_T *fid)
return ret;

/* check the validation of hint_stat and initialize it if required */
if (dir_fid->version != (u32)(inode->i_version & 0xffffffff)) {
if (dir_fid->version != (u32)(GET_IVERSION(inode) & 0xffffffff)) {
dir_fid->hint_stat.clu = dir.dir;
dir_fid->hint_stat.eidx = 0;
dir_fid->version = (u32)(inode->i_version & 0xffffffff);
dir_fid->version = (u32)(GET_IVERSION(inode) & 0xffffffff);
dir_fid->hint_femp.eidx = -1;
}

Expand Down
4 changes: 2 additions & 2 deletions dfr.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ defrag_update_fat_prev(
int skip = 0, done = 0;

/* Check if FS_ERROR occurred */
if (sb->s_flags & MS_RDONLY) {
if (SDFAT_IS_SB_RDONLY(sb)) {
dfr_err("RDONLY partition (err %d)", -EPERM);
goto out;
}
Expand Down Expand Up @@ -1040,7 +1040,7 @@ defrag_update_fat_next(
int done = 0, i = 0, j = 0, err = 0;

/* Check if FS_ERROR occurred */
if (sb->s_flags & MS_RDONLY) {
if (SDFAT_IS_SB_RDONLY(sb)) {
dfr_err("RDONLY partition (err %d)", -EROFS);
goto out;
}
Expand Down
22 changes: 9 additions & 13 deletions misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@
#define ST_LOG(fmt, ...)
#endif

/*************************************************************************
* FUNCTIONS WHICH HAS KERNEL VERSION DEPENDENCY
*************************************************************************/
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
#define CURRENT_TIME_SEC timespec_trunc(current_kernel_time(), NSEC_PER_SEC)
#endif


/*
* sdfat_fs_error reports a file system problem that might indicate fa data
* corruption/inconsistency. Depending on 'errors' mount option the
Expand All @@ -83,7 +75,7 @@ void __sdfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
pr_err("[SDFAT](%s[%d:%d]):ERR: %pV\n",
sb->s_id, MAJOR(bd_dev), MINOR(bd_dev), &vaf);
#ifdef CONFIG_SDFAT_SUPPORT_STLOG
if (opts->errors == SDFAT_ERRORS_RO && !(sb->s_flags & MS_RDONLY)) {
if (opts->errors == SDFAT_ERRORS_RO && !SDFAT_IS_SB_RDONLY(sb)) {
ST_LOG("[SDFAT](%s[%d:%d]):ERR: %pV\n",
sb->s_id, MAJOR(bd_dev), MINOR(bd_dev), &vaf);
}
Expand All @@ -94,8 +86,12 @@ void __sdfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
if (opts->errors == SDFAT_ERRORS_PANIC) {
panic("[SDFAT](%s[%d:%d]): fs panic from previous error\n",
sb->s_id, MAJOR(bd_dev), MINOR(bd_dev));
} else if (opts->errors == SDFAT_ERRORS_RO && !(sb->s_flags & MS_RDONLY)) {
} else if (opts->errors == SDFAT_ERRORS_RO && !SDFAT_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
sdfat_statistics_set_mnt_ro();
pr_err("[SDFAT](%s[%d:%d]): Filesystem has been set "
"read-only\n", sb->s_id, MAJOR(bd_dev), MINOR(bd_dev));
Expand Down Expand Up @@ -179,7 +175,7 @@ static time_t accum_days_in_year[] = {
};

/* Convert a FAT time/date pair to a UNIX date (seconds since 1 1 70). */
void sdfat_time_fat2unix(struct sdfat_sb_info *sbi, struct timespec *ts,
void sdfat_time_fat2unix(struct sdfat_sb_info *sbi, struct timespec_compat *ts,
DATE_TIME_T *tp)
{
time_t year = tp->Year;
Expand All @@ -202,7 +198,7 @@ void sdfat_time_fat2unix(struct sdfat_sb_info *sbi, struct timespec *ts,
}

/* Convert linear UNIX date to a FAT time/date pair. */
void sdfat_time_unix2fat(struct sdfat_sb_info *sbi, struct timespec *ts,
void sdfat_time_unix2fat(struct sdfat_sb_info *sbi, struct timespec_compat *ts,
DATE_TIME_T *tp)
{
time_t second = ts->tv_sec;
Expand Down Expand Up @@ -266,7 +262,7 @@ void sdfat_time_unix2fat(struct sdfat_sb_info *sbi, struct timespec *ts,

TIMESTAMP_T *tm_now(struct sdfat_sb_info *sbi, TIMESTAMP_T *tp)
{
struct timespec ts = CURRENT_TIME_SEC;
struct timespec_compat ts = CURRENT_TIME_SEC;
DATE_TIME_T dt;

sdfat_time_unix2fat(sbi, &ts, &dt);
Expand Down
Loading

0 comments on commit 4f65bdd

Please sign in to comment.