Fix GetDents truncating the last character of filenames (#1610)

This commit is contained in:
Marcin Mikołajczyk 2024-11-28 21:25:37 +01:00 committed by GitHub
parent 471ebdb4f0
commit 286a288bfd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -537,14 +537,13 @@ static int GetDents(int fd, char* buf, int nbytes, s64* basep) {
} }
const auto& entry = file->dirents.at(file->dirents_index++); const auto& entry = file->dirents.at(file->dirents_index++);
auto str = entry.name; auto str = entry.name;
auto str_size = str.size() - 1;
static int fileno = 1000; // random static int fileno = 1000; // random
OrbisKernelDirent* sce_ent = (OrbisKernelDirent*)buf; OrbisKernelDirent* sce_ent = (OrbisKernelDirent*)buf;
sce_ent->d_fileno = fileno++; // TODO this should be unique but atm it changes maybe switch to a sce_ent->d_fileno = fileno++; // TODO this should be unique but atm it changes maybe switch to a
// hash or something? // hash or something?
sce_ent->d_reclen = sizeof(OrbisKernelDirent); sce_ent->d_reclen = sizeof(OrbisKernelDirent);
sce_ent->d_type = (entry.isFile ? 8 : 4); sce_ent->d_type = (entry.isFile ? 8 : 4);
sce_ent->d_namlen = str_size; sce_ent->d_namlen = str.size();
strncpy(sce_ent->d_name, str.c_str(), ORBIS_MAX_PATH); strncpy(sce_ent->d_name, str.c_str(), ORBIS_MAX_PATH);
sce_ent->d_name[ORBIS_MAX_PATH] = '\0'; sce_ent->d_name[ORBIS_MAX_PATH] = '\0';