Fix incorrect timestamp assignment when writing inode#92
Conversation
jserv
left a comment
There was a problem hiding this comment.
Improve git commit messages per https://cbea.ms/git-commit/
|
@jserv Modified the commit message as requested. Thanks for your feedback. |
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. |
Instead of changing the title of this pull request on GitHub, you should reword the commit message using After running
This commit message violates the project's commit message guidelines. |
Thank you for the clarification. I misunderstood and thought you were referring to the pull request title and description. I've amended my commit and pushed the updated commit. Sorry for the misunderstanding, and thank you for pointing it out. |
Check https://cbea.ms/git-commit/ carefully and apply the rules. In particular, |
@jserv I wrapped the body and shortened the subject line and made some adjustments as you suggested. Thanks for the feedback. |
simplefs_write_inode() incorrectly assigns the modification time to the i_atime due to a typo. As a result, disk_inode->i_atime field on disk contains the modification time, while disk_inode->i_mtime is never updated and remains zero. Fix the timestamp assignments so that access time is written to disk_inode->i_atime and modification time is written to disk_inode->i_mtime.
|
Thank @EricKim27 for contributing! I amended the commit messages. |
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 incorrect timestamp assignment in
simplefs_write_inodefor kernel >= 6.7: write access time todisk_inode->i_atimeand modification time todisk_inode->i_mtimeinstead of writing both toi_atime. Preventsi_mtimefrom being left zero so files report the correct modification time instead of 1970-01-01.Written for commit d62bf18. Summary will update on new commits.