Skip to content

Commit e8d6063

Browse files
incardonincardon
andauthored
Refine Linux 6.x support (#34)
inode_set_ctime and inode_set_ctime_to_ts are unavailable in Linux 6.5.x but introduced in 6.6.x. Co-authored-by: Incardona Pietro <[email protected]>
1 parent 19acb71 commit e8d6063

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static int simplefs_write_end(struct file *file,
185185
/* Update inode metadata */
186186
inode->i_blocks = inode->i_size / SIMPLEFS_BLOCK_SIZE + 2;
187187

188-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
188+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
189189
cur_time = current_time(inode);
190190
inode->i_mtime = cur_time;
191191
inode_set_ctime_to_ts(inode, cur_time);

inode.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct inode *simplefs_iget(struct super_block *sb, unsigned long ino)
5555
i_gid_write(inode, le32_to_cpu(cinode->i_gid));
5656
inode->i_size = le32_to_cpu(cinode->i_size);
5757

58-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
58+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
5959
inode_set_ctime(inode, (time64_t) le32_to_cpu(cinode->i_ctime), 0);
6060
#else
6161
inode->i_ctime.tv_sec = (time64_t) le32_to_cpu(cinode->i_ctime);
@@ -214,7 +214,7 @@ static struct inode *simplefs_new_inode(struct inode *dir, mode_t mode)
214214
#endif
215215
set_nlink(inode, 1);
216216

217-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
217+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
218218
cur_time = current_time(inode);
219219
inode->i_atime = inode->i_mtime = cur_time;
220220
inode_set_ctime_to_ts(inode, cur_time);
@@ -256,7 +256,7 @@ static struct inode *simplefs_new_inode(struct inode *dir, mode_t mode)
256256
set_nlink(inode, 1);
257257
}
258258

259-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
259+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
260260
cur_time = current_time(inode);
261261
inode->i_atime = inode->i_mtime = cur_time;
262262
inode_set_ctime_to_ts(inode, cur_time);
@@ -394,7 +394,7 @@ static int simplefs_create(struct inode *dir,
394394
/* Update stats and mark dir and new inode dirty */
395395
mark_inode_dirty(inode);
396396

397-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
397+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
398398
cur_time = current_time(dir);
399399
dir->i_mtime = dir->i_atime = cur_time;
400400
inode_set_ctime_to_ts(dir, cur_time);
@@ -533,7 +533,7 @@ static int simplefs_unlink(struct inode *dir, struct dentry *dentry)
533533
goto clean_inode;
534534

535535
/* Update inode stats */
536-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
536+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
537537
cur_time = current_time(dir);
538538
dir->i_mtime = dir->i_atime = cur_time;
539539
inode_set_ctime_to_ts(dir, cur_time);
@@ -601,7 +601,7 @@ static int simplefs_unlink(struct inode *dir, struct dentry *dentry)
601601
i_gid_write(inode, 0);
602602
inode->i_mode = 0;
603603

604-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
604+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
605605
inode->i_mtime.tv_sec = inode->i_atime.tv_sec = 0;
606606
inode_set_ctime(inode, 0, 0);
607607
#else
@@ -743,7 +743,7 @@ static int simplefs_rename(struct inode *old_dir,
743743
brelse(bh2);
744744

745745
/* Update new parent inode metadata */
746-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
746+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
747747
cur_time = current_time(new_dir);
748748
new_dir->i_atime = new_dir->i_mtime = cur_time;
749749
inode_set_ctime_to_ts(new_dir, cur_time);
@@ -761,7 +761,7 @@ static int simplefs_rename(struct inode *old_dir,
761761
goto release_new;
762762

763763
/* Update old parent inode metadata */
764-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
764+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
765765
cur_time = current_time(old_dir);
766766
old_dir->i_atime = old_dir->i_mtime = cur_time;
767767
inode_set_ctime_to_ts(old_dir, cur_time);

super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static int simplefs_write_inode(struct inode *inode,
7070
disk_inode->i_gid = i_gid_read(inode);
7171
disk_inode->i_size = inode->i_size;
7272

73-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
73+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
7474
struct timespec64 ctime = inode_get_ctime(inode);
7575
disk_inode->i_ctime = ctime.tv_sec;
7676
#else

0 commit comments

Comments
 (0)