mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 22:06:59 +01:00
kernel: report /dev/random and /dev/urandom as character devices (#1140)
kernel: report entropy sources as character devices Co-authored-by: nmzik <Nmzik@mail.ru>
This commit is contained in:
committed by
GitHub
parent
34f6fd1f5f
commit
de62664908
@@ -1138,19 +1138,11 @@ int KYTY_SYSV_ABI KernelFstat(int d, FileStat* sb) {
|
|||||||
auto wt = at;
|
auto wt = at;
|
||||||
|
|
||||||
if (file->special != SpecialFile::None) {
|
if (file->special != SpecialFile::None) {
|
||||||
|
stat.st_mode = 0020644u;
|
||||||
stat.st_size = 0;
|
stat.st_size = 0;
|
||||||
stat.st_blksize = 512;
|
stat.st_blksize = 512;
|
||||||
stat.st_blocks = 0;
|
stat.st_blocks = 0;
|
||||||
SecToTimespec(&stat.st_atim, at.ToUnix());
|
} else if (!file->directory) {
|
||||||
SecToTimespec(&stat.st_mtim, wt.ToUnix());
|
|
||||||
stat.st_ctim = stat.st_atim;
|
|
||||||
stat.st_birthtim = stat.st_mtim;
|
|
||||||
*sb = stat;
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!file->directory) {
|
|
||||||
file->mutex.Lock();
|
file->mutex.Lock();
|
||||||
|
|
||||||
bool is_invalid = file->f.IsInvalid();
|
bool is_invalid = file->f.IsInvalid();
|
||||||
|
|||||||
@@ -121,6 +121,20 @@ void CheckSaveRename(const std::filesystem::path &root,
|
|||||||
"renamed save contents");
|
"renamed save contents");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestRandomDevices() {
|
||||||
|
for (const auto* path : {"/dev/urandom", "/dev/random"}) {
|
||||||
|
const int fd = FileSystem::KernelOpen(path, 0, 0);
|
||||||
|
FileSystem::FileStat stat {};
|
||||||
|
Check(fd >= 3 && FileSystem::KernelFstat(fd, &stat) == OK &&
|
||||||
|
(stat.st_mode & 0170000) == 0020000,
|
||||||
|
"entropy sources are character devices");
|
||||||
|
std::array<uint8_t, 32> entropy {};
|
||||||
|
Check(FileSystem::KernelRead(fd, entropy.data(), entropy.size()) == entropy.size(),
|
||||||
|
"character device supplies requested entropy");
|
||||||
|
Check(FileSystem::KernelClose(fd) == OK, "close entropy source");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TestSaveOpenVisibility() {
|
void TestSaveOpenVisibility() {
|
||||||
constexpr char Path[] = "/savedata0/visible-save.dat";
|
constexpr char Path[] = "/savedata0/visible-save.dat";
|
||||||
constexpr char Payload[] = "saved progress";
|
constexpr char Payload[] = "saved progress";
|
||||||
@@ -1398,6 +1412,7 @@ int main(int, char**) {
|
|||||||
|
|
||||||
TempDirectory temporary;
|
TempDirectory temporary;
|
||||||
FileSystem::Initialize();
|
FileSystem::Initialize();
|
||||||
|
TestRandomDevices();
|
||||||
CheckMountRoot(temporary.Path());
|
CheckMountRoot(temporary.Path());
|
||||||
CheckUnmappedPaths(temporary.Path());
|
CheckUnmappedPaths(temporary.Path());
|
||||||
CheckArchiveMount(temporary.Path());
|
CheckArchiveMount(temporary.Path());
|
||||||
|
|||||||
Reference in New Issue
Block a user