Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cellSaveData: Check filename format of savedata files #11502

Merged
merged 13 commits into from
Feb 14, 2022

Conversation

elad335
Copy link
Contributor

@elad335 elad335 commented Feb 7, 2022

Offhanded yet loyal to proper PS3 emulation semantics fix for the problem mentioned in #11501.
PS3 savedata filenaming format is fortunately pretty limited. Only uppercase A-Z, _, space, dot and - are allowed. And only if fitting the notorious 8.3 naming length constraints.

@nastys
Copy link
Contributor

nastys commented Feb 7, 2022

Unfortunately, it doesn't fix #11501 (at least on macOS)
Schermata 2022-02-07 alle 17 42 44

@elad335
Copy link
Contributor Author

elad335 commented Feb 7, 2022

what is the content of your savedata?

@nastys
Copy link
Contributor

nastys commented Feb 7, 2022

% ls -al@
total 3840
drwxrwxrwx  1 nastys  staff  131072  6 Feb 23:28 .
drwxrwxrwx  1 nastys  staff  131072 12 Gen 23:48 ..
-rwxrwxrwx  1 nastys  staff    4096  7 Feb 16:52 ._PARAM.PFD
-rwxrwxrwx  1 nastys  staff    4096  7 Feb 16:48 ._PARAM.SFO
-rwxrwxrwx  1 nastys  staff    4096  7 Feb 13:27 ._SYSTEM.DAT
-rwxrwxrwx  1 nastys  staff   80968  6 Feb 23:28 ICON0.PNG
-rwxrwxrwx@ 1 nastys  staff   32768  6 Feb 23:33 PARAM.PFD
	com.apple.lastuseddate#PS	    16 
-rwxrwxrwx@ 1 nastys  staff    2736  6 Feb 23:28 PARAM.SFO
	com.apple.lastuseddate#PS	    16 
-rwxrwxrwx  1 nastys  staff  396540  6 Feb 23:28 PIC1.PNG
-rwxrwxrwx@ 1 nastys  staff  328944  6 Feb 23:33 SYSTEM.DAT
	com.apple.lastuseddate#PS	    16 

@elad335
Copy link
Contributor Author

elad335 commented Feb 7, 2022

The "._" prefixed ones are valid as PS3 savedata files, it may honestly need user modification because it is already user modified. Maybe a warning or semething should be shown idk.

@MSuih
Copy link
Member

MSuih commented Feb 7, 2022

While they could be valid we don't have any indication of them ever being used by the real console. Same deal as with using nul as filename or having two files with same name but different case. The problem is that this isn't caused by user modification, it is from system modification and it might be hard for user to remove those files or prevent them from being created.

The only way to "properly" fix cases like these is implement our own file system and just show it as a binary blob to the host OS. But I don't think anyone wants to do that and thus the best solution we can do is to add workarounds for individual cases such as these.

@nastys
Copy link
Contributor

nastys commented Feb 7, 2022

How about checking the file contents?
e.g. all resource forks start with 00 05 16 07 00 02 00 00 4D 61 63 20 4F 53 20 58, I believe, and the magic number for .DS_Store is on Wikipedia.
If it's a match, exclude it and/or warn.
Or just add an option that can be toggled per-game.

@Megamouse Megamouse added Firmware: HLE Savedata Anything that involves cellSaveData labels Feb 7, 2022
@nastys
Copy link
Contributor

nastys commented Feb 7, 2022

For reference, I've updated #11501 with magic number checks.

@elad335
Copy link
Contributor Author

elad335 commented Feb 7, 2022

*.DS_Store, desktop.ini, Thumbs.db etc are hidden in this pr. Just the peculiar ._ prefixed stuff are unhidden because they might be valid PS3 savedata, and no amount of data checks will change it. It just need at best to warn users on macOS when such files are found.

{
continue;
}

size_kbytes += ::narrow<u32>((entry.size + 1023) / 1024); // firmware rounds this value up
}

*sizeKB = size_kbytes;
*sizeKB = size_kbytes + 35;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nani?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

statGet->sysSizeKB = 35; // always reported as 35 regardless of actual file sizes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why not add a comment or whatever

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Nekotekina Nekotekina merged commit fd6c339 into RPCS3:master Feb 14, 2022
@elad335 elad335 deleted the rrr branch September 19, 2022 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Firmware: HLE Savedata Anything that involves cellSaveData
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants