Skip to content

Library case fix uses link(), which fails with EOPNOTSUPP on /data #229

Open

Description

@pristmc-code

On a PS5 Pro, firmware 12.00, link() and linkat() on /data fail with errno 45 (EOPNOTSUPP): /data has no hard links.

repair_module_case_for_source() in src/sm_scan.c (0b56a1c, line 589) uses link() and then unlink() to give a library its case-correct name without replacing another file:

// link() publishes the new name atomically without replacing another file.
if (link(file->path, target) != 0) {
  if (errno == EEXIST) {
    ++conflicts;
  } else {
    ++failures;

For a folder game on /data (for example /data/homebrew/<game>/sce_module/...) this always takes the failures path, so the case fix never happens there. I found the EOPNOTSUPP in a fork that publishes other files the same way; I have not seen this specific function fail in upstream logs, since it needs a game folder whose library names differ only in case.

What we used: when link() fails with EOPNOTSUPP/ENOTSUP, check that the target does not exist (lstat -> ENOENT) and rename() instead. It loses the atomic no-replace guarantee, but the scan holds the folder and the case-only rename is in one directory:

int link_rc = link(file->path, target);
if (link_rc != 0 && (errno == EOPNOTSUPP || errno == ENOTSUP)) {
  struct stat existing;
  if (lstat(target, &existing) == 0) {
    errno = EEXIST;
  } else if (errno == ENOENT && rename(file->path, target) == 0) {
    /* renamed: update file->path, count it as fixed, continue */
  }
}

Not tested: this path on an exFAT image (read-only there anyway) or on case-insensitive storage, where lstat(target) finds the same file and it would count as a conflict. I can open a PR if you want it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions