Skip to content

fix(vfs/posix): various vfs fixes for Linux#4039

Open
AvarianKnight wants to merge 1 commit into
citizenfx:masterfrom
AvarianKnight:fix/linux-rw
Open

fix(vfs/posix): various vfs fixes for Linux#4039
AvarianKnight wants to merge 1 commit into
citizenfx:masterfrom
AvarianKnight:fix/linux-rw

Conversation

@AvarianKnight

Copy link
Copy Markdown
Contributor

While trying to find what could possibly cause files on disk to become corrupted on Linux I started going through the VFS implementation for Linux and noticed a few issues.

This fixes a few issues here:

Read/ReadBulk/Write don't try to loop until all of their bytes are written

RenameFile returns 0 on success, while we were checking if it was successful by checking if it was != 0

GetLength was still reading the buf even though there isn't valid data in it.

See:

https://man7.org/linux/man-pages/man2/write.2.html https://man7.org/linux/man-pages/man2/read.2.html
https://man7.org/linux/man-pages/man2/pread.2.html https://man7.org/linux/man-pages/man3/fstat.3p.html https://man7.org/linux/man-pages/man2/rename.2.html

This PR applies to the following area(s)

Server

Successfully tested on

Game builds: ..

Platforms: Linux

Checklist

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

@github-actions github-actions Bot added triage Needs a preliminary assessment to determine the urgency and required action invalid Requires changes before it's considered valid and can be (re)triaged and removed triage Needs a preliminary assessment to determine the urgency and required action labels Jun 17, 2026
Comment thread code/components/vfs-impl-server/src/PlatformDevice.Posix.cpp Outdated
Comment thread code/components/vfs-impl-server/src/PlatformDevice.Posix.cpp Outdated
Comment thread code/components/vfs-impl-server/src/PlatformDevice.Posix.cpp
@AvarianKnight

Copy link
Copy Markdown
Contributor Author

Question, for the Read calls if we get an error code should we return what we have already, or should we return -1 since it is a failure

@AvarianKnight

Copy link
Copy Markdown
Contributor Author

Other issues here have been fixed. I will build this later today to double check that everything works.

@AvarianKnight AvarianKnight force-pushed the fix/linux-rw branch 2 times, most recently from 39b6139 to 25ef03a Compare June 18, 2026 18:44
While trying to find what could possibly cause files on disk to become corrupted
on Linux I started going through the VFS implementation for Linux and noticed
a few issues.

This fixes a few issues here:

Read/ReadBulk/Write don't try to loop until all of their bytes are written

RenameFile returns `0` on success, while we were checking if it was successful
by checking if it was `!= 0`

GetLength was still reading the buf even though there isn't valid data in it.

Fixes a bug where in certain cases where readdir would return `NULL` we never
released the `DIR` file handle

See:

https://man7.org/linux/man-pages/man2/write.2.html
https://man7.org/linux/man-pages/man2/read.2.html
https://man7.org/linux/man-pages/man2/pread.2.html
https://man7.org/linux/man-pages/man3/fstat.3p.html
https://man7.org/linux/man-pages/man2/rename.2.html
https://man7.org/linux/man-pages/man3/readdir.3.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid Requires changes before it's considered valid and can be (re)triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants