When copying file pages back and forth, we need both dst and src
offsets since the cursor offset and read/write buffer page offsets
are different. This is now fixed.
Also done some mods to close().
- Added logic to calculate which pages are in the file and which are new
for writing.
- Nearly finished the template for sys_write.
- Need to implement write_cache_pages().
- Need to distinguish dirty/clean pages and implement flushing dirty
pages back to vfs.
sys_timer accumulates timer ticks into seconds, minutes, hours and days.
It's left to the user to calculate from days into a date. It is not yet
known if the calculation is even roughly correct.
Reduced 2 kmem_reclaim/grant calls into one kmem_control call.
close() needs to flush dirty buffers.
pager needs to have read/write support properly implemented.
open() needs to record mode and access times.
The need for access times means we need rtc and time implementation.
Also need to add stat() access() etc.
Input paths are now parsed at the beginning and components
put into an ordered linked list headed by struct pathdata.
Lookup functions use these components to look up vnodes.
Factored out mapping of the physical page as the final generic code
after all fault-specific handling is done.
Fixed the error that zero page didn't have an owner (devzero).
Fixed the error that struct dirent did not have the record length
field as u16 as expected by userspace.
Normally anon && shared pages need to COW once and any newer
accesses by other sharing processes should simply map the COW'ed
pages to themselves as writeable. We didn't have that but instead
every ANON && SHARED write fault was going into the COW path, causing
the same offset'ed page to be COW'ed twice.
Next: Factor out the l4_map code to a common point at the end of all
fault handling paths.
Dirbuf allocation was broken, fixed it.
Added more comments on reading directories.
Issues: fs0 ought to check buf address for sys_readdir(). Currently
test0 is passing an area on its stack and fs0 is writing the data to its own
address space (i.e. an area on its own stack.)
Separated vfs file as a specific file. vm file is not always a vfs file.
Updated the README
sys_open was not returning back to client, added that.
Added comments for future vfs additions.
Removed some commented out code.
Removed excessive printfs.
Fixed spid not initialising for mm0
Fixed some faults with fs0.
TODO:
- Need to store vfs files in a separate list.
- Need to define vnum as a vfs-file-specific data, i.e. in priv_data field of vm_file.
- Need to then fix vfs_receive_sys_open.
- fixed is_err(x), was evaluating x twice, resulting in calling a
function x twice.
- Divided task initialisation into multiple parts.
- MM0 now creates a tcb for itself and maintains memory regions of its own.
- MM0's tcb is used for mmapping other tasks' regions. MM0 mmaps and prefaults
those regions, instead of the typical mmap() and fault approach used by
non-pager tasks.
For example there's an internal shmget_shmat() path to map in other tasks'
shm utcbs. Those mappings are then prefaulted into mm0's address space using
the default fault handling path.
- FS0 now reads task data into its utcb from mm0 via a syscall.
FS0 shmat()s to utcbs of other tasks, e.g. mm0 and test0.
FS0 then crashes, that is to be fixed and where this commit is left last.