ps2homebrew / pfsshell

Browse and edit PFS filesystems on APA-formatted hard drive
GNU General Public License v2.0
95 stars 22 forks source link

Drive File Descriptor : Invalid argument. #8

Closed zentasumu closed 5 years ago

zentasumu commented 5 years ago

First off, I've checked the file descriptor and it return nonzero.

Seems that read() and write() needs buffer sizes/count of 512 like so for it to succeed else it returns an invalid argument error.

Also lseek() allows seeking to non block sized offsets but it makes read() and write() return with invalid argument.

Removing lseek continued pfsshell on my chosen hard drive. Then I executed an initialize command afterwards. It was partially successful, as it only made the __mbr partition.

image

Hope this sheds some light on the situation.

Removing lseek makes the hdd_length zero so that explains the no space left error.

uyjulian commented 5 years ago

Thanks for the information. I may take a look into it at a later date.

Darkshadow2 commented 5 years ago

Hmm, that's a lot like the bug that kept it from getting the correct device size on macOS. I wonder if the ioctl code would work there?

zentasumu commented 5 years ago

Updated the post.

Using lseek, read and write only needs sizes/offset of 512, no alignment needed, sorry about that.

zentasumu commented 5 years ago

Also from how it looks like we really do have to use platform specific API when it comes to getting the hard drive info at least.

lseek works now but it doesn't return zero when it goes past the size of the drive, and just continues. I am not sure why its doing that.

zentasumu commented 5 years ago

Checked against the old pfsshell v0.2a. We were having an integer overflow all this time.

Made a pull request fixing this for Windows, while keeping it POSIX ;)

Link to pull request