mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-06 07:12:14 +01:00
Compare commits
3 commits
17a7717584
...
566ad3edd8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
566ad3edd8 | ||
|
|
7c3ee53d6e | ||
|
|
f694b14a26 |
|
|
@ -76,6 +76,8 @@ struct IoDevice : rx::RcBase {
|
|||
virtual ErrorCode map(rx::AddressRange range, std::int64_t offset,
|
||||
rx::EnumBitSet<vmem::Protection> protection, File *file,
|
||||
Process *process);
|
||||
|
||||
[[nodiscard]] virtual std::string toString() const;
|
||||
};
|
||||
|
||||
namespace ioctl {
|
||||
|
|
@ -95,6 +97,8 @@ constexpr std::uint32_t paramSize(std::uint32_t cmd) {
|
|||
}
|
||||
constexpr std::uint32_t group(std::uint32_t cmd) { return (cmd >> 8) & 0xff; }
|
||||
constexpr std::uint32_t id(std::uint32_t cmd) { return cmd & 0xff; }
|
||||
|
||||
std::string groupToString(unsigned iocGroup);
|
||||
} // namespace ioctl
|
||||
|
||||
struct IoctlHandlerEntry;
|
||||
|
|
@ -201,5 +205,9 @@ template <int Group> struct IoDeviceWithIoctl : IoDevice {
|
|||
|
||||
return ioctlTable[id].handler(thread, argp, this, ioctlTable[id].impl);
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string toString() const override {
|
||||
return ioctl::groupToString(Group) + " " + IoDevice::toString();
|
||||
}
|
||||
};
|
||||
} // namespace orbis
|
||||
|
|
|
|||
|
|
@ -43,32 +43,32 @@ struct FileOps {
|
|||
// TODO: chown
|
||||
// TODO: chmod
|
||||
|
||||
ErrorCode (*bind)(orbis::File *file, SocketAddress *address,
|
||||
std::size_t addressLen, Thread *thread) = nullptr;
|
||||
ErrorCode (*listen)(orbis::File *file, int backlog, Thread *thread) = nullptr;
|
||||
ErrorCode (*accept)(orbis::File *file, SocketAddress *address,
|
||||
ErrorCode (*bind)(File *file, SocketAddress *address, std::size_t addressLen,
|
||||
Thread *thread) = nullptr;
|
||||
ErrorCode (*listen)(File *file, int backlog, Thread *thread) = nullptr;
|
||||
ErrorCode (*accept)(File *file, SocketAddress *address,
|
||||
std::uint32_t *addressLen, Thread *thread) = nullptr;
|
||||
ErrorCode (*connect)(orbis::File *file, SocketAddress *address,
|
||||
ErrorCode (*connect)(File *file, SocketAddress *address,
|
||||
std::uint32_t addressLen, Thread *thread) = nullptr;
|
||||
ErrorCode (*sendto)(orbis::File *file, const void *buf, size_t len,
|
||||
sint flags, caddr_t to, sint tolen,
|
||||
Thread *thread) = nullptr;
|
||||
ErrorCode (*sendmsg)(orbis::File *file, msghdr *msg, sint flags,
|
||||
ErrorCode (*sendto)(File *file, const void *buf, size_t len, sint flags,
|
||||
caddr_t to, sint tolen, Thread *thread) = nullptr;
|
||||
ErrorCode (*sendmsg)(File *file, msghdr *msg, sint flags,
|
||||
Thread *thread) = nullptr;
|
||||
ErrorCode (*recvfrom)(orbis::File *file, void *buf, size_t len, sint flags,
|
||||
ErrorCode (*recvfrom)(File *file, void *buf, size_t len, sint flags,
|
||||
SocketAddress *from, uint32_t *fromlenaddr,
|
||||
Thread *thread) = nullptr;
|
||||
ErrorCode (*recvmsg)(orbis::File *file, msghdr *msg, sint flags,
|
||||
ErrorCode (*recvmsg)(File *file, msghdr *msg, sint flags,
|
||||
Thread *thread) = nullptr;
|
||||
ErrorCode (*shutdown)(orbis::File *file, sint how, Thread *thread) = nullptr;
|
||||
ErrorCode (*setsockopt)(orbis::File *file, sint level, sint name,
|
||||
const void *val, sint valsize,
|
||||
Thread *thread) = nullptr;
|
||||
ErrorCode (*getsockopt)(orbis::File *file, sint level, sint name, void *val,
|
||||
ErrorCode (*shutdown)(File *file, sint how, Thread *thread) = nullptr;
|
||||
ErrorCode (*setsockopt)(File *file, sint level, sint name, const void *val,
|
||||
sint valsize, Thread *thread) = nullptr;
|
||||
ErrorCode (*getsockopt)(File *file, sint level, sint name, void *val,
|
||||
sint *avalsize, Thread *thread) = nullptr;
|
||||
ErrorCode (*sendfile)(orbis::File *file, sint fd, off_t offset, size_t nbytes,
|
||||
ErrorCode (*sendfile)(File *file, sint fd, off_t offset, size_t nbytes,
|
||||
ptr<struct sf_hdtr> hdtr, ptr<off_t> sbytes, sint flags,
|
||||
Thread *thread) = nullptr;
|
||||
|
||||
std::string (*toString)(File *file, Thread *thread);
|
||||
};
|
||||
|
||||
struct File : rx::RcBase {
|
||||
|
|
|
|||
|
|
@ -46,16 +46,18 @@ SysResult nosys(Thread *thread);
|
|||
|
||||
SysResult sys_exit(Thread *thread, sint status);
|
||||
SysResult sys_fork(Thread *thread);
|
||||
SysResult sys_read(Thread *thread, sint fd, ptr<void> buf, size_t nbyte);
|
||||
SysResult sys_write(Thread *thread, sint fd, ptr<const void> buf, size_t nbyte);
|
||||
SysResult sys_read(Thread *thread, FileDescriptor fd, ptr<void> buf,
|
||||
size_t nbyte);
|
||||
SysResult sys_write(Thread *thread, FileDescriptor fd, ptr<const void> buf,
|
||||
size_t nbyte);
|
||||
SysResult sys_open(Thread *thread, ptr<const char> path, sint flags, sint mode);
|
||||
SysResult sys_close(Thread *thread, sint fd);
|
||||
SysResult sys_close(Thread *thread, FileDescriptor fd);
|
||||
SysResult sys_wait4(Thread *thread, sint pid, ptr<sint> status, sint options,
|
||||
ptr<struct rusage> rusage);
|
||||
SysResult sys_link(Thread *thread, ptr<char> path, ptr<char> link);
|
||||
SysResult sys_unlink(Thread *thread, ptr<char> path);
|
||||
SysResult sys_chdir(Thread *thread, ptr<char> path);
|
||||
SysResult sys_fchdir(Thread *thread, sint fd);
|
||||
SysResult sys_fchdir(Thread *thread, FileDescriptor fd);
|
||||
SysResult sys_mknod(Thread *thread, ptr<char> path, sint mode, sint dev);
|
||||
SysResult sys_chmod(Thread *thread, ptr<char> path, sint mode);
|
||||
SysResult sys_chown(Thread *thread, ptr<char> path, sint uid, sint gid);
|
||||
|
|
@ -69,26 +71,26 @@ SysResult sys_getuid(Thread *thread);
|
|||
SysResult sys_geteuid(Thread *thread);
|
||||
SysResult sys_ptrace(Thread *thread, sint req, pid_t pid, caddr_t addr,
|
||||
sint data);
|
||||
SysResult sys_recvmsg(Thread *thread, sint s, ptr<struct msghdr> msg,
|
||||
SysResult sys_recvmsg(Thread *thread, FileDescriptor s, ptr<struct msghdr> msg,
|
||||
sint flags);
|
||||
SysResult sys_sendmsg(Thread *thread, sint s, ptr<struct msghdr> msg,
|
||||
SysResult sys_sendmsg(Thread *thread, FileDescriptor s, ptr<struct msghdr> msg,
|
||||
sint flags);
|
||||
SysResult sys_recvfrom(Thread *thread, sint s, caddr_t buf, size_t len,
|
||||
SysResult sys_recvfrom(Thread *thread, FileDescriptor s, caddr_t buf, size_t len,
|
||||
sint flags, ptr<SocketAddress> from,
|
||||
ptr<uint32_t> fromlenaddr);
|
||||
SysResult sys_accept(Thread *thread, sint s, ptr<SocketAddress> from,
|
||||
SysResult sys_accept(Thread *thread, FileDescriptor s, ptr<SocketAddress> from,
|
||||
ptr<uint32_t> fromlenaddr);
|
||||
SysResult sys_getpeername(Thread *thread, sint fdes, ptr<SocketAddress> asa,
|
||||
ptr<uint32_t> alen);
|
||||
SysResult sys_getsockname(Thread *thread, sint fdes, ptr<SocketAddress> asa,
|
||||
SysResult sys_getpeername(Thread *thread, FileDescriptor fdes, ptr<SocketAddress> asa,
|
||||
ptr<uint32_t> alen);
|
||||
SysResult sys_getsockname(Thread *thread, FileDescriptor fdes,
|
||||
ptr<SocketAddress> asa, ptr<uint32_t> alen);
|
||||
SysResult sys_access(Thread *thread, ptr<char> path, sint flags);
|
||||
SysResult sys_chflags(Thread *thread, ptr<char> path, sint flags);
|
||||
SysResult sys_fchflags(Thread *thread, sint fd, sint flags);
|
||||
SysResult sys_fchflags(Thread *thread, FileDescriptor fd, sint flags);
|
||||
SysResult sys_sync(Thread *thread);
|
||||
SysResult sys_kill(Thread *thread, sint pid, sint signum);
|
||||
SysResult sys_getppid(Thread *thread);
|
||||
SysResult sys_dup(Thread *thread, uint fd);
|
||||
SysResult sys_dup(Thread *thread, FileDescriptor fd);
|
||||
SysResult sys_pipe(Thread *thread);
|
||||
SysResult sys_getegid(Thread *thread);
|
||||
SysResult sys_profil(Thread *thread, caddr_t samples, size_t size,
|
||||
|
|
@ -100,7 +102,7 @@ SysResult sys_getlogin(Thread *thread, ptr<char> namebuf, uint namelen);
|
|||
SysResult sys_setlogin(Thread *thread, ptr<char> namebuf);
|
||||
SysResult sys_acct(Thread *thread, ptr<char> path);
|
||||
SysResult sys_sigaltstack(Thread *thread, ptr<stack_t> ss, ptr<stack_t> oss);
|
||||
SysResult sys_ioctl(Thread *thread, sint fd, ulong com, caddr_t data);
|
||||
SysResult sys_ioctl(Thread *thread, FileDescriptor fd, ulong com, caddr_t data);
|
||||
SysResult sys_reboot(Thread *thread, sint opt);
|
||||
SysResult sys_revoke(Thread *thread, ptr<char> path);
|
||||
SysResult sys_symlink(Thread *thread, ptr<char> path, ptr<char> link);
|
||||
|
|
@ -130,38 +132,42 @@ SysResult sys_setitimer(Thread *thread, uint which, ptr<struct itimerval> itv,
|
|||
SysResult sys_swapon(Thread *thread, ptr<char> name);
|
||||
SysResult sys_getitimer(Thread *thread, uint which, ptr<struct itimerval> itv);
|
||||
SysResult sys_getdtablesize(Thread *thread);
|
||||
SysResult sys_dup2(Thread *thread, uint from, uint to);
|
||||
SysResult sys_fcntl(Thread *thread, sint fd, sint cmd, slong arg);
|
||||
SysResult sys_dup2(Thread *thread, FileDescriptor from, FileDescriptor to);
|
||||
SysResult sys_fcntl(Thread *thread, FileDescriptor fd, sint cmd, slong arg);
|
||||
SysResult sys_select(Thread *thread, sint nd, ptr<struct fd_set_t> in,
|
||||
ptr<struct fd_set_t> out, ptr<struct fd_set_t> ex,
|
||||
ptr<struct timeval> tv);
|
||||
SysResult sys_fsync(Thread *thread, sint fd);
|
||||
SysResult sys_fsync(Thread *thread, FileDescriptor fd);
|
||||
SysResult sys_setpriority(Thread *thread, sint which, sint who, sint prio);
|
||||
SysResult sys_socket(Thread *thread, sint domain, sint type, sint protocol);
|
||||
SysResult sys_connect(Thread *thread, sint s, caddr_t name, sint namelen);
|
||||
SysResult sys_connect(Thread *thread, FileDescriptor s, caddr_t name,
|
||||
sint namelen);
|
||||
SysResult sys_getpriority(Thread *thread, sint which, sint who);
|
||||
SysResult sys_bind(Thread *thread, sint s, caddr_t name, sint namelen);
|
||||
SysResult sys_setsockopt(Thread *thread, sint s, sint level, sint name,
|
||||
caddr_t val, sint valsize);
|
||||
SysResult sys_listen(Thread *thread, sint s, sint backlog);
|
||||
SysResult sys_bind(Thread *thread, FileDescriptor s, caddr_t name,
|
||||
sint namelen);
|
||||
SysResult sys_setsockopt(Thread *thread, FileDescriptor s, sint level,
|
||||
sint name, caddr_t val, sint valsize);
|
||||
SysResult sys_listen(Thread *thread, FileDescriptor s, sint backlog);
|
||||
SysResult sys_gettimeofday(Thread *thread, ptr<timeval> tp, ptr<timezone> tzp);
|
||||
SysResult sys_getrusage(Thread *thread, sint who, ptr<struct rusage> rusage);
|
||||
SysResult sys_getsockopt(Thread *thread, sint s, sint level, sint name,
|
||||
caddr_t val, ptr<sint> avalsize);
|
||||
SysResult sys_readv(Thread *thread, sint fd, ptr<IoVec> iovp, uint iovcnt);
|
||||
SysResult sys_writev(Thread *thread, sint fd, ptr<IoVec> iovp, uint iovcnt);
|
||||
SysResult sys_getsockopt(Thread *thread, FileDescriptor s, sint level,
|
||||
sint name, caddr_t val, ptr<sint> avalsize);
|
||||
SysResult sys_readv(Thread *thread, FileDescriptor fd, ptr<IoVec> iovp,
|
||||
uint iovcnt);
|
||||
SysResult sys_writev(Thread *thread, FileDescriptor fd, ptr<IoVec> iovp,
|
||||
uint iovcnt);
|
||||
SysResult sys_settimeofday(Thread *thread, ptr<struct timeval> tp,
|
||||
ptr<timezone> tzp);
|
||||
SysResult sys_fchown(Thread *thread, sint fd, sint uid, sint gid);
|
||||
SysResult sys_fchmod(Thread *thread, sint fd, sint mode);
|
||||
SysResult sys_fchown(Thread *thread, FileDescriptor fd, sint uid, sint gid);
|
||||
SysResult sys_fchmod(Thread *thread, FileDescriptor fd, sint mode);
|
||||
SysResult sys_setreuid(Thread *thread, sint ruid, sint euid);
|
||||
SysResult sys_setregid(Thread *thread, sint rgid, sint egid);
|
||||
SysResult sys_rename(Thread *thread, ptr<char> from, ptr<char> to);
|
||||
SysResult sys_flock(Thread *thread, sint fd, sint how);
|
||||
SysResult sys_flock(Thread *thread, FileDescriptor fd, sint how);
|
||||
SysResult sys_mkfifo(Thread *thread, ptr<char> path, sint mode);
|
||||
SysResult sys_sendto(Thread *thread, sint s, caddr_t buf, size_t len,
|
||||
SysResult sys_sendto(Thread *thread, FileDescriptor s, caddr_t buf, size_t len,
|
||||
sint flags, caddr_t to, sint tolen);
|
||||
SysResult sys_shutdown(Thread *thread, sint s, sint how);
|
||||
SysResult sys_shutdown(Thread *thread, FileDescriptor s, sint how);
|
||||
SysResult sys_socketpair(Thread *thread, sint domain, sint type, sint protocol,
|
||||
ptr<sint> rsv);
|
||||
SysResult sys_mkdir(Thread *thread, ptr<char> path, sint mode);
|
||||
|
|
@ -185,33 +191,34 @@ SysResult sys_semsys(Thread *thread, sint which, sint a2, sint a3, sint a4,
|
|||
SysResult sys_msgsys(Thread *thread, sint which, sint a2, sint a3, sint a4,
|
||||
sint a5, sint a6);
|
||||
SysResult sys_shmsys(Thread *thread, sint which, sint a2, sint a3, sint a4);
|
||||
SysResult sys_freebsd6_pread(Thread *thread, sint fd, ptr<void> buf,
|
||||
SysResult sys_freebsd6_pread(Thread *thread, FileDescriptor fd, ptr<void> buf,
|
||||
size_t nbyte, sint pad, off_t offset);
|
||||
SysResult sys_freebsd6_pwrite(Thread *thread, sint fd, ptr<const void> buf,
|
||||
size_t nbyte, sint pad, off_t offset);
|
||||
SysResult sys_freebsd6_pwrite(Thread *thread, FileDescriptor fd,
|
||||
ptr<const void> buf, size_t nbyte, sint pad,
|
||||
off_t offset);
|
||||
SysResult sys_setfib(Thread *thread, sint fib);
|
||||
SysResult sys_ntp_adjtime(Thread *thread, ptr<struct timex> tp);
|
||||
SysResult sys_setgid(Thread *thread, gid_t gid);
|
||||
SysResult sys_setegid(Thread *thread, gid_t egid);
|
||||
SysResult sys_seteuid(Thread *thread, uid_t euid);
|
||||
SysResult sys_stat(Thread *thread, ptr<char> path, ptr<Stat> ub);
|
||||
SysResult sys_fstat(Thread *thread, sint fd, ptr<Stat> ub);
|
||||
SysResult sys_fstat(Thread *thread, FileDescriptor fd, ptr<Stat> ub);
|
||||
SysResult sys_lstat(Thread *thread, ptr<char> path, ptr<Stat> ub);
|
||||
SysResult sys_pathconf(Thread *thread, ptr<char> path, sint name);
|
||||
SysResult sys_fpathconf(Thread *thread, sint fd, sint name);
|
||||
SysResult sys_fpathconf(Thread *thread, FileDescriptor fd, sint name);
|
||||
SysResult sys_getrlimit(Thread *thread, uint which, ptr<struct rlimit> rlp);
|
||||
SysResult sys_setrlimit(Thread *thread, uint which, ptr<struct rlimit> rlp);
|
||||
SysResult sys_getdirentries(Thread *thread, sint fd, ptr<char> buf, uint count,
|
||||
ptr<slong> basep);
|
||||
SysResult sys_getdirentries(Thread *thread, FileDescriptor fd, ptr<char> buf,
|
||||
uint count, ptr<slong> basep);
|
||||
SysResult sys_freebsd6_mmap(Thread *thread, uintptr_t addr, size_t len,
|
||||
rx::EnumBitSet<vmem::Protection> prot,
|
||||
rx::EnumBitSet<vmem::MapFlags> flags, sint fd,
|
||||
sint pad, off_t pos);
|
||||
SysResult sys_freebsd6_lseek(Thread *thread, sint fd, sint pad, off_t offset,
|
||||
sint whence);
|
||||
rx::EnumBitSet<vmem::MapFlags> flags,
|
||||
FileDescriptor fd, sint pad, off_t pos);
|
||||
SysResult sys_freebsd6_lseek(Thread *thread, FileDescriptor fd, sint pad,
|
||||
off_t offset, sint whence);
|
||||
SysResult sys_freebsd6_truncate(Thread *thread, ptr<char> path, sint pad,
|
||||
off_t length);
|
||||
SysResult sys_freebsd6_ftruncate(Thread *thread, sint fd, sint pad,
|
||||
SysResult sys_freebsd6_ftruncate(Thread *thread, FileDescriptor fd, sint pad,
|
||||
off_t length);
|
||||
SysResult sys___sysctl(Thread *thread, ptr<sint> name, uint namelen,
|
||||
ptr<void> old, ptr<size_t> oldenp, ptr<void> new_,
|
||||
|
|
@ -219,7 +226,8 @@ SysResult sys___sysctl(Thread *thread, ptr<sint> name, uint namelen,
|
|||
SysResult sys_mlock(Thread *thread, uintptr_t addr, size_t len);
|
||||
SysResult sys_munlock(Thread *thread, uintptr_t addr, size_t len);
|
||||
SysResult sys_undelete(Thread *thread, ptr<char> path);
|
||||
SysResult sys_futimes(Thread *thread, sint fd, ptr<struct timeval> tptr);
|
||||
SysResult sys_futimes(Thread *thread, FileDescriptor fd,
|
||||
ptr<struct timeval> tptr);
|
||||
SysResult sys_getpgid(Thread *thread, pid_t pid);
|
||||
SysResult sys_poll(Thread *thread, ptr<struct pollfd> fds, uint nfds,
|
||||
sint timeout);
|
||||
|
|
@ -265,16 +273,17 @@ SysResult sys_aio_write(Thread *thread, ptr<struct aiocb> aiocbp);
|
|||
SysResult sys_lio_listio(Thread *thread, sint mode,
|
||||
ptr<cptr<struct aiocb>> aiocbp, sint nent,
|
||||
ptr<struct sigevent> sig);
|
||||
SysResult sys_getdents(Thread *thread, sint fd, ptr<char> buf, size_t count);
|
||||
SysResult sys_getdents(Thread *thread, FileDescriptor fd, ptr<char> buf,
|
||||
size_t count);
|
||||
SysResult sys_lchmod(Thread *thread, ptr<char> path, mode_t mode);
|
||||
SysResult sys_lutimes(Thread *thread, ptr<char> path, ptr<struct timeval> tptr);
|
||||
SysResult sys_nstat(Thread *thread, ptr<char> path, ptr<struct nstat> ub);
|
||||
SysResult sys_nfstat(Thread *thread, sint fd, ptr<struct nstat> sb);
|
||||
SysResult sys_nfstat(Thread *thread, FileDescriptor fd, ptr<struct nstat> sb);
|
||||
SysResult sys_nlstat(Thread *thread, ptr<char> path, ptr<struct nstat> ub);
|
||||
SysResult sys_preadv(Thread *thread, sint fd, ptr<IoVec> iovp, uint iovcnt,
|
||||
off_t offset);
|
||||
SysResult sys_pwritev(Thread *thread, sint fd, ptr<IoVec> iovp, uint iovcnt,
|
||||
off_t offset);
|
||||
SysResult sys_preadv(Thread *thread, FileDescriptor fd, ptr<IoVec> iovp,
|
||||
uint iovcnt, off_t offset);
|
||||
SysResult sys_pwritev(Thread *thread, FileDescriptor fd, ptr<IoVec> iovp,
|
||||
uint iovcnt, off_t offset);
|
||||
SysResult sys_fhopen(Thread *thread, ptr<const struct fhandle> u_fhp,
|
||||
sint flags);
|
||||
SysResult sys_fhstat(Thread *thread, ptr<const struct fhandle> u_fhp,
|
||||
|
|
@ -296,7 +305,8 @@ SysResult sys_setresgid(Thread *thread, gid_t rgid, gid_t egid, gid_t sgid);
|
|||
SysResult sys_aio_return(Thread *thread, ptr<struct aiocb> aiocbp);
|
||||
SysResult sys_aio_suspend(Thread *thread, ptr<struct aiocb> aiocbp, sint nent,
|
||||
ptr<const timespec> timeout);
|
||||
SysResult sys_aio_cancel(Thread *thread, sint fd, ptr<struct aiocb> aiocbp);
|
||||
SysResult sys_aio_cancel(Thread *thread, FileDescriptor fd,
|
||||
ptr<struct aiocb> aiocbp);
|
||||
SysResult sys_aio_error(Thread *thread, ptr<struct aiocb> aiocbp);
|
||||
SysResult sys_oaio_read(Thread *thread, ptr<struct aiocb> aiocbp);
|
||||
SysResult sys_oaio_write(Thread *thread, ptr<struct aiocb> aiocbp);
|
||||
|
|
@ -367,17 +377,17 @@ SysResult sys_getresuid(Thread *thread, ptr<uid_t> ruid, ptr<uid_t> euid,
|
|||
SysResult sys_getresgid(Thread *thread, ptr<gid_t> rgid, ptr<gid_t> egid,
|
||||
ptr<gid_t> sgid);
|
||||
SysResult sys_kqueue(Thread *thread);
|
||||
SysResult sys_kevent(Thread *thread, sint fd, ptr<KEvent> changelist,
|
||||
SysResult sys_kevent(Thread *thread, FileDescriptor fd, ptr<KEvent> changelist,
|
||||
sint nchanges, ptr<KEvent> eventlist, sint nevents,
|
||||
ptr<const timespec> timeout);
|
||||
SysResult sys_extattr_set_fd(Thread *thread, sint fd, sint attrnamespace,
|
||||
ptr<const char> attrname, ptr<void> data,
|
||||
size_t nbytes);
|
||||
SysResult sys_extattr_get_fd(Thread *thread, sint fd, sint attrnamespace,
|
||||
ptr<const char> attrname, ptr<void> data,
|
||||
size_t nbytes);
|
||||
SysResult sys_extattr_delete_fd(Thread *thread, sint fd, sint attrnamespace,
|
||||
ptr<const char> attrname);
|
||||
SysResult sys_extattr_set_fd(Thread *thread, FileDescriptor fd,
|
||||
sint attrnamespace, ptr<const char> attrname,
|
||||
ptr<void> data, size_t nbytes);
|
||||
SysResult sys_extattr_get_fd(Thread *thread, FileDescriptor fd,
|
||||
sint attrnamespace, ptr<const char> attrname,
|
||||
ptr<void> data, size_t nbytes);
|
||||
SysResult sys_extattr_delete_fd(Thread *thread, FileDescriptor fd,
|
||||
sint attrnamespace, ptr<const char> attrname);
|
||||
SysResult sys___setugid(Thread *thread, sint flags);
|
||||
SysResult sys_eaccess(Thread *thread, ptr<char> path, sint flags);
|
||||
SysResult sys_afs3_syscall(Thread *thread, slong syscall, slong param1,
|
||||
|
|
@ -386,25 +396,27 @@ SysResult sys_afs3_syscall(Thread *thread, slong syscall, slong param1,
|
|||
SysResult sys_nmount(Thread *thread, ptr<IoVec> iovp, uint iovcnt, sint flags);
|
||||
SysResult sys___mac_get_proc(Thread *thread, ptr<struct mac> mac_p);
|
||||
SysResult sys___mac_set_proc(Thread *thread, ptr<struct mac> mac_p);
|
||||
SysResult sys___mac_get_fd(Thread *thread, sint fd, ptr<struct mac> mac_p);
|
||||
SysResult sys___mac_get_fd(Thread *thread, FileDescriptor fd,
|
||||
ptr<struct mac> mac_p);
|
||||
SysResult sys___mac_get_file(Thread *thread, ptr<const char> path,
|
||||
ptr<struct mac> mac_p);
|
||||
SysResult sys___mac_set_fd(Thread *thread, sint fd, ptr<struct mac> mac_p);
|
||||
SysResult sys___mac_set_fd(Thread *thread, FileDescriptor fd,
|
||||
ptr<struct mac> mac_p);
|
||||
SysResult sys___mac_set_file(Thread *thread, ptr<const char> path,
|
||||
ptr<struct mac> mac_p);
|
||||
SysResult sys_kenv(Thread *thread, sint what, ptr<const char> name,
|
||||
ptr<char> value, sint len);
|
||||
SysResult sys_lchflags(Thread *thread, ptr<const char> path, sint flags);
|
||||
SysResult sys_uuidgen(Thread *thread, ptr<struct uuid> store, sint count);
|
||||
SysResult sys_sendfile(Thread *thread, sint fd, sint s, off_t offset,
|
||||
size_t nbytes, ptr<struct sf_hdtr> hdtr,
|
||||
SysResult sys_sendfile(Thread *thread, FileDescriptor fd, FileDescriptor s,
|
||||
off_t offset, size_t nbytes, ptr<struct sf_hdtr> hdtr,
|
||||
ptr<off_t> sbytes, sint flags);
|
||||
SysResult sys_mac_syscall(Thread *thread, ptr<const char> policy, sint call,
|
||||
ptr<void> arg);
|
||||
SysResult sys_getfsstat(Thread *thread, ptr<StatFs> buf, slong bufsize,
|
||||
sint flags);
|
||||
SysResult sys_statfs(Thread *thread, ptr<char> path, ptr<StatFs> buf);
|
||||
SysResult sys_fstatfs(Thread *thread, sint fd, ptr<StatFs> buf);
|
||||
SysResult sys_fstatfs(Thread *thread, FileDescriptor fd, ptr<StatFs> buf);
|
||||
SysResult sys_fhstatfs(Thread *thread, ptr<const struct fhandle> u_fhp,
|
||||
ptr<StatFs> buf);
|
||||
SysResult sys_ksem_close(Thread *thread, semid_t id);
|
||||
|
|
@ -457,8 +469,9 @@ SysResult sys_thr_kill(Thread *thread, slong id, sint sig);
|
|||
SysResult sys__umtx_lock(Thread *thread, ptr<struct umtx> umtx);
|
||||
SysResult sys__umtx_unlock(Thread *thread, ptr<struct umtx> umtx);
|
||||
SysResult sys_jail_attach(Thread *thread, sint jid);
|
||||
SysResult sys_extattr_list_fd(Thread *thread, sint fd, sint attrnamespace,
|
||||
ptr<void> data, size_t nbytes);
|
||||
SysResult sys_extattr_list_fd(Thread *thread, FileDescriptor fd,
|
||||
sint attrnamespace, ptr<void> data,
|
||||
size_t nbytes);
|
||||
SysResult sys_extattr_list_file(Thread *thread, ptr<const char> path,
|
||||
sint attrnamespace, ptr<void> data,
|
||||
size_t nbytes);
|
||||
|
|
@ -522,16 +535,18 @@ SysResult sys_sctp_generic_recvmsg(Thread *thread, sint sd, ptr<IoVec> iov,
|
|||
sint iovlen, caddr_t from, SockLen fromlen,
|
||||
ptr<struct sctp_sndrcvinfo> sinfo,
|
||||
sint flags);
|
||||
SysResult sys_pread(Thread *thread, sint fd, ptr<void> buf, size_t nbyte,
|
||||
off_t offset);
|
||||
SysResult sys_pwrite(Thread *thread, sint fd, ptr<const void> buf, size_t nbyte,
|
||||
off_t offset);
|
||||
SysResult sys_pread(Thread *thread, FileDescriptor fd, ptr<void> buf,
|
||||
size_t nbyte, off_t offset);
|
||||
SysResult sys_pwrite(Thread *thread, FileDescriptor fd, ptr<const void> buf,
|
||||
size_t nbyte, off_t offset);
|
||||
SysResult sys_mmap(Thread *thread, uintptr_t addr, size_t len,
|
||||
rx::EnumBitSet<vmem::Protection> prot,
|
||||
rx::EnumBitSet<vmem::MapFlags> flags, sint fd, off_t pos);
|
||||
SysResult sys_lseek(Thread *thread, sint fd, off_t offset, sint whence);
|
||||
rx::EnumBitSet<vmem::MapFlags> flags, FileDescriptor fd,
|
||||
off_t pos);
|
||||
SysResult sys_lseek(Thread *thread, FileDescriptor fd, off_t offset,
|
||||
sint whence);
|
||||
SysResult sys_truncate(Thread *thread, ptr<char> path, off_t length);
|
||||
SysResult sys_ftruncate(Thread *thread, sint fd, off_t length);
|
||||
SysResult sys_ftruncate(Thread *thread, FileDescriptor fd, off_t length);
|
||||
SysResult sys_thr_kill2(Thread *thread, pid_t pid, slong id, sint sig);
|
||||
SysResult sys_shm_open(Thread *thread, ptr<const char> path, sint flags,
|
||||
mode_t mode);
|
||||
|
|
@ -547,33 +562,36 @@ SysResult sys_cpuset_getaffinity(Thread *thread, cpulevel_t level,
|
|||
SysResult sys_cpuset_setaffinity(Thread *thread, cpulevel_t level,
|
||||
cpuwhich_t which, id_t id, size_t cpusetsize,
|
||||
ptr<const cpuset> mask);
|
||||
SysResult sys_faccessat(Thread *thread, sint fd, ptr<char> path, sint mode,
|
||||
sint flag);
|
||||
SysResult sys_fchmodat(Thread *thread, sint fd, ptr<char> path, mode_t mode,
|
||||
sint flag);
|
||||
SysResult sys_fchownat(Thread *thread, sint fd, ptr<char> path, uid_t uid,
|
||||
gid_t gid, sint flag);
|
||||
SysResult sys_fexecve(Thread *thread, sint fd, ptr<ptr<char>> argv,
|
||||
SysResult sys_faccessat(Thread *thread, FileDescriptor fd, ptr<char> path,
|
||||
sint mode, sint flag);
|
||||
SysResult sys_fchmodat(Thread *thread, FileDescriptor fd, ptr<char> path,
|
||||
mode_t mode, sint flag);
|
||||
SysResult sys_fchownat(Thread *thread, FileDescriptor fd, ptr<char> path,
|
||||
uid_t uid, gid_t gid, sint flag);
|
||||
SysResult sys_fexecve(Thread *thread, FileDescriptor fd, ptr<ptr<char>> argv,
|
||||
ptr<ptr<char>> envv);
|
||||
SysResult sys_fstatat(Thread *thread, sint fd, ptr<char> path, ptr<Stat> buf,
|
||||
sint flag);
|
||||
SysResult sys_futimesat(Thread *thread, sint fd, ptr<char> path,
|
||||
SysResult sys_fstatat(Thread *thread, FileDescriptor fd, ptr<char> path,
|
||||
ptr<Stat> buf, sint flag);
|
||||
SysResult sys_futimesat(Thread *thread, FileDescriptor fd, ptr<char> path,
|
||||
ptr<struct timeval> times);
|
||||
SysResult sys_linkat(Thread *thread, sint fd1, ptr<char> path1, sint fd2,
|
||||
ptr<char> path2, sint flag);
|
||||
SysResult sys_mkdirat(Thread *thread, sint fd, ptr<char> path, mode_t mode);
|
||||
SysResult sys_mkfifoat(Thread *thread, sint fd, ptr<char> path, mode_t mode);
|
||||
SysResult sys_mknodat(Thread *thread, sint fd, ptr<char> path, mode_t mode,
|
||||
dev_t dev);
|
||||
SysResult sys_openat(Thread *thread, sint fd, ptr<char> path, sint flag,
|
||||
mode_t mode);
|
||||
SysResult sys_readlinkat(Thread *thread, sint fd, ptr<char> path, ptr<char> buf,
|
||||
size_t bufsize);
|
||||
SysResult sys_renameat(Thread *thread, sint oldfd, ptr<char> old, sint newfd,
|
||||
ptr<char> new_);
|
||||
SysResult sys_symlinkat(Thread *thread, ptr<char> path1, sint fd,
|
||||
SysResult sys_linkat(Thread *thread, FileDescriptor fd1, ptr<char> path1,
|
||||
FileDescriptor fd2, ptr<char> path2, sint flag);
|
||||
SysResult sys_mkdirat(Thread *thread, FileDescriptor fd, ptr<char> path,
|
||||
mode_t mode);
|
||||
SysResult sys_mkfifoat(Thread *thread, FileDescriptor fd, ptr<char> path,
|
||||
mode_t mode);
|
||||
SysResult sys_mknodat(Thread *thread, FileDescriptor fd, ptr<char> path,
|
||||
mode_t mode, dev_t dev);
|
||||
SysResult sys_openat(Thread *thread, FileDescriptor fd, ptr<char> path,
|
||||
sint flag, mode_t mode);
|
||||
SysResult sys_readlinkat(Thread *thread, FileDescriptor fd, ptr<char> path,
|
||||
ptr<char> buf, size_t bufsize);
|
||||
SysResult sys_renameat(Thread *thread, FileDescriptor oldfd, ptr<char> old,
|
||||
FileDescriptor newfd, ptr<char> new_);
|
||||
SysResult sys_symlinkat(Thread *thread, ptr<char> path1, FileDescriptor fd,
|
||||
ptr<char> path2);
|
||||
SysResult sys_unlinkat(Thread *thread, sint fd, ptr<char> path, sint flag);
|
||||
SysResult sys_unlinkat(Thread *thread, FileDescriptor fd, ptr<char> path,
|
||||
sint flag);
|
||||
SysResult sys_posix_openpt(Thread *thread, sint flags);
|
||||
SysResult sys_gssd_syscall(Thread *thread, ptr<char> path);
|
||||
SysResult sys_jail_get(Thread *thread, ptr<IoVec> iovp, uint iovcnt,
|
||||
|
|
@ -581,7 +599,7 @@ SysResult sys_jail_get(Thread *thread, ptr<IoVec> iovp, uint iovcnt,
|
|||
SysResult sys_jail_set(Thread *thread, ptr<IoVec> iovp, uint iovcnt,
|
||||
sint flags);
|
||||
SysResult sys_jail_remove(Thread *thread, sint jid);
|
||||
SysResult sys_closefrom(Thread *thread, sint lowfd);
|
||||
SysResult sys_closefrom(Thread *thread, FileDescriptor lowfd);
|
||||
SysResult sys___semctl(Thread *thread, sint semid, sint semnum, sint cmd,
|
||||
ptr<union semun> arg);
|
||||
SysResult sys_msgctl(Thread *thread, sint msqid, sint cmd,
|
||||
|
|
@ -589,13 +607,14 @@ SysResult sys_msgctl(Thread *thread, sint msqid, sint cmd,
|
|||
SysResult sys_shmctl(Thread *thread, sint shmid, sint cmd,
|
||||
ptr<struct shmid_ds> buf);
|
||||
SysResult sys_lpathconf(Thread *thread, ptr<char> path, sint name);
|
||||
SysResult sys_cap_new(Thread *thread, sint fd, uint64_t rights);
|
||||
SysResult sys_cap_getrights(Thread *thread, sint fd, ptr<uint64_t> rights);
|
||||
SysResult sys_cap_new(Thread *thread, FileDescriptor fd, uint64_t rights);
|
||||
SysResult sys_cap_getrights(Thread *thread, FileDescriptor fd,
|
||||
ptr<uint64_t> rights);
|
||||
SysResult sys_cap_enter(Thread *thread);
|
||||
SysResult sys_cap_getmode(Thread *thread, ptr<uint> modep);
|
||||
SysResult sys_pdfork(Thread *thread, ptr<sint> fdp, sint flags);
|
||||
SysResult sys_pdkill(Thread *thread, sint fd, sint signum);
|
||||
SysResult sys_pdgetpid(Thread *thread, sint fd, ptr<pid_t> pidp);
|
||||
SysResult sys_pdkill(Thread *thread, FileDescriptor fd, sint signum);
|
||||
SysResult sys_pdgetpid(Thread *thread, FileDescriptor fd, ptr<pid_t> pidp);
|
||||
SysResult sys_pselect(Thread *thread, sint nd, ptr<fd_set_t> in,
|
||||
ptr<fd_set_t> ou, ptr<fd_set_t> ex,
|
||||
ptr<const timespec> ts, ptr<const SigSet> sm);
|
||||
|
|
@ -616,17 +635,18 @@ SysResult sys_rctl_add_rule(Thread *thread, ptr<const void> inbufp,
|
|||
SysResult sys_rctl_remove_rule(Thread *thread, ptr<const void> inbufp,
|
||||
size_t inbuflen, ptr<void> outbuf,
|
||||
size_t outbuflen);
|
||||
SysResult sys_posix_fallocate(Thread *thread, sint fd, off_t offset, off_t len);
|
||||
SysResult sys_posix_fadvise(Thread *thread, sint fd, off_t offset, off_t len,
|
||||
sint advice);
|
||||
SysResult sys_posix_fallocate(Thread *thread, FileDescriptor fd, off_t offset,
|
||||
off_t len);
|
||||
SysResult sys_posix_fadvise(Thread *thread, FileDescriptor fd, off_t offset,
|
||||
off_t len, sint advice);
|
||||
|
||||
SysResult sys_netcontrol(Thread *thread, sint fd, uint op, ptr<void> buf,
|
||||
uint nbuf);
|
||||
SysResult sys_netcontrol(Thread *thread, FileDescriptor fd, uint op,
|
||||
ptr<void> buf, uint nbuf);
|
||||
SysResult sys_netabort(Thread *thread /* TODO */);
|
||||
SysResult sys_netgetsockinfo(Thread *thread /* TODO */);
|
||||
SysResult sys_socketex(Thread *thread, ptr<const char> name, sint domain,
|
||||
sint type, sint protocol);
|
||||
SysResult sys_socketclose(Thread *thread, sint fd);
|
||||
SysResult sys_socketclose(Thread *thread, FileDescriptor fd);
|
||||
SysResult sys_netgetiflist(Thread *thread /* TODO */);
|
||||
SysResult sys_kqueueex(Thread *thread, ptr<char> name, sint flags);
|
||||
SysResult sys_mtypeprotect(Thread *thread, uintptr_t addr, size_t len,
|
||||
|
|
@ -732,7 +752,7 @@ SysResult sys_mdbg_service(Thread *thread, uint32_t op, ptr<void> arg0,
|
|||
ptr<void> arg1);
|
||||
SysResult sys_randomized_path(Thread *thread, sint type, ptr<char> path,
|
||||
ptr<sint> length);
|
||||
SysResult sys_rdup(Thread *thread, sint a, sint b);
|
||||
SysResult sys_rdup(Thread *thread, pid_t pid, FileDescriptor fd);
|
||||
SysResult sys_dl_get_metadata(Thread *thread /* TODO */);
|
||||
SysResult sys_workaround8849(Thread *thread /* TODO */);
|
||||
SysResult sys_is_development_mode(Thread *thread /* TODO */);
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@
|
|||
#include "../evf.hpp"
|
||||
#include "../ipmi.hpp"
|
||||
#include "../osem.hpp"
|
||||
#include "../thread/Thread.hpp"
|
||||
#include "../thread/types.hpp"
|
||||
#include "Thread.hpp"
|
||||
#include "types.hpp"
|
||||
#include "ProcessState.hpp"
|
||||
#include "cpuset.hpp"
|
||||
#include "orbis/AppInfo.hpp"
|
||||
|
|
@ -102,7 +102,7 @@ struct Process final {
|
|||
rx::RcIdMap<Semaphore, sint, 4097, 1> semMap;
|
||||
rx::RcIdMap<Module, ModuleHandle> modulesMap;
|
||||
rx::RcIdMap<Thread, lwpid_t> threadsMap;
|
||||
rx::RcIdMap<orbis::File, sint> fileDescriptors;
|
||||
rx::RcIdMap<orbis::File, FileDescriptor> fileDescriptors;
|
||||
|
||||
rx::AddressRange libkernelRange;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ using sy_call_t = SysResult(Thread *, uint64_t *);
|
|||
struct sysent {
|
||||
sint narg;
|
||||
sy_call_t *call;
|
||||
std::string (*format)(uint64_t *);
|
||||
std::string (*format)(Thread *, uint64_t *);
|
||||
};
|
||||
|
||||
struct sysentvec {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@ using pid_t = int32_t;
|
|||
using uid_t = uint32_t;
|
||||
using gid_t = uint32_t;
|
||||
|
||||
enum class FileDescriptor : std::int32_t {
|
||||
Invalid = -1
|
||||
};
|
||||
|
||||
struct rtprio {
|
||||
uint16_t type;
|
||||
uint16_t prio;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
#include "IoDevice.hpp"
|
||||
#include "file.hpp"
|
||||
#include "rx/Mappable.hpp"
|
||||
#include "rx/format-base.hpp"
|
||||
#include "thread/Thread.hpp"
|
||||
#include "utils/Logs.hpp"
|
||||
#include "vmem.hpp"
|
||||
|
||||
static std::string iocGroupToString(unsigned iocGroup) {
|
||||
std::string orbis::ioctl::groupToString(unsigned iocGroup) {
|
||||
if (iocGroup >= 128) {
|
||||
const char *sceGroups[] = {
|
||||
"DEV",
|
||||
|
|
@ -86,10 +87,14 @@ orbis::IoDevice::map(rx::AddressRange range, std::int64_t offset,
|
|||
|
||||
orbis::ErrorCode orbis::IoDevice::ioctl(std::uint64_t request,
|
||||
orbis::ptr<void> argp, Thread *thread) {
|
||||
auto group = iocGroupToString(ioctl::group(request));
|
||||
auto group = ioctl::groupToString(ioctl::group(request));
|
||||
auto paramSize = ioctl::paramSize(request);
|
||||
ORBIS_LOG_ERROR("unhandled ioctl", request, group, paramSize, argp,
|
||||
thread->tid);
|
||||
thread->where();
|
||||
return ErrorCode::NOTSUP;
|
||||
}
|
||||
|
||||
std::string orbis::IoDevice::toString() const {
|
||||
return rx::format("{}", static_cast<const void *>(this));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,11 @@ orbis::SysResult orbis::sys_cap_enter(Thread *thread) {
|
|||
orbis::SysResult orbis::sys_cap_getmode(Thread *thread, ptr<uint> modep) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_cap_new(Thread *thread, sint fd, uint64_t rights) {
|
||||
orbis::SysResult orbis::sys_cap_new(Thread *thread, FileDescriptor fd,
|
||||
uint64_t rights) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_cap_getrights(Thread *thread, sint fd,
|
||||
orbis::SysResult orbis::sys_cap_getrights(Thread *thread, FileDescriptor fd,
|
||||
ptr<uint64_t> rights) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,13 @@
|
|||
#include "sys/sysproto.hpp"
|
||||
#include "thread/Process.hpp"
|
||||
#include "thread/Thread.hpp"
|
||||
#include <utility>
|
||||
|
||||
orbis::SysResult orbis::sys_getdtablesize(Thread *thread) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_dup2(Thread *thread, uint from, uint to) {
|
||||
orbis::SysResult orbis::sys_dup2(Thread *thread, FileDescriptor from,
|
||||
FileDescriptor to) {
|
||||
auto file = thread->tproc->fileDescriptors.get(from);
|
||||
|
||||
if (file == nullptr) {
|
||||
|
|
@ -19,31 +21,33 @@ orbis::SysResult orbis::sys_dup2(Thread *thread, uint from, uint to) {
|
|||
thread->tproc->fileDescriptors.insert(to, file);
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_dup(Thread *thread, uint fd) {
|
||||
orbis::SysResult orbis::sys_dup(Thread *thread, FileDescriptor fd) {
|
||||
auto file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
thread->retval[0] = thread->tproc->fileDescriptors.insert(std::move(file));
|
||||
thread->retval[0] = std::to_underlying(
|
||||
thread->tproc->fileDescriptors.insert(std::move(file)));
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_fcntl(Thread *thread, sint fd, sint cmd,
|
||||
orbis::SysResult orbis::sys_fcntl(Thread *thread, FileDescriptor fd, sint cmd,
|
||||
slong arg) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, fd, cmd, arg);
|
||||
ORBIS_LOG_TODO(__FUNCTION__, (int)fd, cmd, arg);
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_close(Thread *thread, sint fd) {
|
||||
// ORBIS_LOG_NOTICE(__FUNCTION__, fd);
|
||||
orbis::SysResult orbis::sys_close(Thread *thread, FileDescriptor fd) {
|
||||
// ORBIS_LOG_NOTICE(__FUNCTION__, (int)fd);
|
||||
if (thread->tproc->fileDescriptors.close(fd)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
orbis::SysResult orbis::sys_closefrom(Thread *thread, sint lowfd) {
|
||||
orbis::SysResult orbis::sys_closefrom(Thread *thread, FileDescriptor lowfd) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_fstat(Thread *thread, sint fd, ptr<Stat> ub) {
|
||||
orbis::SysResult orbis::sys_fstat(Thread *thread, FileDescriptor fd,
|
||||
ptr<Stat> ub) {
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -68,13 +72,14 @@ orbis::SysResult orbis::sys_fstat(Thread *thread, sint fd, ptr<Stat> ub) {
|
|||
|
||||
return uwrite(ub, _ub);
|
||||
}
|
||||
orbis::SysResult orbis::sys_nfstat(Thread *thread, sint fd,
|
||||
orbis::SysResult orbis::sys_nfstat(Thread *thread, FileDescriptor fd,
|
||||
ptr<struct nstat> sb) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_fpathconf(Thread *thread, sint fd, sint name) {
|
||||
orbis::SysResult orbis::sys_fpathconf(Thread *thread, FileDescriptor fd,
|
||||
sint name) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_flock(Thread *thread, sint fd, sint how) {
|
||||
orbis::SysResult orbis::sys_flock(Thread *thread, FileDescriptor fd, sint how) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include <chrono>
|
||||
#include <list>
|
||||
#include <span>
|
||||
#include <utility>
|
||||
|
||||
#ifdef __linux
|
||||
#include <sys/select.h>
|
||||
|
|
@ -19,8 +20,8 @@ orbis::SysResult orbis::sys_kqueue(Thread *thread) {
|
|||
}
|
||||
|
||||
auto fd = thread->tproc->fileDescriptors.insert(queue);
|
||||
ORBIS_LOG_TODO(__FUNCTION__, fd);
|
||||
thread->retval[0] = fd;
|
||||
ORBIS_LOG_TODO(__FUNCTION__, (int)fd);
|
||||
thread->retval[0] = std::to_underlying(fd);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
@ -35,8 +36,8 @@ orbis::SysResult orbis::sys_kqueueex(Thread *thread, ptr<char> name,
|
|||
if (name != nullptr) {
|
||||
queue->name = name;
|
||||
}
|
||||
ORBIS_LOG_TODO(__FUNCTION__, name, flags, fd);
|
||||
thread->retval[0] = fd;
|
||||
ORBIS_LOG_TODO(__FUNCTION__, name, flags, (int)fd);
|
||||
thread->retval[0] = std::to_underlying(fd);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
@ -121,7 +122,8 @@ static SysResult keventChange(KQueue *kq, KEvent &change, Thread *thread) {
|
|||
}
|
||||
} else if (change.filter == kEvFiltRead ||
|
||||
change.filter == kEvFiltWrite) {
|
||||
auto fd = thread->tproc->fileDescriptors.get(change.ident);
|
||||
auto fd =
|
||||
thread->tproc->fileDescriptors.get(FileDescriptor(change.ident));
|
||||
|
||||
if (fd == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -221,7 +223,7 @@ static orbis::ErrorCode ureadTimespec(orbis::timespec &ts,
|
|||
}
|
||||
} // namespace orbis
|
||||
|
||||
orbis::SysResult orbis::sys_kevent(Thread *thread, sint fd,
|
||||
orbis::SysResult orbis::sys_kevent(Thread *thread, FileDescriptor fd,
|
||||
ptr<KEvent> changelist, sint nchanges,
|
||||
ptr<KEvent> eventlist, sint nevents,
|
||||
ptr<const timespec> timeout) {
|
||||
|
|
@ -240,7 +242,7 @@ orbis::SysResult orbis::sys_kevent(Thread *thread, sint fd,
|
|||
KEvent change;
|
||||
ORBIS_RET_ON_ERROR(uread(change, &changePtr));
|
||||
if (change.filter != kEvFiltUser) {
|
||||
ORBIS_LOG_NOTICE(__FUNCTION__, fd, change.ident, change.filter,
|
||||
ORBIS_LOG_NOTICE(__FUNCTION__, (int)fd, change.ident, change.filter,
|
||||
change.flags, change.fflags, change.data,
|
||||
change.udata);
|
||||
}
|
||||
|
|
@ -396,7 +398,7 @@ orbis::SysResult orbis::sys_kevent(Thread *thread, sint fd,
|
|||
}
|
||||
}
|
||||
|
||||
// ORBIS_LOG_TODO(__FUNCTION__, "kevent wakeup", fd);
|
||||
// ORBIS_LOG_TODO(__FUNCTION__, "kevent wakeup", (int)fd);
|
||||
|
||||
// for (auto evt : result) {
|
||||
// ORBIS_LOG_TODO(__FUNCTION__,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ orbis::SysResult orbis::sys_execve(Thread *thread, ptr<char> fname,
|
|||
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_fexecve(Thread *thread, sint fd,
|
||||
orbis::SysResult orbis::sys_fexecve(Thread *thread, FileDescriptor fd,
|
||||
ptr<ptr<char>> argv, ptr<ptr<char>> envv) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
#include "sys/sysproto.hpp"
|
||||
#include "thread/Process.hpp"
|
||||
#include "thread/Thread.hpp"
|
||||
#include "thread/types.hpp"
|
||||
#include "uio.hpp"
|
||||
#include <sstream>
|
||||
|
||||
orbis::SysResult orbis::sys_read(Thread *thread, sint fd, ptr<void> buf,
|
||||
size_t nbyte) {
|
||||
orbis::SysResult orbis::sys_read(Thread *thread, FileDescriptor fd,
|
||||
ptr<void> buf, size_t nbyte) {
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -42,13 +42,13 @@ orbis::SysResult orbis::sys_read(Thread *thread, sint fd, ptr<void> buf,
|
|||
auto cnt = io.offset - file->nextOff;
|
||||
file->nextOff = io.offset;
|
||||
|
||||
// ORBIS_LOG_ERROR(__FUNCTION__, fd, buf, nbyte, cnt);
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, (int)fd, buf, nbyte, cnt);
|
||||
thread->retval[0] = cnt;
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_pread(Thread *thread, sint fd, ptr<void> buf,
|
||||
size_t nbyte, off_t offset) {
|
||||
// ORBIS_LOG_ERROR(__FUNCTION__, fd, buf, nbyte, offset);
|
||||
orbis::SysResult orbis::sys_pread(Thread *thread, FileDescriptor fd,
|
||||
ptr<void> buf, size_t nbyte, off_t offset) {
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, (int)fd, buf, nbyte, offset);
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -79,13 +79,13 @@ orbis::SysResult orbis::sys_pread(Thread *thread, sint fd, ptr<void> buf,
|
|||
thread->retval[0] = io.offset - offset;
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_freebsd6_pread(Thread *thread, sint fd,
|
||||
orbis::SysResult orbis::sys_freebsd6_pread(Thread *thread, FileDescriptor fd,
|
||||
ptr<void> buf, size_t nbyte, sint,
|
||||
off_t offset) {
|
||||
return sys_pread(thread, fd, buf, nbyte, offset);
|
||||
}
|
||||
orbis::SysResult orbis::sys_readv(Thread *thread, sint fd, ptr<IoVec> iovp,
|
||||
uint iovcnt) {
|
||||
orbis::SysResult orbis::sys_readv(Thread *thread, FileDescriptor fd,
|
||||
ptr<IoVec> iovp, uint iovcnt) {
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -117,8 +117,8 @@ orbis::SysResult orbis::sys_readv(Thread *thread, sint fd, ptr<IoVec> iovp,
|
|||
thread->retval[0] = cnt;
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_preadv(Thread *thread, sint fd, ptr<IoVec> iovp,
|
||||
uint iovcnt, off_t offset) {
|
||||
orbis::SysResult orbis::sys_preadv(Thread *thread, FileDescriptor fd,
|
||||
ptr<IoVec> iovp, uint iovcnt, off_t offset) {
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -148,8 +148,10 @@ orbis::SysResult orbis::sys_preadv(Thread *thread, sint fd, ptr<IoVec> iovp,
|
|||
thread->retval[0] = io.offset - offset;
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_write(Thread *thread, sint fd, ptr<const void> buf,
|
||||
size_t nbyte) {
|
||||
orbis::SysResult orbis::sys_write(Thread *thread, FileDescriptor fd,
|
||||
ptr<const void> buf, size_t nbyte) {
|
||||
// ORBIS_LOG_ERROR(__FUNCTION__, (int)fd, buf, nbyte);
|
||||
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -183,8 +185,11 @@ orbis::SysResult orbis::sys_write(Thread *thread, sint fd, ptr<const void> buf,
|
|||
thread->retval[0] = cnt;
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_pwrite(Thread *thread, sint fd, ptr<const void> buf,
|
||||
size_t nbyte, off_t offset) {
|
||||
orbis::SysResult orbis::sys_pwrite(Thread *thread, FileDescriptor fd,
|
||||
ptr<const void> buf, size_t nbyte,
|
||||
off_t offset) {
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, (int)fd, buf, nbyte, offset);
|
||||
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -215,13 +220,13 @@ orbis::SysResult orbis::sys_pwrite(Thread *thread, sint fd, ptr<const void> buf,
|
|||
thread->retval[0] = io.offset - offset;
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_freebsd6_pwrite(Thread *thread, sint fd,
|
||||
orbis::SysResult orbis::sys_freebsd6_pwrite(Thread *thread, FileDescriptor fd,
|
||||
ptr<const void> buf, size_t nbyte,
|
||||
sint, off_t offset) {
|
||||
return sys_pwrite(thread, fd, buf, nbyte, offset);
|
||||
}
|
||||
orbis::SysResult orbis::sys_writev(Thread *thread, sint fd, ptr<IoVec> iovp,
|
||||
uint iovcnt) {
|
||||
orbis::SysResult orbis::sys_writev(Thread *thread, FileDescriptor fd,
|
||||
ptr<IoVec> iovp, uint iovcnt) {
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -254,8 +259,9 @@ orbis::SysResult orbis::sys_writev(Thread *thread, sint fd, ptr<IoVec> iovp,
|
|||
thread->retval[0] = cnt;
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_pwritev(Thread *thread, sint fd, ptr<IoVec> iovp,
|
||||
uint iovcnt, off_t offset) {
|
||||
orbis::SysResult orbis::sys_pwritev(Thread *thread, FileDescriptor fd,
|
||||
ptr<IoVec> iovp, uint iovcnt,
|
||||
off_t offset) {
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -284,7 +290,8 @@ orbis::SysResult orbis::sys_pwritev(Thread *thread, sint fd, ptr<IoVec> iovp,
|
|||
thread->retval[0] = io.offset - offset;
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_ftruncate(Thread *thread, sint fd, off_t length) {
|
||||
orbis::SysResult orbis::sys_ftruncate(Thread *thread, FileDescriptor fd,
|
||||
off_t length) {
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -295,15 +302,16 @@ orbis::SysResult orbis::sys_ftruncate(Thread *thread, sint fd, off_t length) {
|
|||
return ErrorCode::NOTSUP;
|
||||
}
|
||||
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, fd, length);
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, (int)fd, length);
|
||||
std::lock_guard lock(file->mtx);
|
||||
return truncate(file.get(), length, thread);
|
||||
}
|
||||
orbis::SysResult orbis::sys_freebsd6_ftruncate(Thread *thread, sint fd, sint,
|
||||
orbis::SysResult orbis::sys_freebsd6_ftruncate(Thread *thread,
|
||||
FileDescriptor fd, sint,
|
||||
off_t length) {
|
||||
return sys_ftruncate(thread, fd, length);
|
||||
}
|
||||
orbis::SysResult orbis::sys_ioctl(Thread *thread, sint fd, ulong com,
|
||||
orbis::SysResult orbis::sys_ioctl(Thread *thread, FileDescriptor fd, ulong com,
|
||||
caddr_t data) {
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ orbis::SysResult orbis::sys___mac_set_proc(Thread *thread,
|
|||
ptr<struct mac> mac_p) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys___mac_get_fd(Thread *thread, sint fd,
|
||||
orbis::SysResult orbis::sys___mac_get_fd(Thread *thread, FileDescriptor fd,
|
||||
ptr<struct mac> mac_p) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ orbis::SysResult orbis::sys___mac_get_file(Thread *thread, ptr<const char> path,
|
|||
ptr<struct mac> mac_p) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys___mac_set_fd(Thread *thread, sint fd,
|
||||
orbis::SysResult orbis::sys___mac_set_fd(Thread *thread, FileDescriptor fd,
|
||||
ptr<struct mac> mac_p) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,14 @@
|
|||
#include "thread/Thread.hpp"
|
||||
#include "utils/Logs.hpp"
|
||||
#include <pipe.hpp>
|
||||
#include <utility>
|
||||
|
||||
orbis::SysResult orbis::sys_pipe(Thread *thread) {
|
||||
auto [a, b] = createPipe();
|
||||
auto fd0 = thread->tproc->fileDescriptors.insert(a);
|
||||
auto fd1 = thread->tproc->fileDescriptors.insert(b);
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, fd0, fd1);
|
||||
thread->retval[0] = fd0;
|
||||
thread->retval[1] = fd1;
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, (int)fd0, (int)fd1);
|
||||
thread->retval[0] = std::to_underlying(fd0);
|
||||
thread->retval[1] = std::to_underlying(fd1);
|
||||
return {};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "sys/sysproto.hpp"
|
||||
|
||||
orbis::SysResult orbis::sys_pdgetpid(Thread *thread, sint fd, ptr<pid_t> pidp) {
|
||||
orbis::SysResult orbis::sys_pdgetpid(Thread *thread, FileDescriptor fd,
|
||||
ptr<pid_t> pidp) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,13 +32,11 @@ struct orbis::AppMountInfo {
|
|||
|
||||
static_assert(sizeof(orbis::AppMountInfo) == 120);
|
||||
|
||||
orbis::SysResult orbis::sys_netcontrol(Thread *thread, sint fd, uint op,
|
||||
ptr<void> buf, uint nbuf) {
|
||||
orbis::SysResult orbis::sys_netcontrol(Thread *thread, FileDescriptor fd,
|
||||
uint op, ptr<void> buf, uint nbuf) {
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_netabort(Thread *thread /* TODO */) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_netabort(Thread *thread /* TODO */) { return {}; }
|
||||
orbis::SysResult orbis::sys_netgetsockinfo(Thread *thread /* TODO */) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
|
@ -54,15 +52,15 @@ orbis::SysResult orbis::sys_socketex(Thread *thread, ptr<const char> name,
|
|||
}
|
||||
|
||||
auto fd = thread->tproc->fileDescriptors.insert(file);
|
||||
ORBIS_LOG_WARNING("Socket opened", name, fd);
|
||||
thread->retval[0] = fd;
|
||||
ORBIS_LOG_WARNING("Socket opened", name, (int)fd);
|
||||
thread->retval[0] = std::to_underlying(fd);
|
||||
return {};
|
||||
}
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_socketclose(Thread *thread, sint fd) {
|
||||
orbis::SysResult orbis::sys_socketclose(Thread *thread, FileDescriptor fd) {
|
||||
// This syscall is identical to sys_close
|
||||
ORBIS_LOG_NOTICE(__FUNCTION__, fd);
|
||||
ORBIS_LOG_NOTICE(__FUNCTION__, (int)fd);
|
||||
if (thread->tproc->fileDescriptors.close(fd)) {
|
||||
return {};
|
||||
}
|
||||
|
|
@ -469,7 +467,8 @@ orbis::SysResult orbis::sys_batch_map(Thread *thread, sint unk,
|
|||
result = sys_mmap(
|
||||
thread, _entry.start, _entry.length,
|
||||
rx::EnumBitSet<vmem::Protection>::fromUnderlying(_entry.protection),
|
||||
vmem::MapFlags::Void | vmem::MapFlags::Anon | flags, -1, 0);
|
||||
vmem::MapFlags::Void | vmem::MapFlags::Anon | flags,
|
||||
FileDescriptor::Invalid, 0);
|
||||
break;
|
||||
case 4:
|
||||
result = sys_mtypeprotect(
|
||||
|
|
@ -1209,8 +1208,8 @@ orbis::SysResult orbis::sys_randomized_path(Thread *thread, sint type,
|
|||
}
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_rdup(Thread *thread, sint pid, sint fd) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, pid, fd);
|
||||
orbis::SysResult orbis::sys_rdup(Thread *thread, pid_t pid, FileDescriptor fd) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, pid, (int)fd);
|
||||
auto process = pid == -1 || pid == thread->tproc->pid ? thread->tproc
|
||||
: findProcessById(pid);
|
||||
|
||||
|
|
@ -1223,7 +1222,8 @@ orbis::SysResult orbis::sys_rdup(Thread *thread, sint pid, sint fd) {
|
|||
return ErrorCode::BADF;
|
||||
}
|
||||
|
||||
thread->retval[0] = thread->tproc->fileDescriptors.insert(std::move(file));
|
||||
thread->retval[0] = std::to_underlying(
|
||||
thread->tproc->fileDescriptors.insert(std::move(file)));
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_dl_get_metadata(Thread *thread /* TODO */) {
|
||||
|
|
@ -1771,7 +1771,7 @@ orbis::SysResult orbis::sys_blockpool_open(Thread *thread) {
|
|||
return ErrorCode::MFILE;
|
||||
}
|
||||
|
||||
thread->retval[0] = fd;
|
||||
thread->retval[0] = std::to_underlying(fd);
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult
|
||||
|
|
|
|||
|
|
@ -134,7 +134,8 @@ orbis::SysResult orbis::sys_kill(Thread *thread, sint pid, sint signum) {
|
|||
return {};
|
||||
}
|
||||
|
||||
orbis::SysResult orbis::sys_pdkill(Thread *thread, sint fd, sint signum) {
|
||||
orbis::SysResult orbis::sys_pdkill(Thread *thread, FileDescriptor fd,
|
||||
sint signum) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_sigqueue(Thread *thread, pid_t pid, sint signum,
|
||||
|
|
|
|||
|
|
@ -18,16 +18,16 @@ orbis::SysResult orbis::sys_socket(Thread *thread, sint domain, sint type,
|
|||
}
|
||||
|
||||
auto fd = thread->tproc->fileDescriptors.insert(file);
|
||||
ORBIS_LOG_WARNING("Socket opened", fd);
|
||||
thread->retval[0] = fd;
|
||||
ORBIS_LOG_WARNING("Socket opened", (int)fd);
|
||||
thread->retval[0] = std::to_underlying(fd);
|
||||
return {};
|
||||
}
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
||||
orbis::SysResult orbis::sys_bind(Thread *thread, sint s, caddr_t name,
|
||||
orbis::SysResult orbis::sys_bind(Thread *thread, FileDescriptor s, caddr_t name,
|
||||
sint namelen) {
|
||||
// ORBIS_LOG_ERROR(__FUNCTION__, s, name, namelen);
|
||||
// ORBIS_LOG_ERROR(__FUNCTION__, (int)s, name, namelen);
|
||||
|
||||
auto file = thread->tproc->fileDescriptors.get(s);
|
||||
if (file == nullptr) {
|
||||
|
|
@ -41,8 +41,9 @@ orbis::SysResult orbis::sys_bind(Thread *thread, sint s, caddr_t name,
|
|||
return ErrorCode::NOTSUP;
|
||||
}
|
||||
|
||||
orbis::SysResult orbis::sys_listen(Thread *thread, sint s, sint backlog) {
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, s, backlog);
|
||||
orbis::SysResult orbis::sys_listen(Thread *thread, FileDescriptor s,
|
||||
sint backlog) {
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, (int)s, backlog);
|
||||
auto file = thread->tproc->fileDescriptors.get(s);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -55,10 +56,10 @@ orbis::SysResult orbis::sys_listen(Thread *thread, sint s, sint backlog) {
|
|||
return ErrorCode::NOTSUP;
|
||||
}
|
||||
|
||||
orbis::SysResult orbis::sys_accept(Thread *thread, sint s,
|
||||
orbis::SysResult orbis::sys_accept(Thread *thread, FileDescriptor s,
|
||||
ptr<SocketAddress> from,
|
||||
ptr<uint32_t> fromlenaddr) {
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, s, from, fromlenaddr);
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, (int)s, from, fromlenaddr);
|
||||
auto file = thread->tproc->fileDescriptors.get(s);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -71,8 +72,8 @@ orbis::SysResult orbis::sys_accept(Thread *thread, sint s,
|
|||
return ErrorCode::NOTSUP;
|
||||
}
|
||||
|
||||
orbis::SysResult orbis::sys_connect(Thread *thread, sint s, caddr_t name,
|
||||
sint namelen) {
|
||||
orbis::SysResult orbis::sys_connect(Thread *thread, FileDescriptor s,
|
||||
caddr_t name, sint namelen) {
|
||||
auto file = thread->tproc->fileDescriptors.get(s);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -99,26 +100,24 @@ orbis::SysResult orbis::sys_socketpair(Thread *thread, sint domain, sint type,
|
|||
auto aFd = thread->tproc->fileDescriptors.insert(a);
|
||||
auto bFd = thread->tproc->fileDescriptors.insert(b);
|
||||
|
||||
if (auto errc = uwrite(rsv, aFd); errc != ErrorCode{}) {
|
||||
return errc;
|
||||
}
|
||||
ORBIS_RET_ON_ERROR(uwrite(rsv, std::to_underlying(aFd)));
|
||||
|
||||
return uwrite(rsv + 1, bFd);
|
||||
return uwrite(rsv + 1, std::to_underlying(bFd));
|
||||
}
|
||||
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_sendto(Thread *thread, sint s, caddr_t buf,
|
||||
size_t len, sint flags, caddr_t to,
|
||||
sint tolen) {
|
||||
orbis::SysResult orbis::sys_sendto(Thread *thread, FileDescriptor s,
|
||||
caddr_t buf, size_t len, sint flags,
|
||||
caddr_t to, sint tolen) {
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_sendmsg(Thread *thread, sint s,
|
||||
orbis::SysResult orbis::sys_sendmsg(Thread *thread, FileDescriptor s,
|
||||
ptr<struct msghdr> msg, sint flags) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_recvfrom(Thread *thread, sint s, caddr_t buf,
|
||||
size_t len, sint flags,
|
||||
orbis::SysResult orbis::sys_recvfrom(Thread *thread, FileDescriptor s,
|
||||
caddr_t buf, size_t len, sint flags,
|
||||
ptr<SocketAddress> from,
|
||||
ptr<uint32_t> fromlenaddr) {
|
||||
auto file = thread->tproc->fileDescriptors.get(s);
|
||||
|
|
@ -133,7 +132,7 @@ orbis::SysResult orbis::sys_recvfrom(Thread *thread, sint s, caddr_t buf,
|
|||
|
||||
return ErrorCode::NOTSUP;
|
||||
}
|
||||
orbis::SysResult orbis::sys_recvmsg(Thread *thread, sint s,
|
||||
orbis::SysResult orbis::sys_recvmsg(Thread *thread, FileDescriptor s,
|
||||
ptr<struct msghdr> msg, sint flags) {
|
||||
auto file = thread->tproc->fileDescriptors.get(s);
|
||||
if (file == nullptr) {
|
||||
|
|
@ -146,7 +145,8 @@ orbis::SysResult orbis::sys_recvmsg(Thread *thread, sint s,
|
|||
|
||||
return ErrorCode::NOTSUP;
|
||||
}
|
||||
orbis::SysResult orbis::sys_shutdown(Thread *thread, sint s, sint how) {
|
||||
orbis::SysResult orbis::sys_shutdown(Thread *thread, FileDescriptor s,
|
||||
sint how) {
|
||||
auto file = thread->tproc->fileDescriptors.get(s);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -158,9 +158,10 @@ orbis::SysResult orbis::sys_shutdown(Thread *thread, sint s, sint how) {
|
|||
|
||||
return ErrorCode::NOTSUP;
|
||||
}
|
||||
orbis::SysResult orbis::sys_setsockopt(Thread *thread, sint s, sint level,
|
||||
sint name, caddr_t val, sint valsize) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, s, level, name, val, valsize);
|
||||
orbis::SysResult orbis::sys_setsockopt(Thread *thread, FileDescriptor s,
|
||||
sint level, sint name, caddr_t val,
|
||||
sint valsize) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, (int)s, level, name, val, valsize);
|
||||
auto file = thread->tproc->fileDescriptors.get(s);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -172,10 +173,10 @@ orbis::SysResult orbis::sys_setsockopt(Thread *thread, sint s, sint level,
|
|||
|
||||
return ErrorCode::NOTSUP;
|
||||
}
|
||||
orbis::SysResult orbis::sys_getsockopt(Thread *thread, sint s, sint level,
|
||||
sint name, caddr_t val,
|
||||
orbis::SysResult orbis::sys_getsockopt(Thread *thread, FileDescriptor s,
|
||||
sint level, sint name, caddr_t val,
|
||||
ptr<sint> avalsize) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, s, level, name, val, avalsize);
|
||||
ORBIS_LOG_TODO(__FUNCTION__, (int)s, level, name, val, avalsize);
|
||||
auto file = thread->tproc->fileDescriptors.get(s);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -187,21 +188,21 @@ orbis::SysResult orbis::sys_getsockopt(Thread *thread, sint s, sint level,
|
|||
|
||||
return ErrorCode::NOTSUP;
|
||||
}
|
||||
orbis::SysResult orbis::sys_getsockname(Thread *thread, sint fdes,
|
||||
orbis::SysResult orbis::sys_getsockname(Thread *thread, FileDescriptor fdes,
|
||||
ptr<SocketAddress> asa,
|
||||
ptr<uint32_t> alen) {
|
||||
// return uwrite<uint32_t>(alen, sizeof(SockAddr));
|
||||
ORBIS_LOG_TODO(__FUNCTION__);
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_getpeername(Thread *thread, sint fdes,
|
||||
orbis::SysResult orbis::sys_getpeername(Thread *thread, FileDescriptor fdes,
|
||||
ptr<SocketAddress> asa,
|
||||
ptr<uint32_t> alen) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_sendfile(Thread *thread, sint fd, sint s,
|
||||
off_t offset, size_t nbytes,
|
||||
ptr<struct sf_hdtr> hdtr,
|
||||
orbis::SysResult orbis::sys_sendfile(Thread *thread, FileDescriptor fd,
|
||||
FileDescriptor s, off_t offset,
|
||||
size_t nbytes, ptr<struct sf_hdtr> hdtr,
|
||||
ptr<off_t> sbytes, sint flags) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "thread/Process.hpp"
|
||||
#include "thread/ProcessOps.hpp"
|
||||
#include "thread/Thread.hpp"
|
||||
#include <utility>
|
||||
|
||||
orbis::SysResult orbis::sys_shm_open(Thread *thread, ptr<const char> path,
|
||||
sint flags, mode_t mode) {
|
||||
|
|
@ -20,7 +21,7 @@ orbis::SysResult orbis::sys_shm_open(Thread *thread, ptr<const char> path,
|
|||
return result;
|
||||
}
|
||||
|
||||
thread->retval[0] = thread->tproc->fileDescriptors.insert(file);
|
||||
thread->retval[0] = std::to_underlying(thread->tproc->fileDescriptors.insert(file));
|
||||
return {};
|
||||
}
|
||||
return ErrorCode::NOSYS;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ orbis::SysResult orbis::sys_quotactl(Thread *thread, ptr<char> path, sint cmd,
|
|||
|
||||
orbis::SysResult orbis::sys_statfs(Thread *thread, ptr<char> path,
|
||||
ptr<StatFs> buf) {
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, path);
|
||||
if (buf == 0) {
|
||||
thread->retval[0] = 1;
|
||||
return {};
|
||||
|
|
@ -29,7 +30,8 @@ orbis::SysResult orbis::sys_statfs(Thread *thread, ptr<char> path,
|
|||
thread->retval[0] = 1;
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_fstatfs(Thread *thread, sint fd, ptr<StatFs> buf) {
|
||||
orbis::SysResult orbis::sys_fstatfs(Thread *thread, FileDescriptor fd,
|
||||
ptr<StatFs> buf) {
|
||||
if (buf == 0) {
|
||||
thread->retval[0] = 1;
|
||||
return {};
|
||||
|
|
@ -48,7 +50,7 @@ orbis::SysResult orbis::sys_getfsstat(Thread *thread, ptr<StatFs> buf,
|
|||
slong bufsize, sint flags) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_fchdir(Thread *thread, sint fd) {
|
||||
orbis::SysResult orbis::sys_fchdir(Thread *thread, FileDescriptor fd) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_chdir(Thread *thread, ptr<char> path) {
|
||||
|
|
@ -72,18 +74,18 @@ orbis::SysResult orbis::sys_open(Thread *thread, ptr<const char> path,
|
|||
}
|
||||
|
||||
auto fd = thread->tproc->fileDescriptors.insert(file);
|
||||
thread->retval[0] = fd;
|
||||
thread->retval[0] = std::to_underlying(fd);
|
||||
return {};
|
||||
}
|
||||
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
||||
orbis::SysResult orbis::sys_openat(Thread *thread, sint fd, ptr<char> path,
|
||||
sint flag, mode_t mode) {
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, fd, path, flag, mode);
|
||||
orbis::SysResult orbis::sys_openat(Thread *thread, FileDescriptor fd,
|
||||
ptr<char> path, sint flag, mode_t mode) {
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, (int)fd, path, flag, mode);
|
||||
|
||||
if (fd == -100) {
|
||||
if (fd == FileDescriptor(-100)) {
|
||||
std::string cwd;
|
||||
{
|
||||
std::lock_guard lock(thread->tproc->mtx);
|
||||
|
|
@ -104,31 +106,32 @@ orbis::SysResult orbis::sys_mknod(Thread *thread, ptr<char> path, sint mode,
|
|||
sint dev) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_mknodat(Thread *thread, sint fd, ptr<char> path,
|
||||
mode_t mode, dev_t dev) {
|
||||
orbis::SysResult orbis::sys_mknodat(Thread *thread, FileDescriptor fd,
|
||||
ptr<char> path, mode_t mode, dev_t dev) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_mkfifo(Thread *thread, ptr<char> path, sint mode) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_mkfifoat(Thread *thread, sint fd, ptr<char> path,
|
||||
mode_t mode) {
|
||||
orbis::SysResult orbis::sys_mkfifoat(Thread *thread, FileDescriptor fd,
|
||||
ptr<char> path, mode_t mode) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_link(Thread *thread, ptr<char> path,
|
||||
ptr<char> link) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_linkat(Thread *thread, sint fd1, ptr<char> path1,
|
||||
sint fd2, ptr<char> path2, sint flag) {
|
||||
orbis::SysResult orbis::sys_linkat(Thread *thread, FileDescriptor fd1,
|
||||
ptr<char> path1, FileDescriptor fd2,
|
||||
ptr<char> path2, sint flag) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_symlink(Thread *thread, ptr<char> path,
|
||||
ptr<char> link) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_symlinkat(Thread *thread, ptr<char> path1, sint fd,
|
||||
ptr<char> path2) {
|
||||
orbis::SysResult orbis::sys_symlinkat(Thread *thread, ptr<char> path1,
|
||||
FileDescriptor fd, ptr<char> path2) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_undelete(Thread *thread, ptr<char> path) {
|
||||
|
|
@ -136,16 +139,17 @@ orbis::SysResult orbis::sys_undelete(Thread *thread, ptr<char> path) {
|
|||
}
|
||||
orbis::SysResult orbis::sys_unlink(Thread *thread, ptr<char> path) {
|
||||
if (auto unlink = thread->tproc->ops->unlink) {
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, path);
|
||||
return unlink(thread, path);
|
||||
}
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_unlinkat(Thread *thread, sint fd, ptr<char> path,
|
||||
sint flag) {
|
||||
orbis::SysResult orbis::sys_unlinkat(Thread *thread, FileDescriptor fd,
|
||||
ptr<char> path, sint flag) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_lseek(Thread *thread, sint fd, off_t offset,
|
||||
sint whence) {
|
||||
orbis::SysResult orbis::sys_lseek(Thread *thread, FileDescriptor fd,
|
||||
off_t offset, sint whence) {
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -184,12 +188,12 @@ orbis::SysResult orbis::sys_lseek(Thread *thread, sint fd, off_t offset,
|
|||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, fd, offset, whence, file->nextOff);
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, (int)fd, offset, whence, file->nextOff);
|
||||
thread->retval[0] = file->nextOff;
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_freebsd6_lseek(Thread *thread, sint fd, sint,
|
||||
off_t offset, sint whence) {
|
||||
orbis::SysResult orbis::sys_freebsd6_lseek(Thread *thread, FileDescriptor fd,
|
||||
sint, off_t offset, sint whence) {
|
||||
return sys_lseek(thread, fd, offset, whence);
|
||||
}
|
||||
orbis::SysResult orbis::sys_access(Thread *thread, ptr<char> path, sint flags) {
|
||||
|
|
@ -200,8 +204,8 @@ orbis::SysResult orbis::sys_access(Thread *thread, ptr<char> path, sint flags) {
|
|||
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_faccessat(Thread *thread, sint fd, ptr<char> path,
|
||||
sint mode, sint flag) {
|
||||
orbis::SysResult orbis::sys_faccessat(Thread *thread, FileDescriptor fd,
|
||||
ptr<char> path, sint mode, sint flag) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_eaccess(Thread *thread, ptr<char> path,
|
||||
|
|
@ -235,8 +239,8 @@ orbis::SysResult orbis::sys_stat(Thread *thread, ptr<char> path, ptr<Stat> ub) {
|
|||
|
||||
return uwrite(ub, _ub);
|
||||
}
|
||||
orbis::SysResult orbis::sys_fstatat(Thread *thread, sint fd, ptr<char> path,
|
||||
ptr<Stat> buf, sint flag) {
|
||||
orbis::SysResult orbis::sys_fstatat(Thread *thread, FileDescriptor fd,
|
||||
ptr<char> path, ptr<Stat> buf, sint flag) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_lstat(Thread *thread, ptr<char> path,
|
||||
|
|
@ -261,6 +265,8 @@ orbis::SysResult orbis::sys_lpathconf(Thread *thread, ptr<char> path,
|
|||
}
|
||||
orbis::SysResult orbis::sys_readlink(Thread *thread, ptr<char> path,
|
||||
ptr<char> buf, size_t count) {
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, path);
|
||||
|
||||
char _path[1024];
|
||||
ORBIS_RET_ON_ERROR(ureadString(_path, sizeof(_path), path));
|
||||
auto pathLen = std::strlen(_path);
|
||||
|
|
@ -278,8 +284,9 @@ orbis::SysResult orbis::sys_readlink(Thread *thread, ptr<char> path,
|
|||
thread->retval[0] = pathLen;
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_readlinkat(Thread *thread, sint fd, ptr<char> path,
|
||||
ptr<char> buf, size_t bufsize) {
|
||||
orbis::SysResult orbis::sys_readlinkat(Thread *thread, FileDescriptor fd,
|
||||
ptr<char> path, ptr<char> buf,
|
||||
size_t bufsize) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_chflags(Thread *thread, ptr<char> path,
|
||||
|
|
@ -290,36 +297,39 @@ orbis::SysResult orbis::sys_lchflags(Thread *thread, ptr<const char> path,
|
|||
sint flags) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_fchflags(Thread *thread, sint fd, sint flags) {
|
||||
orbis::SysResult orbis::sys_fchflags(Thread *thread, FileDescriptor fd,
|
||||
sint flags) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_chmod(Thread *thread, ptr<char> path, sint mode) {
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_fchmodat(Thread *thread, sint fd, ptr<char> path,
|
||||
mode_t mode, sint flag) {
|
||||
orbis::SysResult orbis::sys_fchmodat(Thread *thread, FileDescriptor fd,
|
||||
ptr<char> path, mode_t mode, sint flag) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_lchmod(Thread *thread, ptr<char> path,
|
||||
mode_t mode) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_fchmod(Thread *thread, sint fd, sint mode) {
|
||||
orbis::SysResult orbis::sys_fchmod(Thread *thread, FileDescriptor fd,
|
||||
sint mode) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_chown(Thread *thread, ptr<char> path, sint uid,
|
||||
sint gid) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_fchownat(Thread *thread, sint fd, ptr<char> path,
|
||||
uid_t uid, gid_t gid, sint flag) {
|
||||
orbis::SysResult orbis::sys_fchownat(Thread *thread, FileDescriptor fd,
|
||||
ptr<char> path, uid_t uid, gid_t gid,
|
||||
sint flag) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_lchown(Thread *thread, ptr<char> path, sint uid,
|
||||
sint gid) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_fchown(Thread *thread, sint fd, sint uid,
|
||||
orbis::SysResult orbis::sys_fchown(Thread *thread, FileDescriptor fd, sint uid,
|
||||
sint gid) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
|
@ -327,7 +337,8 @@ orbis::SysResult orbis::sys_utimes(Thread *thread, ptr<char> path,
|
|||
ptr<struct timeval> tptr) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_futimesat(Thread *thread, sint fd, ptr<char> path,
|
||||
orbis::SysResult orbis::sys_futimesat(Thread *thread, FileDescriptor fd,
|
||||
ptr<char> path,
|
||||
ptr<struct timeval> times) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
|
@ -335,12 +346,14 @@ orbis::SysResult orbis::sys_lutimes(Thread *thread, ptr<char> path,
|
|||
ptr<struct timeval> tptr) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_futimes(Thread *thread, sint fd,
|
||||
orbis::SysResult orbis::sys_futimes(Thread *thread, FileDescriptor fd,
|
||||
ptr<struct timeval> tptr) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_truncate(Thread *thread, ptr<char> path,
|
||||
off_t length) {
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, path, length);
|
||||
|
||||
rx::Ref<File> file;
|
||||
auto result = thread->tproc->ops->open(thread, path, 2, 0, &file);
|
||||
if (result.isError()) {
|
||||
|
|
@ -359,16 +372,20 @@ orbis::SysResult orbis::sys_freebsd6_truncate(Thread *thread, ptr<char> path,
|
|||
sint, off_t length) {
|
||||
return sys_truncate(thread, path, length);
|
||||
}
|
||||
orbis::SysResult orbis::sys_fsync(Thread *thread, sint fd) { return {}; }
|
||||
orbis::SysResult orbis::sys_fsync(Thread *thread, FileDescriptor fd) {
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_rename(Thread *thread, ptr<char> from,
|
||||
ptr<char> to) {
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, from, to);
|
||||
if (auto rename = thread->tproc->ops->rename) {
|
||||
return rename(thread, from, to);
|
||||
}
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_renameat(Thread *thread, sint oldfd, ptr<char> old,
|
||||
sint newfd, ptr<char> new_) {
|
||||
orbis::SysResult orbis::sys_renameat(Thread *thread, FileDescriptor oldfd,
|
||||
ptr<char> old, FileDescriptor newfd,
|
||||
ptr<char> new_) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_mkdir(Thread *thread, ptr<char> path, sint mode) {
|
||||
|
|
@ -377,8 +394,8 @@ orbis::SysResult orbis::sys_mkdir(Thread *thread, ptr<char> path, sint mode) {
|
|||
}
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_mkdirat(Thread *thread, sint fd, ptr<char> path,
|
||||
mode_t mode) {
|
||||
orbis::SysResult orbis::sys_mkdirat(Thread *thread, FileDescriptor fd,
|
||||
ptr<char> path, mode_t mode) {
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -395,15 +412,16 @@ orbis::SysResult orbis::sys_mkdirat(Thread *thread, sint fd, ptr<char> path,
|
|||
}
|
||||
|
||||
orbis::SysResult orbis::sys_rmdir(Thread *thread, ptr<char> path) {
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, path);
|
||||
if (auto rmdir = thread->tproc->ops->rmdir) {
|
||||
return rmdir(thread, path);
|
||||
}
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_getdirentries(Thread *thread, sint fd,
|
||||
orbis::SysResult orbis::sys_getdirentries(Thread *thread, FileDescriptor fd,
|
||||
ptr<char> buf, uint count,
|
||||
ptr<slong> basep) {
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, fd, (void *)buf, count, basep);
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, (int)fd, (void *)buf, count, basep);
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
|
|
@ -433,9 +451,9 @@ orbis::SysResult orbis::sys_getdirentries(Thread *thread, sint fd,
|
|||
thread->retval[0] = (next - pos) * sizeof(orbis::Dirent);
|
||||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_getdents(Thread *thread, sint fd, ptr<char> buf,
|
||||
size_t count) {
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, fd, (void *)buf, count);
|
||||
orbis::SysResult orbis::sys_getdents(Thread *thread, FileDescriptor fd,
|
||||
ptr<char> buf, size_t count) {
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, (int)fd, (void *)buf, count);
|
||||
return orbis::sys_getdirentries(thread, fd, buf, count, nullptr);
|
||||
}
|
||||
orbis::SysResult orbis::sys_umask(Thread *thread, sint newmask) {
|
||||
|
|
@ -467,11 +485,12 @@ orbis::SysResult orbis::sys_fhstatfs(Thread *thread,
|
|||
ptr<StatFs> buf) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_posix_fallocate(Thread *thread, sint fd,
|
||||
orbis::SysResult orbis::sys_posix_fallocate(Thread *thread, FileDescriptor fd,
|
||||
off_t offset, off_t len) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_posix_fadvise(Thread *thread, sint fd, off_t offset,
|
||||
off_t len, sint advice) {
|
||||
orbis::SysResult orbis::sys_posix_fadvise(Thread *thread, FileDescriptor fd,
|
||||
off_t offset, off_t len,
|
||||
sint advice) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ orbis::SysResult orbis::sys_aio_suspend(Thread *thread,
|
|||
ptr<const timespec> timeout) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_aio_cancel(Thread *thread, sint fd,
|
||||
orbis::SysResult orbis::sys_aio_cancel(Thread *thread, FileDescriptor fd,
|
||||
ptr<struct aiocb> aiocbp) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ orbis::SysResult orbis::sys_extattrctl(Thread *thread, ptr<char> path, char cmd,
|
|||
ptr<const char> attrname) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_extattr_set_fd(Thread *thread, sint fd,
|
||||
orbis::SysResult orbis::sys_extattr_set_fd(Thread *thread, FileDescriptor fd,
|
||||
sint attrnamespace,
|
||||
ptr<const char> attrname,
|
||||
ptr<void> data, size_t nbytes) {
|
||||
|
|
@ -25,7 +25,7 @@ orbis::SysResult orbis::sys_extattr_set_link(Thread *thread,
|
|||
ptr<void> data, size_t nbytes) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_extattr_get_fd(Thread *thread, sint fd,
|
||||
orbis::SysResult orbis::sys_extattr_get_fd(Thread *thread, FileDescriptor fd,
|
||||
sint attrnamespace,
|
||||
ptr<const char> attrname,
|
||||
ptr<void> data, size_t nbytes) {
|
||||
|
|
@ -44,7 +44,7 @@ orbis::SysResult orbis::sys_extattr_get_link(Thread *thread,
|
|||
ptr<void> data, size_t nbytes) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_extattr_delete_fd(Thread *thread, sint fd,
|
||||
orbis::SysResult orbis::sys_extattr_delete_fd(Thread *thread, FileDescriptor fd,
|
||||
sint attrnamespace,
|
||||
ptr<const char> attrname) {
|
||||
return ErrorCode::NOSYS;
|
||||
|
|
@ -60,7 +60,7 @@ orbis::SysResult orbis::sys_extattr_delete_link(Thread *thread,
|
|||
ptr<const char> attrname) {
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_extattr_list_fd(Thread *thread, sint fd,
|
||||
orbis::SysResult orbis::sys_extattr_list_fd(Thread *thread, FileDescriptor fd,
|
||||
sint attrnamespace, ptr<void> data,
|
||||
size_t nbytes) {
|
||||
return ErrorCode::NOSYS;
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ orbis::SysResult orbis::sys_sstk(Thread *, sint) {
|
|||
|
||||
orbis::SysResult orbis::sys_mmap(Thread *thread, uintptr_t addr, size_t len,
|
||||
rx::EnumBitSet<vmem::Protection> prot,
|
||||
rx::EnumBitSet<vmem::MapFlags> flags, sint fd,
|
||||
off_t pos) {
|
||||
rx::EnumBitSet<vmem::MapFlags> flags,
|
||||
FileDescriptor fd, off_t pos) {
|
||||
|
||||
std::uint64_t callerAddress = getCallerAddress(thread);
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ orbis::SysResult orbis::sys_mmap(Thread *thread, uintptr_t addr, size_t len,
|
|||
auto name = callerAddress ? rx::format("anon:{:012x}", callerAddress) : "";
|
||||
|
||||
if (flags & vmem::MapFlags::Void) {
|
||||
if (fd != -1 || pos != 0) {
|
||||
if (fd != FileDescriptor::Invalid || pos != 0) {
|
||||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ orbis::SysResult orbis::sys_mmap(Thread *thread, uintptr_t addr, size_t len,
|
|||
flags |= vmem::MapFlags::Anon;
|
||||
blockFlags |= vmem::BlockFlags::Stack;
|
||||
|
||||
if (fd != -1 || pos != 0) {
|
||||
if (fd != FileDescriptor::Invalid || pos != 0) {
|
||||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ orbis::SysResult orbis::sys_mmap(Thread *thread, uintptr_t addr, size_t len,
|
|||
}
|
||||
|
||||
if (flags & vmem::MapFlags::Anon) {
|
||||
if (fd != -1 || pos != 0) {
|
||||
if (fd != FileDescriptor::Invalid || pos != 0) {
|
||||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
|
|
@ -158,7 +158,7 @@ orbis::SysResult orbis::sys_freebsd6_mmap(Thread *thread, uintptr_t addr,
|
|||
size_t len,
|
||||
rx::EnumBitSet<vmem::Protection> prot,
|
||||
rx::EnumBitSet<vmem::MapFlags> flags,
|
||||
sint fd, sint, off_t pos) {
|
||||
FileDescriptor fd, sint, off_t pos) {
|
||||
return sys_mmap(thread, addr, len, prot, flags, fd, pos);
|
||||
}
|
||||
orbis::SysResult orbis::sys_msync(Thread *thread, uintptr_t addr, size_t len,
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ struct WrapImpl<Fn> {
|
|||
sysent result;
|
||||
result.narg = sizeof...(Args);
|
||||
result.call = &WrapImpl::call;
|
||||
result.format = [](uint64_t *values) -> std::string {
|
||||
result.format = [](Thread *thread, uint64_t *values) -> std::string {
|
||||
std::string result = getSysentName(&WrapImpl::call);
|
||||
result += "(";
|
||||
|
||||
|
|
@ -134,7 +134,9 @@ struct WrapImpl<Fn> {
|
|||
} else if constexpr (std::is_pointer_v<type>) {
|
||||
result += rx::format("{}", (void *)value);
|
||||
|
||||
// using pointee = std::remove_cvref_t<std::remove_pointer_t<type>>;
|
||||
// using pointee =
|
||||
// std::remove_cvref_t<std::remove_pointer_t<type>>;
|
||||
//
|
||||
// if constexpr (requires(rx::format_parse_context &ctx) {
|
||||
// rx::formatter<pointee>().parse(ctx);
|
||||
// }) {
|
||||
|
|
@ -149,6 +151,27 @@ struct WrapImpl<Fn> {
|
|||
// }
|
||||
// }
|
||||
// }
|
||||
} else if constexpr (std::is_same_v<type, FileDescriptor>) {
|
||||
result += rx::format("{}", std::to_underlying(value));
|
||||
if (std::to_underlying(value) >= 0) {
|
||||
auto file = thread->tproc->fileDescriptors.get(value);
|
||||
result += " (";
|
||||
|
||||
if (file) {
|
||||
if (file->ops && file->ops->toString) {
|
||||
result += file->ops->toString(file.get(), thread);
|
||||
} else if (file->device) {
|
||||
result += file->device->toString();
|
||||
} else {
|
||||
result += "<null device>";
|
||||
}
|
||||
|
||||
} else {
|
||||
result += "<invalid fd>";
|
||||
}
|
||||
|
||||
result += ")";
|
||||
}
|
||||
} else if constexpr (requires(rx::format_parse_context &ctx) {
|
||||
rx::formatter<type>().parse(ctx);
|
||||
}) {
|
||||
|
|
|
|||
|
|
@ -432,11 +432,13 @@ std::pair<rx::AddressRange, orbis::ErrorCode> orbis::vmem::mapFile(
|
|||
blockFlags |= file->device->blockFlags;
|
||||
|
||||
if (!validateProtection(prot)) {
|
||||
rx::println(stderr, "map: invalid prot {}", prot);
|
||||
return {{}, ErrorCode::INVAL};
|
||||
}
|
||||
|
||||
if (blockFlags & BlockFlags::PooledMemory) {
|
||||
if (size < dmem::kPageSize * 2 || size % dmem::kPageSize) {
|
||||
rx::println(stderr, "map: blockpool: invalid size {}", size);
|
||||
return {{}, ErrorCode::INVAL};
|
||||
}
|
||||
}
|
||||
|
|
@ -452,7 +454,9 @@ std::pair<rx::AddressRange, orbis::ErrorCode> orbis::vmem::mapFile(
|
|||
}
|
||||
|
||||
if (allocFlags & AllocationFlags::Fixed) {
|
||||
if (addressHint % alignment) {
|
||||
if (addressHint & (alignment - 1)) {
|
||||
rx::println(stderr, "map: invalid fixed address {:x}, alignment {:x}",
|
||||
addressHint, alignment);
|
||||
return {{}, ErrorCode::INVAL};
|
||||
}
|
||||
}
|
||||
|
|
@ -485,10 +489,12 @@ std::pair<rx::AddressRange, orbis::ErrorCode> orbis::vmem::mapFile(
|
|||
if (errc != std::errc{}) {
|
||||
if (errc == std::errc::not_enough_memory) {
|
||||
// virtual memory shouldn't care about physical memory
|
||||
rx::println(stderr, "map: OOM");
|
||||
return {{}, ErrorCode::INVAL};
|
||||
}
|
||||
|
||||
if (errc == std::errc::file_exists) {
|
||||
rx::println(stderr, "map: NoOverwrite overwrites memory");
|
||||
return {{}, ErrorCode::NOMEM};
|
||||
}
|
||||
|
||||
|
|
@ -502,6 +508,10 @@ std::pair<rx::AddressRange, orbis::ErrorCode> orbis::vmem::mapFile(
|
|||
}
|
||||
}
|
||||
|
||||
if (type != MemoryType::Invalid && !validateMemoryType(type, prot)) {
|
||||
return {{}, ErrorCode::ACCES};
|
||||
}
|
||||
|
||||
auto budget = process->getBudget();
|
||||
|
||||
if (blockFlags & BlockFlags::PooledMemory) {
|
||||
|
|
@ -522,8 +532,6 @@ std::pair<rx::AddressRange, orbis::ErrorCode> orbis::vmem::mapFile(
|
|||
}
|
||||
}
|
||||
|
||||
allocFlags = AllocationFlags::Fixed | (allocFlags & AllocationFlags::NoMerge);
|
||||
|
||||
if (blockFlags & BlockFlags::DirectMemory) {
|
||||
if (!budget->acquire(BudgetResource::Dmem, size)) {
|
||||
rx::println(stderr, "map: dmem budget: failed to allocate {:#x} bytes",
|
||||
|
|
@ -538,15 +546,14 @@ std::pair<rx::AddressRange, orbis::ErrorCode> orbis::vmem::mapFile(
|
|||
|
||||
if (blockFlags & BlockFlags::PooledMemory) {
|
||||
if (auto errc = blockpool::allocateControlBlock(); errc != ErrorCode{}) {
|
||||
rx::println(stderr,
|
||||
"map: blockpool: failed to allocate control block, error {}",
|
||||
errc);
|
||||
return {{}, errc};
|
||||
}
|
||||
allocationInfo.flagsEx |= BlockFlagsEx::PoolControl;
|
||||
}
|
||||
|
||||
if (type != MemoryType::Invalid && !validateMemoryType(type, prot)) {
|
||||
return {{}, ErrorCode::ACCES};
|
||||
}
|
||||
|
||||
if (auto error = process->invoke([=] {
|
||||
return file->device->map(range, fileOffset, prot, file, process);
|
||||
});
|
||||
|
|
@ -563,6 +570,7 @@ std::pair<rx::AddressRange, orbis::ErrorCode> orbis::vmem::mapFile(
|
|||
blockpool::releaseControlBlock();
|
||||
}
|
||||
|
||||
rx::println(stderr, "map: device allocation failure, blockFlags {}", blockFlags);
|
||||
return {{}, error};
|
||||
}
|
||||
|
||||
|
|
@ -595,8 +603,10 @@ std::pair<rx::AddressRange, orbis::ErrorCode> orbis::vmem::mapFile(
|
|||
}
|
||||
|
||||
{
|
||||
auto [_it, errc, _range] = vmem->map(range.beginAddress(), range.size(),
|
||||
allocationInfo, allocFlags, alignment);
|
||||
auto [_it, errc, _range] = vmem->map(
|
||||
range.beginAddress(), range.size(), allocationInfo,
|
||||
AllocationFlags::Fixed | (allocFlags & AllocationFlags::NoMerge),
|
||||
alignment);
|
||||
|
||||
rx::dieIf(errc != std::errc{}, "failed to commit virtual memory {}", errc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include "orbis/utils/Logs.hpp"
|
||||
#include "orbis/vmem.hpp"
|
||||
#include "rx/Mappable.hpp"
|
||||
#include "rx/format-base.hpp"
|
||||
#include "vfs.hpp"
|
||||
#include <cerrno>
|
||||
#include <dirent.h>
|
||||
|
|
@ -27,12 +28,13 @@
|
|||
#include <sys/uio.h>
|
||||
#include <sys/un.h>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
struct HostFile : orbis::File {
|
||||
bool closeOnExit = true;
|
||||
bool alignTruncate = false;
|
||||
orbis::kstring path;
|
||||
|
||||
~HostFile() {
|
||||
if (!closeOnExit && hostFd) {
|
||||
|
|
@ -508,8 +510,8 @@ static orbis::ErrorCode socket_accept(orbis::File *file,
|
|||
|
||||
auto guestSocket = wrapSocket(result, "", 1, 1, 0);
|
||||
auto guestFd = thread->tproc->fileDescriptors.insert(guestSocket);
|
||||
thread->retval[0] = guestFd;
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, socket->name, guestFd);
|
||||
thread->retval[0] = std::to_underlying(guestFd);
|
||||
ORBIS_LOG_ERROR(__FUNCTION__, socket->name, (int)guestFd);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
@ -611,11 +613,26 @@ orbis::ErrorCode socket_recvfrom(orbis::File *file, void *buf,
|
|||
return orbis::ErrorCode::NOTSUP;
|
||||
}
|
||||
|
||||
static std::string host_toString(orbis::File *file, orbis::Thread *thread) {
|
||||
auto hostFile = static_cast<HostFile *>(file);
|
||||
|
||||
if (!hostFile->path.empty()) {
|
||||
std::string result;
|
||||
result += '"';
|
||||
result += hostFile->path;
|
||||
result += '"';
|
||||
return result;
|
||||
}
|
||||
|
||||
return rx::format("host fd {}", hostFile->hostFd.native_handle());
|
||||
}
|
||||
|
||||
static const orbis::FileOps hostOps = {
|
||||
.read = host_read,
|
||||
.write = host_write,
|
||||
.truncate = host_truncate,
|
||||
.stat = host_stat,
|
||||
.toString = host_toString,
|
||||
};
|
||||
|
||||
static const orbis::FileOps socketOps = {
|
||||
|
|
@ -828,6 +845,7 @@ orbis::ErrorCode HostFsDevice::open(rx::Ref<orbis::File> *file,
|
|||
newFile->dirEntries = std::move(dirEntries);
|
||||
newFile->ops = &hostOps;
|
||||
newFile->device = this;
|
||||
newFile->path = path;
|
||||
*file = newFile;
|
||||
return {};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include "orbis/utils/Logs.hpp"
|
||||
#include "rx/Rc.hpp"
|
||||
#include <bits/types/struct_iovec.h>
|
||||
#include <string>
|
||||
// #include <rx/hexdump.hpp>
|
||||
|
||||
#define SNDCTL_DSP_RESET 0x20005000
|
||||
|
|
@ -37,6 +38,10 @@ struct AoutDevice : public orbis::IoDevice {
|
|||
orbis::ErrorCode open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) override;
|
||||
|
||||
[[nodiscard]] std::string toString() const override {
|
||||
return "aout" + std::to_string(id);
|
||||
}
|
||||
};
|
||||
|
||||
static orbis::ErrorCode aout_ioctl(orbis::File *file, std::uint64_t request,
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ struct BlockPoolDevice
|
|||
orbis::ErrorCode map(rx::AddressRange range, std::int64_t offset,
|
||||
rx::EnumBitSet<orbis::vmem::Protection> protection,
|
||||
orbis::File *file, orbis::Process *process) override;
|
||||
|
||||
[[nodiscard]] std::string toString() const override { return "blockpool"; }
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@
|
|||
#include "orbis/thread/Thread.hpp"
|
||||
#include "orbis/utils/Logs.hpp"
|
||||
#include "orbis/vmem.hpp"
|
||||
#include "rx/format.hpp"
|
||||
#include "rx/AddressRange.hpp"
|
||||
#include "rx/EnumBitSet.hpp"
|
||||
#include "rx/format.hpp"
|
||||
#include <string>
|
||||
|
||||
enum {
|
||||
DMEM_IOCTL_ALLOCATE = 0xc0288001,
|
||||
|
|
@ -42,6 +43,10 @@ struct DmemDevice
|
|||
orbis::ErrorCode map(rx::AddressRange range, std::int64_t offset,
|
||||
rx::EnumBitSet<orbis::vmem::Protection> protection,
|
||||
orbis::File *file, orbis::Process *process) override;
|
||||
|
||||
[[nodiscard]] std::string toString() const override {
|
||||
return "dmem" + std::to_string(index);
|
||||
}
|
||||
};
|
||||
|
||||
struct DmemFile : public orbis::File {};
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "orbis/utils/Logs.hpp"
|
||||
#include "orbis/vmem.hpp"
|
||||
#include "rx/Config.hpp"
|
||||
#include "rx/FileLock.hpp"
|
||||
#include "rx/die.hpp"
|
||||
#include "rx/format.hpp"
|
||||
#include "rx/mem.hpp"
|
||||
|
|
@ -299,26 +300,26 @@ static void onSysEnter(orbis::Thread *thread, int id, uint64_t *args,
|
|||
if (!g_traceSyscalls) {
|
||||
return;
|
||||
}
|
||||
flockfile(stderr);
|
||||
std::fprintf(stderr, " [%u] ", thread->tid);
|
||||
|
||||
rx::ScopedFileLock lock(stderr);
|
||||
rx::print(stderr, " [{}] ", thread->tid);
|
||||
|
||||
if (auto ent = getSyscallEnt(thread, id)) {
|
||||
std::fprintf(stderr, "%s\n", ent->format(args).c_str());
|
||||
rx::println(stderr, "{}", ent->format(thread, args).c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
std::fprintf(stderr, "sys_%u(", id);
|
||||
rx::print(stderr, "sys_{}(", id);
|
||||
|
||||
for (int i = 0; i < argsCount; ++i) {
|
||||
if (i != 0) {
|
||||
std::fprintf(stderr, ", ");
|
||||
rx::print(stderr, ", ");
|
||||
}
|
||||
|
||||
std::fprintf(stderr, "%#lx", args[i]);
|
||||
rx::print(stderr, "{:#x}", args[i]);
|
||||
}
|
||||
|
||||
std::fprintf(stderr, ")\n");
|
||||
funlockfile(stderr);
|
||||
rx::println(stderr, ")");
|
||||
}
|
||||
|
||||
static void onSysExit(orbis::Thread *thread, int id, uint64_t *args,
|
||||
|
|
@ -327,11 +328,11 @@ static void onSysExit(orbis::Thread *thread, int id, uint64_t *args,
|
|||
return;
|
||||
}
|
||||
|
||||
flockfile(stderr);
|
||||
rx::ScopedFileLock lock(stderr);
|
||||
rx::print(stderr, "{}: [{}] ", result.isError() ? 'E' : 'S', thread->tid);
|
||||
|
||||
if (auto ent = getSyscallEnt(thread, id)) {
|
||||
rx::print(stderr, "{}", ent->format(args));
|
||||
rx::print(stderr, "{}", ent->format(thread, args));
|
||||
} else {
|
||||
rx::print(stderr, "sys_{}(", id);
|
||||
|
||||
|
|
@ -352,7 +353,6 @@ static void onSysExit(orbis::Thread *thread, int id, uint64_t *args,
|
|||
if (result.isError()) {
|
||||
thread->where();
|
||||
}
|
||||
funlockfile(stderr);
|
||||
}
|
||||
|
||||
static void guestInitDev(orbis::Thread *thread, int stdinFd, int stdoutFd,
|
||||
|
|
|
|||
Loading…
Reference in a new issue