Skip to content

Fix incorrect timestamp assignment when writing inode#92

Open
EricKim27 wants to merge 1 commit into
sysprog21:masterfrom
EricKim27:clean_base
Open

Fix incorrect timestamp assignment when writing inode#92
EricKim27 wants to merge 1 commit into
sysprog21:masterfrom
EricKim27:clean_base

Conversation

@EricKim27

@EricKim27 EricKim27 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

fix simplefs_write_inode to write the access time into disk_inode->i_atime and the modification time into disk_inode->i_mtime correctly.

After an inode has been modified or created, simplefs_write_inode(assigned to write_inode in simplefs_super_ops) is called to write the contents in the vfs inode to the relevant raw inode on disk. Because of a typo in simplefs_write_inode, i_atime gets assigned twice; once for writing access time, and again for writing modification time to it.

As a result, the raw inode metadata contains modification time on its access time field, and the modification time is never updated. Upon calling system calls like stat(), it returns modification time as access time, and an incorrect modification time(since it is never updated, and all bytes are zeroed out at mkfs, it defaults to 0, January 1st, 1970 in unix time).

Fix the assignments so access time is written to i_atime field and modification time is written to i_mtime field on on-disk inode structure.


Summary by cubic

Fixes mtime not updating by correcting a typo in super.c: write to i_mtime instead of i_atime in simplefs_write_inode for kernel >= 6.7. Files now record and show the correct modification time instead of 1970-01-01.

Written for commit 94e6f18. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@jserv jserv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve git commit messages per https://cbea.ms/git-commit/

@EricKim27 EricKim27 changed the title fix: fix mtime from not updating correctly Fix simplefs_write_inode to write modification and access time correctly to disk inode Jul 22, 2026
@EricKim27

EricKim27 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@jserv Modified the commit message as requested. Thanks for your feedback.

@jserv

jserv commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Modified the commit message as requested.

Check https://cbea.ms/git-commit/ carefully and improve git commit messages to address motivations and considerations.

@EricKim27 EricKim27 changed the title Fix simplefs_write_inode to write modification and access time correctly to disk inode Fix incorrect timestamp assignment when writing inode Jul 22, 2026
@EricKim27

EricKim27 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Modified the commit message as requested.

Check https://cbea.ms/git-commit/ carefully and improve git commit messages to address motivations and considerations.

I read the article you provided to me and improved the messages that would address my motivations and considerations. Thanks for the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants