You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently there is a lot of unneeded code in our file system handling which is left over from RepyV2's file interface.
One good thing to address to start with is to remove a lot of unneeded code in Emulfile. Since this is only being called by RustPOSIX with names like linddata.XXX, etc. and operates on a directory it is assumed to control, it really doesn't need most of this checking. I propose this function is changed to only open the file descriptor and set up the object without making any other system calls.
One complication for this plan is how lseek relies on filesize, which is set in this function. One option would be to simply lseek everytime this is called, but this would be inefficient because most lseeks in a program are likely within the file bounds.
To have an efficient solution for this problem without recording the actual file size, I propose that filesize is changed to something like sizeisatleast and for lseek to be called to check if you seek to a position greater than sizeisatleast. This way, a minimal number of lseek operations need to be performed on a file descriptor, while one will not seek past the end of file during a call to write, read, etc.
Of course ftruncate and truncate also need to be modified to update sizeisatleast. fstat also should likely be modified in this case since it reads the actual file size from disk.
The text was updated successfully, but these errors were encountered:
Currently there is a lot of unneeded code in our file system handling which is left over from RepyV2's file interface.
One good thing to address to start with is to remove a lot of unneeded code in Emulfile. Since this is only being called by RustPOSIX with names like linddata.XXX, etc. and operates on a directory it is assumed to control, it really doesn't need most of this checking. I propose this function is changed to only open the file descriptor and set up the object without making any other system calls.
One complication for this plan is how lseek relies on filesize, which is set in this function. One option would be to simply lseek everytime this is called, but this would be inefficient because most lseeks in a program are likely within the file bounds.
To have an efficient solution for this problem without recording the actual file size, I propose that filesize is changed to something like sizeisatleast and for lseek to be called to check if you seek to a position greater than sizeisatleast. This way, a minimal number of lseek operations need to be performed on a file descriptor, while one will not seek past the end of file during a call to write, read, etc.
Of course ftruncate and truncate also need to be modified to update sizeisatleast. fstat also should likely be modified in this case since it reads the actual file size from disk.
The text was updated successfully, but these errors were encountered: