sys_fs_open() update, octal formatting

This commit is contained in:
Nekotekina 2015-03-13 23:43:11 +03:00
parent 0fc6ec2df9
commit 139173caa0
3 changed files with 62 additions and 29 deletions

View file

@ -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) 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 // TODO
// call the syscall // 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) 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); 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 // TODO
@ -209,9 +209,9 @@ s32 cellFsFtruncate(u32 fd, u64 size)
return sys_fs_ftruncate(fd, 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 // 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) 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) 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) 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: // TODO:

View file

@ -20,19 +20,13 @@
SysCallBase sys_fs("sys_fs"); 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()); sys_fs.Warning("*** path = '%s'", path.get_ptr());
std::shared_ptr<vfsStream> file; 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 // TODO: other checks for path
if (Emu.GetVFS().ExistsDir(path.get_ptr())) 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)); file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsRead));
break; 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_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)); 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; break;
} }
case CELL_FS_O_WRONLY | CELL_FS_O_CREAT | CELL_FS_O_TRUNC: case CELL_FS_O_WRONLY | CELL_FS_O_CREAT | CELL_FS_O_TRUNC:
{ {
Emu.GetVFS().CreateFile(path.get_ptr()); 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)); file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsWriteAppend));
break; break;
} }
case CELL_FS_O_RDWR: case CELL_FS_O_RDWR:
{ {
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsReadWrite)); file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsReadWrite));
break; break;
} }
case CELL_FS_O_RDWR | CELL_FS_O_CREAT: case CELL_FS_O_RDWR | CELL_FS_O_CREAT:
{ {
Emu.GetVFS().CreateFile(path.get_ptr()); Emu.GetVFS().CreateFile(path.get_ptr());
file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsReadWrite)); file.reset(Emu.GetVFS().OpenFile(path.get_ptr(), vfsReadWrite));
break; 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: 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; return CELL_FS_EINVAL;
} }
} }
if (!file || !file->IsOpened()) 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; 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()) if (!directory || !directory->IsOpened())
{ {
sys_fs.Error("sys_fs_opendir(): failed to open '%s'", path.get_ptr());
return CELL_FS_ENOENT; return CELL_FS_ENOENT;
} }
@ -329,9 +362,9 @@ s32 sys_fs_fstat(u32 fd, vm::ptr<CellFsStat> sb)
return CELL_OK; 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()); sys_fs.Warning("*** path = '%s'", path.get_ptr());
const std::string _path = 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; 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()); sys_fs.Todo("*** path = '%s'", path.get_ptr());
return CELL_OK; return CELL_OK;

View file

@ -145,7 +145,7 @@ struct CellFsUtimbuf
#pragma pack(pop) #pragma pack(pop)
// SysCalls // 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_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_write(u32 fd, vm::ptr<const void> buf, u64 nbytes, vm::ptr<u64> nwrite);
s32 sys_fs_close(u32 fd); 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_closedir(u32 fd);
s32 sys_fs_stat(vm::ptr<const char> path, vm::ptr<CellFsStat> sb); 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_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_rename(vm::ptr<const char> from, vm::ptr<const char> to);
s32 sys_fs_rmdir(vm::ptr<const char> path); s32 sys_fs_rmdir(vm::ptr<const char> path);
s32 sys_fs_unlink(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_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_truncate(vm::ptr<const char> path, u64 size);
s32 sys_fs_ftruncate(u32 fd, 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);