mirror of
https://github.com/SysRay/psOff_public.git
synced 2024-11-27 08:30:25 +00:00
Move initialization of /dev/zero and /dev/null, meet POSIX standard
This commit is contained in:
parent
7dfd4a8140
commit
22bdeaf03d
@ -90,8 +90,6 @@ class FileManager: public IFileManager {
|
||||
assert(addFile(createType_in(), "/dev/stdin") == 0);
|
||||
assert(addFile(createType_out(SCE_TYPEOUT_ERROR), "/dev/stdout") == 1);
|
||||
assert(addFile(createType_out(SCE_TYPEOUT_DEBUG), "/dev/stderr") == 2);
|
||||
addFile(createType_zero(), "/dev/zero");
|
||||
addFile(createType_null(), "/dev/null");
|
||||
}
|
||||
|
||||
void addMountPoint(std::string_view mountPoint, std::filesystem::path const& root, MountType type) final {
|
||||
|
@ -24,7 +24,7 @@ std::unique_ptr<IFile> createType_null() {
|
||||
}
|
||||
|
||||
size_t TypeNull::read(void* buf, size_t nbytes) {
|
||||
return nbytes;
|
||||
return -1;
|
||||
}
|
||||
|
||||
size_t TypeNull::write(void* buf, size_t nbytes) {
|
||||
|
@ -30,7 +30,7 @@ size_t TypeZero::read(void* buf, size_t nbytes) {
|
||||
}
|
||||
|
||||
size_t TypeZero::write(void* buf, size_t nbytes) {
|
||||
return 0;
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
void TypeZero::sync() {}
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "core/fileManager/types/type_file.h"
|
||||
#include "core/fileManager/types/type_random.h"
|
||||
#include "core/fileManager/types/type_rng.h"
|
||||
#include "core/fileManager/types/type_null.h"
|
||||
#include "core/fileManager/types/type_zero.h"
|
||||
#include "core/memory/memory.h"
|
||||
#include "logging.h"
|
||||
|
||||
@ -37,6 +39,10 @@ std::unique_ptr<IFile> createType_dev(std::filesystem::path path, std::ios_base:
|
||||
return createType_random();
|
||||
} else if (path == "/dev/rng") {
|
||||
return createType_rng();
|
||||
} else if (path == "/dev/zero") {
|
||||
return createType_zero();
|
||||
} else if (path == "/dev/null") {
|
||||
return createType_null();
|
||||
} else { // todo: other devices
|
||||
LOG_CRIT(L"%S: unknown device!", path.c_str());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user