diff --git a/dir.c b/dir.c index aefd8859a8f6..a8e3e36de072 100644 --- a/dir.c +++ b/dir.c @@ -444,7 +444,7 @@ int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir, { struct super_block *sb = inode->i_sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) struct timespec64 ts = current_time(inode); #else struct timespec64 ts = CURRENT_TIME_SEC; diff --git a/exfat_fs.h b/exfat_fs.h index 67d4e46fb810..5d81b89688ad 100644 --- a/exfat_fs.h +++ b/exfat_fs.h @@ -6,6 +6,7 @@ #ifndef _EXFAT_FS_H #define _EXFAT_FS_H +#include #include #include #include @@ -422,8 +423,14 @@ extern const struct file_operations exfat_file_operations; int __exfat_truncate(struct inode *inode, loff_t new_size); void exfat_truncate(struct inode *inode, loff_t size); int exfat_setattr(struct dentry *dentry, struct iattr *attr); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) int exfat_getattr(const struct path *path, struct kstat *stat, unsigned int request_mask, unsigned int query_flags); +#else +int exfat_getattr(struct vfsmount *mnt, struct dentry *dentry, + struct kstat *stat); +#endif + /* namei.c */ extern const struct dentry_operations exfat_dentry_ops; diff --git a/fatent.c b/fatent.c index a855b1769a96..7e6eb3b7b7c5 100644 --- a/fatent.c +++ b/fatent.c @@ -26,7 +26,11 @@ static int exfat_mirror_bh(struct super_block *sb, sector_t sec, memcpy(c_bh->b_data, bh->b_data, sb->s_blocksize); set_buffer_uptodate(c_bh); mark_buffer_dirty(c_bh); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) if (sb->s_flags & SB_SYNCHRONOUS) +#else + if (sb->s_flags & MS_SYNCHRONOUS) +#endif err = sync_dirty_buffer(c_bh); brelse(c_bh); } @@ -75,7 +79,11 @@ int exfat_ent_set(struct super_block *sb, unsigned int loc, fat_entry = (__le32 *)&(bh->b_data[off]); *fat_entry = cpu_to_le32(content); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) exfat_update_bh(sb, bh, sb->s_flags & SB_SYNCHRONOUS); +#else + exfat_update_bh(sb, bh, sb->s_flags & MS_SYNCHRONOUS); +#endif exfat_mirror_bh(sb, sec, bh); brelse(bh); return 0; diff --git a/file.c b/file.c index 79fce874c8dc..415a8d48849e 100644 --- a/file.c +++ b/file.c @@ -5,8 +5,12 @@ #include #include -#include #include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) +#include +#else +#include +#endif #include "exfat_raw.h" #include "exfat_fs.h" @@ -21,7 +25,7 @@ static int exfat_cont_expand(struct inode *inode, loff_t size) if (err) return err; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) inode->i_ctime = inode->i_mtime = current_time(inode); #else inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC; @@ -165,7 +169,7 @@ int __exfat_truncate(struct inode *inode, loff_t new_size) return -EIO; ep2 = ep + 1; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) ts = current_time(inode); #else ts = CURRENT_TIME_SEC; @@ -252,7 +256,7 @@ void exfat_truncate(struct inode *inode, loff_t size) if (err) goto write_size; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) inode->i_ctime = inode->i_mtime = current_time(inode); #else inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC; @@ -279,16 +283,28 @@ write_size: mutex_unlock(&sbi->s_lock); } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) int exfat_getattr(const struct path *path, struct kstat *stat, unsigned int request_mask, unsigned int query_flags) +#else +int exfat_getattr(struct vfsmount *mnt, struct dentry *dentry, + struct kstat *stat) +#endif + { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) struct inode *inode = d_backing_inode(path->dentry); struct exfat_inode_info *ei = EXFAT_I(inode); +#else + struct inode *inode = d_inode(dentry); +#endif generic_fillattr(inode, stat); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) stat->result_mask |= STATX_BTIME; stat->btime.tv_sec = ei->i_crtime.tv_sec; stat->btime.tv_nsec = ei->i_crtime.tv_nsec; +#endif stat->blksize = EXFAT_SB(inode->i_sb)->cluster_size; return 0; } @@ -316,7 +332,13 @@ int exfat_setattr(struct dentry *dentry, struct iattr *attr) ATTR_TIMES_SET); } +#if ((LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)) && \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 37))) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) error = setattr_prepare(dentry, attr); +#else + error = inode_change_ok(inode, attr); +#endif attr->ia_valid = ia_valid; if (error) goto out; diff --git a/inode.c b/inode.c index 45ac2e7f3e45..0a535bd86422 100644 --- a/inode.c +++ b/inode.c @@ -13,7 +13,7 @@ #include #include #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) #include #endif #include "exfat_raw.h" @@ -439,7 +439,7 @@ static int exfat_write_end(struct file *file, struct address_space *mapping, exfat_write_failed(mapping, pos+len); if (!(err < 0) && !(ei->attr & ATTR_ARCHIVE)) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) inode->i_mtime = inode->i_ctime = current_time(inode); #else inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; @@ -451,7 +451,13 @@ static int exfat_write_end(struct file *file, struct address_space *mapping, return err; } + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0) static ssize_t exfat_direct_IO(struct kiocb *iocb, struct iov_iter *iter) +#else +static ssize_t exfat_direct_IO(struct kiocb *iocb, struct iov_iter *iter, + loff_t offset) +#endif { struct address_space *mapping = iocb->ki_filp->f_mapping; struct inode *inode = mapping->host; @@ -477,7 +483,11 @@ static ssize_t exfat_direct_IO(struct kiocb *iocb, struct iov_iter *iter) * Need to use the DIO_LOCKING for avoiding the race * condition of exfat_get_block() and ->truncate(). */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0) ret = blockdev_direct_IO(iocb, inode, iter, exfat_get_block); +#else + ret = blockdev_direct_IO(iocb, inode, iter, offset, exfat_get_block); +#endif if (ret < 0 && (rw & WRITE)) exfat_write_failed(mapping, size); return ret; @@ -588,7 +598,7 @@ static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info) inode->i_uid = sbi->options.fs_uid; inode->i_gid = sbi->options.fs_gid; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) inode_inc_iversion(inode); #else inode->i_version++; @@ -650,7 +660,7 @@ struct inode *exfat_build_inode(struct super_block *sb, goto out; } inode->i_ino = iunique(sb, EXFAT_ROOT_INO); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) inode_set_iversion(inode, 1); #else inode->i_version = 1; diff --git a/misc.c b/misc.c index 14a3300848f6..f363c5c917d0 100644 --- a/misc.c +++ b/misc.c @@ -39,8 +39,14 @@ void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...) if (opts->errors == EXFAT_ERRORS_PANIC) { panic("exFAT-fs (%s): fs panic from previous error\n", sb->s_id); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) } else if (opts->errors == EXFAT_ERRORS_RO && !sb_rdonly(sb)) { sb->s_flags |= SB_RDONLY; +#else + } else if (opts->errors == EXFAT_ERRORS_RO && + !(sb->s_flags & MS_RDONLY)) { + sb->s_flags |= MS_RDONLY; +#endif exfat_msg(sb, KERN_ERR, "Filesystem has been set read-only"); } } @@ -105,7 +111,11 @@ void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts, struct tm tm; u16 t, d; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) time64_to_tm(ts->tv_sec, 0, &tm); +#else + time_to_tm(ts->tv_sec, 0, &tm); +#endif t = (tm.tm_hour << 11) | (tm.tm_min << 5) | (tm.tm_sec >> 1); d = ((tm.tm_year - 80) << 9) | ((tm.tm_mon + 1) << 5) | tm.tm_mday; diff --git a/namei.c b/namei.c index 930ae52482d9..21f5e872ae51 100644 --- a/namei.c +++ b/namei.c @@ -4,7 +4,7 @@ */ #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) #include #endif #include @@ -62,7 +62,7 @@ static int exfat_d_revalidate(struct dentry *dentry, unsigned int flags) return 0; spin_lock(&dentry->d_lock); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) ret = inode_eq_iversion(d_inode(dentry->d_parent), exfat_d_version(dentry)); #else @@ -92,7 +92,11 @@ static int exfat_d_hash(const struct dentry *dentry, struct qstr *qstr) struct nls_table *t = EXFAT_SB(sb)->nls_io; const unsigned char *name = qstr->name; unsigned int len = exfat_striptail_len(qstr->len, qstr->name); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) unsigned long hash = init_name_hash(dentry); +#else + unsigned long hash = init_name_hash(); +#endif int i, charlen; wchar_t c; @@ -107,8 +111,13 @@ static int exfat_d_hash(const struct dentry *dentry, struct qstr *qstr) return 0; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) static int exfat_d_cmp(const struct dentry *dentry, unsigned int len, const char *str, const struct qstr *name) +#else +static int exfat_d_cmp(const struct dentry *parent, const struct dentry *dentry, + unsigned int len, const char *str, const struct qstr *name) +#endif { struct super_block *sb = dentry->d_sb; struct nls_table *t = EXFAT_SB(sb)->nls_io; @@ -145,7 +154,11 @@ static int exfat_utf8_d_hash(const struct dentry *dentry, struct qstr *qstr) struct super_block *sb = dentry->d_sb; const unsigned char *name = qstr->name; unsigned int len = exfat_striptail_len(qstr->len, qstr->name); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) unsigned long hash = init_name_hash(dentry); +#else + unsigned long hash = init_name_hash(); +#endif int i, charlen; unicode_t u; @@ -171,8 +184,14 @@ static int exfat_utf8_d_hash(const struct dentry *dentry, struct qstr *qstr) return 0; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) static int exfat_utf8_d_cmp(const struct dentry *dentry, unsigned int len, const char *str, const struct qstr *name) +#else +static int exfat_utf8_d_cmp(const struct dentry *parent, + const struct dentry *dentry, unsigned int len, + const char *str, const struct qstr *name) +#endif { struct super_block *sb = dentry->d_sb; unsigned int alen = exfat_striptail_len(name->len, name->name); @@ -588,12 +607,12 @@ static int exfat_create(struct inode *dir, struct dentry *dentry, umode_t mode, if (err) goto unlock; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) inode_inc_iversion(dir); #else dir->i_version++; #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) dir->i_ctime = dir->i_mtime = current_time(dir); #else dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; @@ -608,13 +627,13 @@ static int exfat_create(struct inode *dir, struct dentry *dentry, umode_t mode, if (IS_ERR(inode)) goto unlock; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) inode_inc_iversion(inode); #else inode->i_version++; #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) inode->i_mtime = inode->i_atime = inode->i_ctime = EXFAT_I(inode)->i_crtime = current_time(inode); #else @@ -655,14 +674,14 @@ static int exfat_find(struct inode *dir, struct qstr *qname, return num_entries; /* check the validation of hint_stat and initialize it if required */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) if (ei->version != (inode_peek_iversion_raw(dir) & 0xffffffff)) { #else if (ei->version != (dir->i_version & 0xffffffff)) { #endif ei->hint_stat.clu = cdir.dir; ei->hint_stat.eidx = 0; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) ei->version = (inode_peek_iversion_raw(dir) & 0xffffffff); #else ei->version = (dir->i_version & 0xffffffff); @@ -832,7 +851,7 @@ static struct dentry *exfat_lookup(struct inode *dir, struct dentry *dentry, out: mutex_unlock(&EXFAT_SB(sb)->s_lock); if (!inode) -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) exfat_d_version_set(dentry, inode_query_iversion(dir)); #else exfat_d_version_set(dentry, dir->i_version); @@ -890,12 +909,12 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry) ei->dir.dir = DIR_DELETED; exfat_set_vol_flags(sb, VOL_CLEAN); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) inode_inc_iversion(dir); #else dir->i_version++; #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) dir->i_mtime = dir->i_atime = current_time(dir); #else dir->i_mtime = dir->i_atime = CURRENT_TIME_SEC; @@ -906,13 +925,13 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry) mark_inode_dirty(dir); clear_nlink(inode); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) inode->i_mtime = inode->i_atime = current_time(inode); #else inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; #endif exfat_unhash_inode(inode); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) exfat_d_version_set(dentry, inode_query_iversion(dir)); #else exfat_d_version_set(dentry, dir->i_version); @@ -939,13 +958,13 @@ static int exfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) if (err) goto unlock; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) inode_inc_iversion(dir); #else dir->i_version++; #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) dir->i_ctime = dir->i_mtime = current_time(dir); #else dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; @@ -963,12 +982,12 @@ static int exfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) goto unlock; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) inode_inc_iversion(inode); #else inode->i_version++; #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) inode->i_mtime = inode->i_atime = inode->i_ctime = EXFAT_I(inode)->i_crtime = current_time(inode); #else @@ -1089,12 +1108,12 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry) ei->dir.dir = DIR_DELETED; exfat_set_vol_flags(sb, VOL_CLEAN); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) inode_inc_iversion(dir); #else dir->i_version++; #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) dir->i_mtime = dir->i_atime = current_time(dir); #else dir->i_mtime = dir->i_atime = CURRENT_TIME_SEC; @@ -1106,13 +1125,13 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry) drop_nlink(dir); clear_nlink(inode); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) inode->i_mtime = inode->i_atime = current_time(inode); #else inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; #endif exfat_unhash_inode(inode); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) exfat_d_version_set(dentry, inode_query_iversion(dir)); #else exfat_d_version_set(dentry, dir->i_version); @@ -1447,15 +1466,21 @@ out: return ret; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0) static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsigned int flags) +#else +static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry) +#endif { struct inode *old_inode, *new_inode; struct super_block *sb = old_dir->i_sb; loff_t i_pos; int err; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) /* * The VFS already checks for existence, so for local filesystems * the RENAME_NOREPLACE implementation is equivalent to plain rename. @@ -1463,6 +1488,7 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry, */ if (flags & ~RENAME_NOREPLACE) return -EINVAL; +#endif mutex_lock(&EXFAT_SB(sb)->s_lock); old_inode = old_dentry->d_inode; @@ -1472,12 +1498,12 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry, if (err) goto unlock; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) inode_inc_iversion(new_dir); #else new_dir->i_version++; #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) new_dir->i_ctime = new_dir->i_mtime = new_dir->i_atime = EXFAT_I(new_dir)->i_crtime = current_time(new_dir); #else @@ -1504,12 +1530,12 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry, inc_nlink(new_dir); } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) inode_inc_iversion(old_dir); #else old_dir->i_version++; #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir); #else old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME_SEC; @@ -1532,7 +1558,7 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry, "abnormal access to an inode dropped"); WARN_ON(new_inode->i_nlink == 0); } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) new_inode->i_ctime = EXFAT_I(new_inode)->i_crtime = current_time(new_inode); #else diff --git a/super.c b/super.c index d805bf57c646..b7f57665fa00 100644 --- a/super.c +++ b/super.c @@ -23,7 +23,7 @@ #include #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) #include #endif @@ -125,7 +125,11 @@ int exfat_set_vol_flags(struct super_block *sb, unsigned short new_flag) /* skip updating volume dirty flag, * if this volume has been mounted with read-only */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) if (sb_rdonly(sb)) +#else + if (sb->s_flags & MS_RDONLY) +#endif return 0; if (!sbi->pbr_bh) { @@ -505,7 +509,7 @@ static int exfat_read_root(struct inode *inode) inode->i_uid = sbi->options.fs_uid; inode->i_gid = sbi->options.fs_gid; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) inode_inc_iversion(inode); #else inode->i_version++; @@ -522,7 +526,7 @@ static int exfat_read_root(struct inode *inode) EXFAT_I(inode)->i_size_ondisk = i_size_read(inode); exfat_save_attr(inode, ATTR_SUBDIR); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) inode->i_mtime = inode->i_atime = inode->i_ctime = ei->i_crtime = current_time(inode); #else @@ -743,11 +747,15 @@ static int exfat_fill_super(struct super_block *sb, void *data, int silent) } #endif +#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; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) sb->s_time_gran = 1; sb->s_time_min = EXFAT_MIN_TIMESTAMP_SECS; sb->s_time_max = EXFAT_MAX_TIMESTAMP_SECS; @@ -792,7 +800,7 @@ static int exfat_fill_super(struct super_block *sb, void *data, int silent) root_inode->i_ino = EXFAT_ROOT_INO; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0) inode_set_iversion(root_inode, 1); #else root_inode->i_version = 1;