mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-06 00:40:11 +00:00
sys_fs_open() update, octal formatting
This commit is contained in:
parent
0fc6ec2df9
commit
139173caa0
@ -42,12 +42,12 @@ struct FsRingBufferConfig
|
||||
|
||||
s32 cellFsOpen(vm::ptr<const char> path, s32 flags, vm::ptr<u32> fd, vm::ptr<const void> arg, u64 size)
|
||||
{
|
||||
cellFs.Warning("cellFsOpen(path=*0x%x, flags=%d, fd=*0x%x, arg=*0x%x, size=0x%llx) -> sys_fs_open()", path, flags, fd, arg, size);
|
||||
cellFs.Warning("cellFsOpen(path=*0x%x, flags=%#o, fd=*0x%x, arg=*0x%x, size=0x%llx) -> sys_fs_open()", path, flags, fd, arg, size);
|
||||
|
||||
// TODO
|
||||
|
||||
// call the syscall
|
||||
return sys_fs_open(path, flags, fd, {}, arg, size);
|
||||
return sys_fs_open(path, flags, fd, flags & CELL_FS_O_CREAT ? CELL_FS_S_IRUSR | CELL_FS_S_IWUSR : 0, arg, size);
|
||||
}
|
||||
|
||||
s32 cellFsRead(PPUThread& CPU, u32 fd, vm::ptr<void> buf, u64 nbytes, vm::ptr<u64> nread)
|
||||
@ -118,9 +118,9 @@ s32 cellFsFstat(u32 fd, vm::ptr<CellFsStat> sb)
|
||||
return sys_fs_fstat(fd, sb);
|
||||
}
|
||||
|
||||
s32 cellFsMkdir(vm::ptr<const char> path, CellFsMode mode)
|
||||
s32 cellFsMkdir(vm::ptr<const char> path, s32 mode)
|
||||
{
|
||||
cellFs.Warning("cellFsMkdir(path=*0x%x, mode=%d) -> sys_fs_mkdir()", path, mode);
|
||||
cellFs.Warning("cellFsMkdir(path=*0x%x, mode=%#o) -> sys_fs_mkdir()", path, mode);
|
||||
|
||||
// TODO
|
||||
|
||||
@ -209,9 +209,9 @@ s32 cellFsFtruncate(u32 fd, u64 size)
|
||||
return sys_fs_ftruncate(fd, size);
|
||||
}
|
||||
|
||||
s32 cellFsChmod(vm::ptr<const char> path, CellFsMode mode)
|
||||
s32 cellFsChmod(vm::ptr<const char> path, s32 mode)
|
||||
{
|
||||
cellFs.Warning("cellFsChmod(path=*0x%x, mode=%d) -> sys_fs_chmod()", path, mode);
|
||||
cellFs.Warning("cellFsChmod(path=*0x%x, mode=%#o) -> sys_fs_chmod()", path, mode);
|
||||
|
||||
// TODO
|
||||
|
||||
@ -539,7 +539,7 @@ int sdata_unpack(const std::string& packed_file, const std::string& unpacked_fil
|
||||
|
||||
s32 cellFsSdataOpen(PPUThread& CPU, vm::ptr<const char> path, s32 flags, vm::ptr<u32> fd, vm::ptr<const void> arg, u64 size)
|
||||
{
|
||||
cellFs.Log("cellFsSdataOpen(path=*0x%x, flags=%d, fd=*0x%x, arg=*0x%x, size=0x%llx)", path, flags, fd, arg, size);
|
||||
cellFs.Log("cellFsSdataOpen(path=*0x%x, flags=%#o, fd=*0x%x, arg=*0x%x, size=0x%llx)", path, flags, fd, arg, size);
|
||||
|
||||
if (flags != CELL_FS_O_RDONLY)
|
||||
{
|
||||
@ -569,7 +569,7 @@ s32 cellFsSdataOpen(PPUThread& CPU, vm::ptr<const char> path, s32 flags, vm::ptr
|
||||
|
||||
s32 cellFsSdataOpenByFd(u32 mself_fd, s32 flags, vm::ptr<u32> sdata_fd, u64 offset, vm::ptr<const void> arg, u64 size)
|
||||
{
|
||||
cellFs.Todo("cellFsSdataOpenByFd(mself_fd=0x%x, flags=%d, sdata_fd=*0x%x, offset=0x%llx, arg=*0x%x, size=0x%llx)", mself_fd, flags, sdata_fd, offset, arg, size);
|
||||
cellFs.Todo("cellFsSdataOpenByFd(mself_fd=0x%x, flags=%#o, sdata_fd=*0x%x, offset=0x%llx, arg=*0x%x, size=0x%llx)", mself_fd, flags, sdata_fd, offset, arg, size);
|
||||
|
||||
// TODO:
|
||||
|
||||
|
@ -20,19 +20,13 @@
|
||||
|
||||
SysCallBase sys_fs("sys_fs");
|
||||
|
||||
s32 sys_fs_open(vm::ptr<const char> path, s32 flags, vm::ptr<u32> fd, CellFsMode mode, vm::ptr<const void> arg, u64 size)
|
||||
s32 sys_fs_open(vm::ptr<const char> path, s32 flags, vm::ptr<u32> fd, s32 mode, vm::ptr<const void> arg, u64 size)
|
||||
{
|
||||
sys_fs.Warning("sys_fs_open(path=*0x%x, flags=%d, fd=*0x%x, mode=%d, arg=*0x%x, size=0x%llx)", path, flags, fd, mode, arg, size);
|
||||
sys_fs.Warning("sys_fs_open(path=*0x%x, flags=%#o, fd=*0x%x, mode=%#o, arg=*0x%x, size=0x%llx)", path, flags, fd, mode, arg, size);
|
||||
sys_fs.Warning("*** path = '%s'", path.get_ptr());
|
||||
|
||||
std::shared_ptr<vfsStream> file;
|
||||
|
||||
if (mode)
|
||||
{
|
||||
sys_fs.Error("sys_fs_open(): unknown mode (%d)", mode);
|
||||
//return CELL_FS_EINVAL;
|
||||
}
|
||||
|
||||
// TODO: other checks for path
|
||||
|
||||
if (Emu.GetVFS().ExistsDir(path.get_ptr()))
|
||||
@ -48,10 +42,40 @@ s32 sys_fs_open(vm::ptr<const char> path, s32 flags, vm::ptr<u32> fd, CellFsMode
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsRead));
|
||||
break;
|
||||
}
|
||||
//case CELL_FS_O_WRONLY:
|
||||
//case CELL_FS_O_WRONLY | CELL_FS_O_CREAT:
|
||||
|
||||
case CELL_FS_O_WRONLY:
|
||||
{
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsWriteAppend));
|
||||
|
||||
if (file)
|
||||
{
|
||||
file->Seek(0);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CELL_FS_O_WRONLY | CELL_FS_O_CREAT:
|
||||
{
|
||||
Emu.GetVFS().CreateFile(path.get_ptr());
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsWriteAppend));
|
||||
|
||||
if (file)
|
||||
{
|
||||
file->Seek(0);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CELL_FS_O_WRONLY | CELL_FS_O_APPEND:
|
||||
{
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsWriteAppend));
|
||||
break;
|
||||
}
|
||||
|
||||
case CELL_FS_O_WRONLY | CELL_FS_O_CREAT | CELL_FS_O_EXCL:
|
||||
case CELL_FS_O_RDWR | CELL_FS_O_CREAT | CELL_FS_O_EXCL: // ???
|
||||
{
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsWriteExcl));
|
||||
|
||||
@ -62,6 +86,7 @@ s32 sys_fs_open(vm::ptr<const char> path, s32 flags, vm::ptr<u32> fd, CellFsMode
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CELL_FS_O_WRONLY | CELL_FS_O_CREAT | CELL_FS_O_TRUNC:
|
||||
{
|
||||
Emu.GetVFS().CreateFile(path.get_ptr());
|
||||
@ -75,30 +100,37 @@ s32 sys_fs_open(vm::ptr<const char> path, s32 flags, vm::ptr<u32> fd, CellFsMode
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsWriteAppend));
|
||||
break;
|
||||
}
|
||||
|
||||
case CELL_FS_O_RDWR:
|
||||
{
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsReadWrite));
|
||||
break;
|
||||
}
|
||||
|
||||
case CELL_FS_O_RDWR | CELL_FS_O_CREAT:
|
||||
{
|
||||
Emu.GetVFS().CreateFile(path.get_ptr());
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsReadWrite));
|
||||
break;
|
||||
}
|
||||
//case CELL_FS_O_RDWR | CELL_FS_O_CREAT | CELL_FS_O_EXCL:
|
||||
//case CELL_FS_O_RDWR | CELL_FS_O_CREAT | CELL_FS_O_TRUNC:
|
||||
|
||||
case CELL_FS_O_RDWR | CELL_FS_O_CREAT | CELL_FS_O_TRUNC:
|
||||
{
|
||||
Emu.GetVFS().CreateFile(path.get_ptr(), true);
|
||||
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsReadWrite));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
sys_fs.Error("sys_fs_open(): invalid or unimplemented flags (%d)", flags);
|
||||
sys_fs.Error("sys_fs_open(): invalid or unimplemented flags (%#o)", flags);
|
||||
return CELL_FS_EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!file || !file->IsOpened())
|
||||
{
|
||||
sys_fs.Error("sys_fs_open(): failed to open '%s' (flags=%d, mode=%d)", path.get_ptr(), flags, mode);
|
||||
sys_fs.Error("sys_fs_open(): failed to open '%s' (flags=%#o, mode=%#o)", path.get_ptr(), flags, mode);
|
||||
return CELL_FS_ENOENT;
|
||||
}
|
||||
|
||||
@ -169,6 +201,7 @@ s32 sys_fs_opendir(vm::ptr<const char> path, vm::ptr<u32> fd)
|
||||
|
||||
if (!directory || !directory->IsOpened())
|
||||
{
|
||||
sys_fs.Error("sys_fs_opendir(): failed to open '%s'", path.get_ptr());
|
||||
return CELL_FS_ENOENT;
|
||||
}
|
||||
|
||||
@ -329,9 +362,9 @@ s32 sys_fs_fstat(u32 fd, vm::ptr<CellFsStat> sb)
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 sys_fs_mkdir(vm::ptr<const char> path, CellFsMode mode)
|
||||
s32 sys_fs_mkdir(vm::ptr<const char> path, s32 mode)
|
||||
{
|
||||
sys_fs.Warning("sys_fs_mkdir(path=*0x%x, mode=%d)", path, mode);
|
||||
sys_fs.Warning("sys_fs_mkdir(path=*0x%x, mode=%#o)", path, mode);
|
||||
sys_fs.Warning("*** path = '%s'", path.get_ptr());
|
||||
|
||||
const std::string _path = path.get_ptr();
|
||||
@ -528,9 +561,9 @@ s32 sys_fs_ftruncate(u32 fd, u64 size)
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 sys_fs_chmod(vm::ptr<const char> path, CellFsMode mode)
|
||||
s32 sys_fs_chmod(vm::ptr<const char> path, s32 mode)
|
||||
{
|
||||
sys_fs.Todo("sys_fs_chmod(path=*0x%x, mode=%d) -> CELL_OK", path, mode);
|
||||
sys_fs.Todo("sys_fs_chmod(path=*0x%x, mode=%#o) -> CELL_OK", path, mode);
|
||||
sys_fs.Todo("*** path = '%s'", path.get_ptr());
|
||||
|
||||
return CELL_OK;
|
||||
|
@ -145,7 +145,7 @@ struct CellFsUtimbuf
|
||||
#pragma pack(pop)
|
||||
|
||||
// SysCalls
|
||||
s32 sys_fs_open(vm::ptr<const char> path, s32 flags, vm::ptr<u32> fd, CellFsMode mode, vm::ptr<const void> arg, u64 size);
|
||||
s32 sys_fs_open(vm::ptr<const char> path, s32 flags, vm::ptr<u32> fd, s32 mode, vm::ptr<const void> arg, u64 size);
|
||||
s32 sys_fs_read(u32 fd, vm::ptr<void> buf, u64 nbytes, vm::ptr<u64> nread);
|
||||
s32 sys_fs_write(u32 fd, vm::ptr<const void> buf, u64 nbytes, vm::ptr<u64> nwrite);
|
||||
s32 sys_fs_close(u32 fd);
|
||||
@ -154,7 +154,7 @@ s32 sys_fs_readdir(u32 fd, vm::ptr<CellFsDirent> dir, vm::ptr<u64> nread);
|
||||
s32 sys_fs_closedir(u32 fd);
|
||||
s32 sys_fs_stat(vm::ptr<const char> path, vm::ptr<CellFsStat> sb);
|
||||
s32 sys_fs_fstat(u32 fd, vm::ptr<CellFsStat> sb);
|
||||
s32 sys_fs_mkdir(vm::ptr<const char> path, CellFsMode mode);
|
||||
s32 sys_fs_mkdir(vm::ptr<const char> path, s32 mode);
|
||||
s32 sys_fs_rename(vm::ptr<const char> from, vm::ptr<const char> to);
|
||||
s32 sys_fs_rmdir(vm::ptr<const char> path);
|
||||
s32 sys_fs_unlink(vm::ptr<const char> path);
|
||||
@ -163,4 +163,4 @@ s32 sys_fs_fget_block_size(u32 fd, vm::ptr<u64> sector_size, vm::ptr<u64> block_
|
||||
s32 sys_fs_get_block_size(vm::ptr<const char> path, vm::ptr<u64> sector_size, vm::ptr<u64> block_size, vm::ptr<u64> arg4);
|
||||
s32 sys_fs_truncate(vm::ptr<const char> path, u64 size);
|
||||
s32 sys_fs_ftruncate(u32 fd, u64 size);
|
||||
s32 sys_fs_chmod(vm::ptr<const char> path, CellFsMode mode);
|
||||
s32 sys_fs_chmod(vm::ptr<const char> path, s32 mode);
|
||||
|
Loading…
x
Reference in New Issue
Block a user