fs/ext: Support RO_COMPAT_EXTRA_ISIZE #446
Merged
Burer
merged 4 commits from 2026-06-24 10:31:25 +00:00
Matou1306/kolibrios:ext-improvements into main
Dismiss Review
Are you sure you want to dismiss this review?
Labels
Clear labels
Influence/Text/TYPO
AI
Eolite
FS
GSoC
Good First PR
HLL
HardwareTested
IRCC
Influence/Settings
Lang/C
Lang/FASM
Pay for the code
Subsystem/API
Subsystem/Audio
Subsystem/Graphics
Subsystem/IPC and events
Subsystem/Memory
Subsystem/Network
Subsystem/Services(daemon)
Subsystem/Taskmanager
Subsystem/VFS
Subsystem/Window
This issue or PR in the Google Source of Code program
The issue is suitable to beginners
Paid task
infinity service, audio drivers, midi, speacker, audio programs
vesa, vga, framebuffer, cursors, blitter, and video drivers
pipes, signals, events, shared memory
virt and phys memory allocators, malloc and other
userspace and kernel(for example: serial) services
process, threads, run apps, scheduler
drivers from filesystem, fs api, blkdev, programs that work with the file system
windows, skins, buttons, mouse and keyboard code for windows (not the base code)
Category
Applications
Category
Drivers
Category
General
Category
Kernel
Category
Libraries
Kind
Breaking
Breaking change that won't be backward compatible
Kind
Bug
Something is not working
Kind
Build
Kind
Documentation
Documentation changes
Kind
Enhancement
Improve existing functionality
Kind
Feature
New functionality
Kind
Security
This is security issue
Kind
Testing
Issue or pull request related to testing
PR
Ready to merge
Pull request is ready for merge
PR
Conflicts
PR conflicts with main
PR
Dependent
This PR is dependent on another PR
PR
Request changes
Changes requested in pull request
PR
Review required
Priority
Critical
1
The priority is critical
Priority
High
2
The priority is high
Priority
Medium
3
The priority is medium
Priority
Low
4
The priority is low
Reviewed
Confirmed
Issue has been confirmed
Reviewed
Duplicate
This issue or pull request already exists
Reviewed
Invalid
Invalid issue
Reviewed
Won't Fix
This issue won't be fixed
Status
Abandoned
Somebody has started to work on this but abandoned work
Status
Blocked
Something is blocking this issue or pull request
Status
Need More Info
Feedback is required to reproduce issue or to continue work
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: KolibriOS/kolibrios#446
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
This commit provides support for 0x0040 RO_COMPAT_EXTRA_ISIZE.
Umka reading t072 and writing t074 tests are done and passing.
WIP: Support RO_COMPAT_EXTRA_ISIZEto WIP: fs/ext: Support RO_COMPAT_EXTRA_ISIZE@@ -14,2 +14,4 @@; out:; eax, ebx = return values for sysfunc 70UNIXTIME_TO_KOS_OFFSET = (365*31+8)*24*60*60 ; 01.01.1970 to 01.01.2001This constant will be useful for several filesystem's, e.g. XFS. It is a good idea to move it to a common place like fs/fs_lfn.inc or fs/fs_common.inc
@@ -157,0 +178,4 @@MOUNT_POLICY_NOATIME = 0MOUNT_POLICY_ATIME = 1MOUNT_POLICY_RELATIME = 2MOUNT_POLICY = MOUNT_POLICY_NOATIME ; TODO: add proper mount syscallI believe, this should be a per-partition setting, i.e. a field in the EXTFS structure
@@ -161,0 +184,4 @@; 1 = sparse superblock; 2 = 64-bit file size; 40 = extra inode size (WIP)READ_ONLY_SUPPORT = 43This must be hex. Same above
@@ -904,2 +930,2 @@add eax, 978307200mov [edi+INODE.inodeModified], eaxlea eax, [edi+INODE.cTime]mov edx, -1Does this add 0x3fff_ffff nanoseconds? Shouldn't we add 0 ns if the field is missing?
This is just like a flag I made for ext_write_time, the function checks if the extra field is -1 to know if the field doesn't exit to not touch it.
Also I am ignoring nanoseconds (writing it as 0) if that's ok? To get nanoseconds I will have to call an additional system function if I understand correctly.
It is ok to write just seconds. I doubt any other filesystem in KolibriOS writes nanoseconds at the moment.
@@ -1986,0 +2099,4 @@@@:jmp ext_read_time.has_all_extra:; fast path: all Extra fields up to crTimeExtra are presentDo I understand correctly the inode size can only be a power of two? I.e. either no extra time is present or all of them are present?
inode_size itself is indeed a power of 2, but the real boundary is the i_extra_isize field at offset 128d: this is the one that specifies the number of extra bytes.
This part of the code is just a shortcut if extra_isize is large enough to contain all extra time fields, it'll skip checking 4 times. If not all fields are present then it will go the slow path checking every field.
I don't know why any partition in the world would have one extra time field but not the other since inode size is either 128 or 256+ which will always fit all of them, but there is no constraint on it, that's why I made the long path of checking before each field. Also extra_isize itself can be different across different inodes, which is why I made the check here instead of global.
711708ad49to80163f0cbecffb9f6f24todf264189adI think this should be ready now, it passes umka tests too.
I will clean up and rebase the commits if no more edits are required
The code looks good but this PR has 21 commits including other people's commits. Rebase and force push the branch and it should be ok to merge to main then.
9c6a69ed8etodcd7b68b57@dunkaist Done
@Matou1306
Please, check this points.
Some of them could be fake alerts, but I believe most is real problems.
🔴 readInode:
i_extra_isizeis copied unclamped, so an on-disk value >32 overflows the inode struct and makes32 - extra_isizeunderflow into a hugerep stosbwhich leads to kernel memory corruption from untrusted metadata.🟠 unlinkInode: updates
mTimein the buffer but never callswriteInode, so the directory's mtime change is lost (unlikelinkInode, which does write it).🟠 ext_ReadFolder: calls
update_aTimeon every sub-entry inode, updating each listed file's atime (a directory listing shouldn't touch every file's atime) and causing one inode write per entry.🟠 MOUNT_POLICY: the
db MOUNT_POLICY_NOATIMEstruct initializer has no effect on the dynamically-allocated partition struct - it only works because NOATIME==0 and the struct is zero-allocated.🟠 symlink_depth: narrowing it to
dbwhile leaving three dword-width accesses (init/dec/cmp) makes those writes spill into the adjacentMOUNT_POLICYbyte and past the struct - fix by keeping itddor changing the three accesses to byte-width.@Burer I implemented your suggestions thanks for that, they pass umka tests.
However, while testing this out on qemu, I found out there is another bug that corrupts everything when I create a new file. I am still uncovering the issue but it corrupts creating files (sometimes creates folders instead, sometimes gives them random file sizes).
The tests were not sufficient I guess... I will fix these issues asap and make sure to also test interactively on qemu in the future.
@Burer @dunkaist I pushed a commit that should fix the bug, I just forgot to reload ebx after calling ext_write_time. I updated it so that the proc uses edi esi ebx to push/pop them instead. I created a new t076 for umka which tests ext create file, which used to fail on the code one commit ago but is now succeeding. I also tried testing on qemu, created a file, edited a file, and it works normally now. Please take a look.
b39dce6b55to21a56f5862Hi, @Matou1306
Great work!
Now I can see only a few small problems, check them also, please:
🟠
update_aTime: routes atime updates throughwriteInode, which always stampscTime=now, so an atime refresh on read also bumps ctime - should be fixed before enabling atime by writing only the atime field instead of the whole inode.🟡
ext_CreateFile/ext_CreateFolder: zeroes the inode and setaTime/mTimebut never setcrTimeori_extra_isize, so files created on anextra_isizevolume get no creation time and no sub-second fields (extra_isizestays 0).🟡
ext_write_time: writes only the epoch bits (and edx, 3) into*_time_extra, zeroing the nanosecond field on every timestamp update, so any sub-second precision set by Linux is dropped.@Burer Thanks, I will work on them.
For the first one when I updated the code I stuck with the previous structure which updated time fields in write_Inode. Linux does it very differently by having another process write it asynchronously, for KolibriOS I think I can just input a flag to the function that decides whether to update cTime or not.
Regarding sub-second fields we are only writing the seconds, saving the old nanosecond field would be meaningless I guess because we already updated the timestamp. Say the old time was 13:43:13.02341 then we update it to 21:34:50 saving those 0.02341 would actually be incorrect here (?)
@Matou1306
It's up to you and your mentor to decide support nanoseconds or not.
I agree that this is not crucial for KOS and can be skipped.
Just listed all found problems for your information.
I think nanoseconds can be ignored/zeroed for KolibriOS.
21a56f5862tob8d304125a@Burer I worked on the first 2 points, for the nanoseconds as @dunkaist mentioned we will be ignoring it.
@Matou1306
Seems good to me!
But one small latent bug was introduced in latest commits.
writeInode_no_cTimeskips themov edi, ebxthat sets up the inode-buffer pointer:So when entered via
writeInode_no_cTime, edi keeps the caller's leftover value instead of pointing at the inode buffer. The root-inode cache update then reuses it:Writing the root inode through
writeInode_no_cTimetherefore corrupts the cached root inode.It is not triggered today, as the only caller is
update_aTime, which never writes the root inode (ReadFile rejects directories). But it is a latent trap for any futureno_cTimewrite of the root inode.Fix should be simple - move
mov edi, ebxabove thecmp edx, -1soediis always initialized, as it was before this commit.b8d304125ato7788c14683@Burer Thanks for catching that!
When I looked at it the first time I didn't think of it much and thought it was some preparation for
fsGetTimecall 😐.@Matou1306
Thanks you for accurate work!
7788c14683tofb63b9c5adfb63b9c5adto4215cdcee3