diff --git a/kernel/orbis/include/orbis/sys/sysproto.hpp b/kernel/orbis/include/orbis/sys/sysproto.hpp index e40e6b912..c26922aef 100644 --- a/kernel/orbis/include/orbis/sys/sysproto.hpp +++ b/kernel/orbis/include/orbis/sys/sysproto.hpp @@ -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 buf, size_t nbyte); -SysResult sys_write(Thread *thread, sint fd, ptr buf, size_t nbyte); +SysResult sys_read(Thread *thread, FileDescriptor fd, ptr buf, + size_t nbyte); +SysResult sys_write(Thread *thread, FileDescriptor fd, ptr buf, + size_t nbyte); SysResult sys_open(Thread *thread, ptr 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 status, sint options, ptr rusage); SysResult sys_link(Thread *thread, ptr path, ptr link); SysResult sys_unlink(Thread *thread, ptr path); SysResult sys_chdir(Thread *thread, ptr path); -SysResult sys_fchdir(Thread *thread, sint fd); +SysResult sys_fchdir(Thread *thread, FileDescriptor fd); SysResult sys_mknod(Thread *thread, ptr path, sint mode, sint dev); SysResult sys_chmod(Thread *thread, ptr path, sint mode); SysResult sys_chown(Thread *thread, ptr 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 msg, +SysResult sys_recvmsg(Thread *thread, FileDescriptor s, ptr msg, sint flags); -SysResult sys_sendmsg(Thread *thread, sint s, ptr msg, +SysResult sys_sendmsg(Thread *thread, FileDescriptor s, ptr 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 from, ptr fromlenaddr); -SysResult sys_accept(Thread *thread, sint s, ptr from, +SysResult sys_accept(Thread *thread, FileDescriptor s, ptr from, ptr fromlenaddr); -SysResult sys_getpeername(Thread *thread, sint fdes, ptr asa, - ptr alen); -SysResult sys_getsockname(Thread *thread, sint fdes, ptr asa, +SysResult sys_getpeername(Thread *thread, FileDescriptor fdes, ptr asa, ptr alen); +SysResult sys_getsockname(Thread *thread, FileDescriptor fdes, + ptr asa, ptr alen); SysResult sys_access(Thread *thread, ptr path, sint flags); SysResult sys_chflags(Thread *thread, ptr 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 namebuf, uint namelen); SysResult sys_setlogin(Thread *thread, ptr namebuf); SysResult sys_acct(Thread *thread, ptr path); SysResult sys_sigaltstack(Thread *thread, ptr ss, ptr 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 path); SysResult sys_symlink(Thread *thread, ptr path, ptr link); @@ -130,38 +132,42 @@ SysResult sys_setitimer(Thread *thread, uint which, ptr itv, SysResult sys_swapon(Thread *thread, ptr name); SysResult sys_getitimer(Thread *thread, uint which, ptr 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 in, ptr out, ptr ex, ptr 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 tp, ptr tzp); SysResult sys_getrusage(Thread *thread, sint who, ptr rusage); -SysResult sys_getsockopt(Thread *thread, sint s, sint level, sint name, - caddr_t val, ptr avalsize); -SysResult sys_readv(Thread *thread, sint fd, ptr iovp, uint iovcnt); -SysResult sys_writev(Thread *thread, sint fd, ptr iovp, uint iovcnt); +SysResult sys_getsockopt(Thread *thread, FileDescriptor s, sint level, + sint name, caddr_t val, ptr avalsize); +SysResult sys_readv(Thread *thread, FileDescriptor fd, ptr iovp, + uint iovcnt); +SysResult sys_writev(Thread *thread, FileDescriptor fd, ptr iovp, + uint iovcnt); SysResult sys_settimeofday(Thread *thread, ptr tp, ptr 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 from, ptr 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 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 rsv); SysResult sys_mkdir(Thread *thread, ptr 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 buf, +SysResult sys_freebsd6_pread(Thread *thread, FileDescriptor fd, ptr buf, size_t nbyte, sint pad, off_t offset); -SysResult sys_freebsd6_pwrite(Thread *thread, sint fd, ptr buf, - size_t nbyte, sint pad, off_t offset); +SysResult sys_freebsd6_pwrite(Thread *thread, FileDescriptor fd, + ptr buf, size_t nbyte, sint pad, + off_t offset); SysResult sys_setfib(Thread *thread, sint fib); SysResult sys_ntp_adjtime(Thread *thread, ptr 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 path, ptr ub); -SysResult sys_fstat(Thread *thread, sint fd, ptr ub); +SysResult sys_fstat(Thread *thread, FileDescriptor fd, ptr ub); SysResult sys_lstat(Thread *thread, ptr path, ptr ub); SysResult sys_pathconf(Thread *thread, ptr 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 rlp); SysResult sys_setrlimit(Thread *thread, uint which, ptr rlp); -SysResult sys_getdirentries(Thread *thread, sint fd, ptr buf, uint count, - ptr basep); +SysResult sys_getdirentries(Thread *thread, FileDescriptor fd, ptr buf, + uint count, ptr basep); SysResult sys_freebsd6_mmap(Thread *thread, uintptr_t addr, size_t len, rx::EnumBitSet prot, - rx::EnumBitSet 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 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 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 name, uint namelen, ptr old, ptr oldenp, ptr new_, @@ -219,7 +226,8 @@ SysResult sys___sysctl(Thread *thread, ptr 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 path); -SysResult sys_futimes(Thread *thread, sint fd, ptr tptr); +SysResult sys_futimes(Thread *thread, FileDescriptor fd, + ptr tptr); SysResult sys_getpgid(Thread *thread, pid_t pid); SysResult sys_poll(Thread *thread, ptr fds, uint nfds, sint timeout); @@ -265,16 +273,17 @@ SysResult sys_aio_write(Thread *thread, ptr aiocbp); SysResult sys_lio_listio(Thread *thread, sint mode, ptr> aiocbp, sint nent, ptr sig); -SysResult sys_getdents(Thread *thread, sint fd, ptr buf, size_t count); +SysResult sys_getdents(Thread *thread, FileDescriptor fd, ptr buf, + size_t count); SysResult sys_lchmod(Thread *thread, ptr path, mode_t mode); SysResult sys_lutimes(Thread *thread, ptr path, ptr tptr); SysResult sys_nstat(Thread *thread, ptr path, ptr ub); -SysResult sys_nfstat(Thread *thread, sint fd, ptr sb); +SysResult sys_nfstat(Thread *thread, FileDescriptor fd, ptr sb); SysResult sys_nlstat(Thread *thread, ptr path, ptr ub); -SysResult sys_preadv(Thread *thread, sint fd, ptr iovp, uint iovcnt, - off_t offset); -SysResult sys_pwritev(Thread *thread, sint fd, ptr iovp, uint iovcnt, - off_t offset); +SysResult sys_preadv(Thread *thread, FileDescriptor fd, ptr iovp, + uint iovcnt, off_t offset); +SysResult sys_pwritev(Thread *thread, FileDescriptor fd, ptr iovp, + uint iovcnt, off_t offset); SysResult sys_fhopen(Thread *thread, ptr u_fhp, sint flags); SysResult sys_fhstat(Thread *thread, ptr 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 aiocbp); SysResult sys_aio_suspend(Thread *thread, ptr aiocbp, sint nent, ptr timeout); -SysResult sys_aio_cancel(Thread *thread, sint fd, ptr aiocbp); +SysResult sys_aio_cancel(Thread *thread, FileDescriptor fd, + ptr aiocbp); SysResult sys_aio_error(Thread *thread, ptr aiocbp); SysResult sys_oaio_read(Thread *thread, ptr aiocbp); SysResult sys_oaio_write(Thread *thread, ptr aiocbp); @@ -367,17 +377,17 @@ SysResult sys_getresuid(Thread *thread, ptr ruid, ptr euid, SysResult sys_getresgid(Thread *thread, ptr rgid, ptr egid, ptr sgid); SysResult sys_kqueue(Thread *thread); -SysResult sys_kevent(Thread *thread, sint fd, ptr changelist, +SysResult sys_kevent(Thread *thread, FileDescriptor fd, ptr changelist, sint nchanges, ptr eventlist, sint nevents, ptr timeout); -SysResult sys_extattr_set_fd(Thread *thread, sint fd, sint attrnamespace, - ptr attrname, ptr data, - size_t nbytes); -SysResult sys_extattr_get_fd(Thread *thread, sint fd, sint attrnamespace, - ptr attrname, ptr data, - size_t nbytes); -SysResult sys_extattr_delete_fd(Thread *thread, sint fd, sint attrnamespace, - ptr attrname); +SysResult sys_extattr_set_fd(Thread *thread, FileDescriptor fd, + sint attrnamespace, ptr attrname, + ptr data, size_t nbytes); +SysResult sys_extattr_get_fd(Thread *thread, FileDescriptor fd, + sint attrnamespace, ptr attrname, + ptr data, size_t nbytes); +SysResult sys_extattr_delete_fd(Thread *thread, FileDescriptor fd, + sint attrnamespace, ptr attrname); SysResult sys___setugid(Thread *thread, sint flags); SysResult sys_eaccess(Thread *thread, ptr 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 iovp, uint iovcnt, sint flags); SysResult sys___mac_get_proc(Thread *thread, ptr mac_p); SysResult sys___mac_set_proc(Thread *thread, ptr mac_p); -SysResult sys___mac_get_fd(Thread *thread, sint fd, ptr mac_p); +SysResult sys___mac_get_fd(Thread *thread, FileDescriptor fd, + ptr mac_p); SysResult sys___mac_get_file(Thread *thread, ptr path, ptr mac_p); -SysResult sys___mac_set_fd(Thread *thread, sint fd, ptr mac_p); +SysResult sys___mac_set_fd(Thread *thread, FileDescriptor fd, + ptr mac_p); SysResult sys___mac_set_file(Thread *thread, ptr path, ptr mac_p); SysResult sys_kenv(Thread *thread, sint what, ptr name, ptr value, sint len); SysResult sys_lchflags(Thread *thread, ptr path, sint flags); SysResult sys_uuidgen(Thread *thread, ptr store, sint count); -SysResult sys_sendfile(Thread *thread, sint fd, sint s, off_t offset, - size_t nbytes, ptr hdtr, +SysResult sys_sendfile(Thread *thread, FileDescriptor fd, FileDescriptor s, + off_t offset, size_t nbytes, ptr hdtr, ptr sbytes, sint flags); SysResult sys_mac_syscall(Thread *thread, ptr policy, sint call, ptr arg); SysResult sys_getfsstat(Thread *thread, ptr buf, slong bufsize, sint flags); SysResult sys_statfs(Thread *thread, ptr path, ptr buf); -SysResult sys_fstatfs(Thread *thread, sint fd, ptr buf); +SysResult sys_fstatfs(Thread *thread, FileDescriptor fd, ptr buf); SysResult sys_fhstatfs(Thread *thread, ptr u_fhp, ptr 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 umtx); SysResult sys__umtx_unlock(Thread *thread, ptr umtx); SysResult sys_jail_attach(Thread *thread, sint jid); -SysResult sys_extattr_list_fd(Thread *thread, sint fd, sint attrnamespace, - ptr data, size_t nbytes); +SysResult sys_extattr_list_fd(Thread *thread, FileDescriptor fd, + sint attrnamespace, ptr data, + size_t nbytes); SysResult sys_extattr_list_file(Thread *thread, ptr path, sint attrnamespace, ptr data, size_t nbytes); @@ -522,16 +535,18 @@ SysResult sys_sctp_generic_recvmsg(Thread *thread, sint sd, ptr iov, sint iovlen, caddr_t from, SockLen fromlen, ptr sinfo, sint flags); -SysResult sys_pread(Thread *thread, sint fd, ptr buf, size_t nbyte, - off_t offset); -SysResult sys_pwrite(Thread *thread, sint fd, ptr buf, size_t nbyte, - off_t offset); +SysResult sys_pread(Thread *thread, FileDescriptor fd, ptr buf, + size_t nbyte, off_t offset); +SysResult sys_pwrite(Thread *thread, FileDescriptor fd, ptr buf, + size_t nbyte, off_t offset); SysResult sys_mmap(Thread *thread, uintptr_t addr, size_t len, rx::EnumBitSet prot, - rx::EnumBitSet flags, sint fd, off_t pos); -SysResult sys_lseek(Thread *thread, sint fd, off_t offset, sint whence); + rx::EnumBitSet flags, FileDescriptor fd, + off_t pos); +SysResult sys_lseek(Thread *thread, FileDescriptor fd, off_t offset, + sint whence); SysResult sys_truncate(Thread *thread, ptr 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 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 mask); -SysResult sys_faccessat(Thread *thread, sint fd, ptr path, sint mode, - sint flag); -SysResult sys_fchmodat(Thread *thread, sint fd, ptr path, mode_t mode, - sint flag); -SysResult sys_fchownat(Thread *thread, sint fd, ptr path, uid_t uid, - gid_t gid, sint flag); -SysResult sys_fexecve(Thread *thread, sint fd, ptr> argv, +SysResult sys_faccessat(Thread *thread, FileDescriptor fd, ptr path, + sint mode, sint flag); +SysResult sys_fchmodat(Thread *thread, FileDescriptor fd, ptr path, + mode_t mode, sint flag); +SysResult sys_fchownat(Thread *thread, FileDescriptor fd, ptr path, + uid_t uid, gid_t gid, sint flag); +SysResult sys_fexecve(Thread *thread, FileDescriptor fd, ptr> argv, ptr> envv); -SysResult sys_fstatat(Thread *thread, sint fd, ptr path, ptr buf, - sint flag); -SysResult sys_futimesat(Thread *thread, sint fd, ptr path, +SysResult sys_fstatat(Thread *thread, FileDescriptor fd, ptr path, + ptr buf, sint flag); +SysResult sys_futimesat(Thread *thread, FileDescriptor fd, ptr path, ptr times); -SysResult sys_linkat(Thread *thread, sint fd1, ptr path1, sint fd2, - ptr path2, sint flag); -SysResult sys_mkdirat(Thread *thread, sint fd, ptr path, mode_t mode); -SysResult sys_mkfifoat(Thread *thread, sint fd, ptr path, mode_t mode); -SysResult sys_mknodat(Thread *thread, sint fd, ptr path, mode_t mode, - dev_t dev); -SysResult sys_openat(Thread *thread, sint fd, ptr path, sint flag, - mode_t mode); -SysResult sys_readlinkat(Thread *thread, sint fd, ptr path, ptr buf, - size_t bufsize); -SysResult sys_renameat(Thread *thread, sint oldfd, ptr old, sint newfd, - ptr new_); -SysResult sys_symlinkat(Thread *thread, ptr path1, sint fd, +SysResult sys_linkat(Thread *thread, FileDescriptor fd1, ptr path1, + FileDescriptor fd2, ptr path2, sint flag); +SysResult sys_mkdirat(Thread *thread, FileDescriptor fd, ptr path, + mode_t mode); +SysResult sys_mkfifoat(Thread *thread, FileDescriptor fd, ptr path, + mode_t mode); +SysResult sys_mknodat(Thread *thread, FileDescriptor fd, ptr path, + mode_t mode, dev_t dev); +SysResult sys_openat(Thread *thread, FileDescriptor fd, ptr path, + sint flag, mode_t mode); +SysResult sys_readlinkat(Thread *thread, FileDescriptor fd, ptr path, + ptr buf, size_t bufsize); +SysResult sys_renameat(Thread *thread, FileDescriptor oldfd, ptr old, + FileDescriptor newfd, ptr new_); +SysResult sys_symlinkat(Thread *thread, ptr path1, FileDescriptor fd, ptr path2); -SysResult sys_unlinkat(Thread *thread, sint fd, ptr path, sint flag); +SysResult sys_unlinkat(Thread *thread, FileDescriptor fd, ptr path, + sint flag); SysResult sys_posix_openpt(Thread *thread, sint flags); SysResult sys_gssd_syscall(Thread *thread, ptr path); SysResult sys_jail_get(Thread *thread, ptr iovp, uint iovcnt, @@ -581,7 +599,7 @@ SysResult sys_jail_get(Thread *thread, ptr iovp, uint iovcnt, SysResult sys_jail_set(Thread *thread, ptr 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 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 buf); SysResult sys_lpathconf(Thread *thread, ptr path, sint name); -SysResult sys_cap_new(Thread *thread, sint fd, uint64_t rights); -SysResult sys_cap_getrights(Thread *thread, sint fd, ptr rights); +SysResult sys_cap_new(Thread *thread, FileDescriptor fd, uint64_t rights); +SysResult sys_cap_getrights(Thread *thread, FileDescriptor fd, + ptr rights); SysResult sys_cap_enter(Thread *thread); SysResult sys_cap_getmode(Thread *thread, ptr modep); SysResult sys_pdfork(Thread *thread, ptr fdp, sint flags); -SysResult sys_pdkill(Thread *thread, sint fd, sint signum); -SysResult sys_pdgetpid(Thread *thread, sint fd, ptr pidp); +SysResult sys_pdkill(Thread *thread, FileDescriptor fd, sint signum); +SysResult sys_pdgetpid(Thread *thread, FileDescriptor fd, ptr pidp); SysResult sys_pselect(Thread *thread, sint nd, ptr in, ptr ou, ptr ex, ptr ts, ptr sm); @@ -616,17 +635,18 @@ SysResult sys_rctl_add_rule(Thread *thread, ptr inbufp, SysResult sys_rctl_remove_rule(Thread *thread, ptr inbufp, size_t inbuflen, ptr 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 buf, - uint nbuf); +SysResult sys_netcontrol(Thread *thread, FileDescriptor fd, uint op, + ptr buf, uint nbuf); SysResult sys_netabort(Thread *thread /* TODO */); SysResult sys_netgetsockinfo(Thread *thread /* TODO */); SysResult sys_socketex(Thread *thread, ptr 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 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 arg0, ptr arg1); SysResult sys_randomized_path(Thread *thread, sint type, ptr path, ptr 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 */); diff --git a/kernel/orbis/include/orbis/thread/Process.hpp b/kernel/orbis/include/orbis/thread/Process.hpp index b9b546430..b368ec31c 100644 --- a/kernel/orbis/include/orbis/thread/Process.hpp +++ b/kernel/orbis/include/orbis/thread/Process.hpp @@ -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 semMap; rx::RcIdMap modulesMap; rx::RcIdMap threadsMap; - rx::RcIdMap fileDescriptors; + rx::RcIdMap fileDescriptors; rx::AddressRange libkernelRange; diff --git a/kernel/orbis/include/orbis/thread/types.hpp b/kernel/orbis/include/orbis/thread/types.hpp index c509d8943..4de66ca33 100644 --- a/kernel/orbis/include/orbis/thread/types.hpp +++ b/kernel/orbis/include/orbis/thread/types.hpp @@ -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; diff --git a/kernel/orbis/src/sys/sys_capability.cpp b/kernel/orbis/src/sys/sys_capability.cpp index 6f33f57bf..5a78c912e 100644 --- a/kernel/orbis/src/sys/sys_capability.cpp +++ b/kernel/orbis/src/sys/sys_capability.cpp @@ -6,10 +6,11 @@ orbis::SysResult orbis::sys_cap_enter(Thread *thread) { orbis::SysResult orbis::sys_cap_getmode(Thread *thread, ptr 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 rights) { return ErrorCode::NOSYS; } diff --git a/kernel/orbis/src/sys/sys_descrip.cpp b/kernel/orbis/src/sys/sys_descrip.cpp index b2a2b9439..cea098df7 100644 --- a/kernel/orbis/src/sys/sys_descrip.cpp +++ b/kernel/orbis/src/sys/sys_descrip.cpp @@ -4,11 +4,13 @@ #include "sys/sysproto.hpp" #include "thread/Process.hpp" #include "thread/Thread.hpp" +#include 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 ub) { +orbis::SysResult orbis::sys_fstat(Thread *thread, FileDescriptor fd, + ptr ub) { rx::Ref 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 ub) { return uwrite(ub, _ub); } -orbis::SysResult orbis::sys_nfstat(Thread *thread, sint fd, +orbis::SysResult orbis::sys_nfstat(Thread *thread, FileDescriptor fd, ptr 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; } diff --git a/kernel/orbis/src/sys/sys_event.cpp b/kernel/orbis/src/sys/sys_event.cpp index 5e591ccf1..3f42edf91 100644 --- a/kernel/orbis/src/sys/sys_event.cpp +++ b/kernel/orbis/src/sys/sys_event.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #ifdef __linux #include @@ -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 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 changelist, sint nchanges, ptr eventlist, sint nevents, ptr 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__, diff --git a/kernel/orbis/src/sys/sys_exec.cpp b/kernel/orbis/src/sys/sys_exec.cpp index 756d1fabb..8d8d7bdfc 100644 --- a/kernel/orbis/src/sys/sys_exec.cpp +++ b/kernel/orbis/src/sys/sys_exec.cpp @@ -11,7 +11,7 @@ orbis::SysResult orbis::sys_execve(Thread *thread, ptr fname, return ErrorCode::NOSYS; } -orbis::SysResult orbis::sys_fexecve(Thread *thread, sint fd, +orbis::SysResult orbis::sys_fexecve(Thread *thread, FileDescriptor fd, ptr> argv, ptr> envv) { return ErrorCode::NOSYS; } diff --git a/kernel/orbis/src/sys/sys_generic.cpp b/kernel/orbis/src/sys/sys_generic.cpp index 5a9224e8d..29172e23d 100644 --- a/kernel/orbis/src/sys/sys_generic.cpp +++ b/kernel/orbis/src/sys/sys_generic.cpp @@ -3,11 +3,11 @@ #include "sys/sysproto.hpp" #include "thread/Process.hpp" #include "thread/Thread.hpp" +#include "thread/types.hpp" #include "uio.hpp" -#include -orbis::SysResult orbis::sys_read(Thread *thread, sint fd, ptr buf, - size_t nbyte) { +orbis::SysResult orbis::sys_read(Thread *thread, FileDescriptor fd, + ptr buf, size_t nbyte) { rx::Ref 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 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 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 buf, size_t nbyte, off_t offset) { + ORBIS_LOG_ERROR(__FUNCTION__, (int)fd, buf, nbyte, offset); rx::Ref 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 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 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 iovp, - uint iovcnt) { +orbis::SysResult orbis::sys_readv(Thread *thread, FileDescriptor fd, + ptr iovp, uint iovcnt) { rx::Ref 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 iovp, thread->retval[0] = cnt; return {}; } -orbis::SysResult orbis::sys_preadv(Thread *thread, sint fd, ptr iovp, - uint iovcnt, off_t offset) { +orbis::SysResult orbis::sys_preadv(Thread *thread, FileDescriptor fd, + ptr iovp, uint iovcnt, off_t offset) { rx::Ref 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 iovp, thread->retval[0] = io.offset - offset; return {}; } -orbis::SysResult orbis::sys_write(Thread *thread, sint fd, ptr buf, - size_t nbyte) { +orbis::SysResult orbis::sys_write(Thread *thread, FileDescriptor fd, + ptr buf, size_t nbyte) { + // ORBIS_LOG_ERROR(__FUNCTION__, (int)fd, buf, nbyte); + rx::Ref 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 buf, thread->retval[0] = cnt; return {}; } -orbis::SysResult orbis::sys_pwrite(Thread *thread, sint fd, ptr buf, - size_t nbyte, off_t offset) { +orbis::SysResult orbis::sys_pwrite(Thread *thread, FileDescriptor fd, + ptr buf, size_t nbyte, + off_t offset) { + ORBIS_LOG_ERROR(__FUNCTION__, (int)fd, buf, nbyte, offset); + rx::Ref 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 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 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 iovp, - uint iovcnt) { +orbis::SysResult orbis::sys_writev(Thread *thread, FileDescriptor fd, + ptr iovp, uint iovcnt) { rx::Ref 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 iovp, thread->retval[0] = cnt; return {}; } -orbis::SysResult orbis::sys_pwritev(Thread *thread, sint fd, ptr iovp, - uint iovcnt, off_t offset) { +orbis::SysResult orbis::sys_pwritev(Thread *thread, FileDescriptor fd, + ptr iovp, uint iovcnt, + off_t offset) { rx::Ref 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 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 = 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 = thread->tproc->fileDescriptors.get(fd); if (file == nullptr) { diff --git a/kernel/orbis/src/sys/sys_mac.cpp b/kernel/orbis/src/sys/sys_mac.cpp index 1f4c501c2..5d4cbff4c 100644 --- a/kernel/orbis/src/sys/sys_mac.cpp +++ b/kernel/orbis/src/sys/sys_mac.cpp @@ -12,7 +12,7 @@ orbis::SysResult orbis::sys___mac_set_proc(Thread *thread, ptr 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 mac_p) { return ErrorCode::NOSYS; } @@ -20,7 +20,7 @@ orbis::SysResult orbis::sys___mac_get_file(Thread *thread, ptr path, ptr 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 mac_p) { return ErrorCode::NOSYS; } diff --git a/kernel/orbis/src/sys/sys_pipe.cpp b/kernel/orbis/src/sys/sys_pipe.cpp index 396f6574d..1059c897c 100644 --- a/kernel/orbis/src/sys/sys_pipe.cpp +++ b/kernel/orbis/src/sys/sys_pipe.cpp @@ -3,13 +3,14 @@ #include "thread/Thread.hpp" #include "utils/Logs.hpp" #include +#include 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 {}; } diff --git a/kernel/orbis/src/sys/sys_procdesc.cpp b/kernel/orbis/src/sys/sys_procdesc.cpp index 0ddd003ff..7a70a97b9 100644 --- a/kernel/orbis/src/sys/sys_procdesc.cpp +++ b/kernel/orbis/src/sys/sys_procdesc.cpp @@ -1,5 +1,6 @@ #include "sys/sysproto.hpp" -orbis::SysResult orbis::sys_pdgetpid(Thread *thread, sint fd, ptr pidp) { +orbis::SysResult orbis::sys_pdgetpid(Thread *thread, FileDescriptor fd, + ptr pidp) { return ErrorCode::NOSYS; } diff --git a/kernel/orbis/src/sys/sys_sce.cpp b/kernel/orbis/src/sys/sys_sce.cpp index 772dfb65b..050b70fbc 100644 --- a/kernel/orbis/src/sys/sys_sce.cpp +++ b/kernel/orbis/src/sys/sys_sce.cpp @@ -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 buf, uint nbuf) { +orbis::SysResult orbis::sys_netcontrol(Thread *thread, FileDescriptor fd, + uint op, ptr 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 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::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 diff --git a/kernel/orbis/src/sys/sys_sig.cpp b/kernel/orbis/src/sys/sys_sig.cpp index e5dc057f4..aaed6cfc1 100644 --- a/kernel/orbis/src/sys/sys_sig.cpp +++ b/kernel/orbis/src/sys/sys_sig.cpp @@ -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, diff --git a/kernel/orbis/src/sys/sys_uipc.cpp b/kernel/orbis/src/sys/sys_uipc.cpp index eccf0f51a..d775b7703 100644 --- a/kernel/orbis/src/sys/sys_uipc.cpp +++ b/kernel/orbis/src/sys/sys_uipc.cpp @@ -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 from, ptr 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 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 from, ptr 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 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 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 asa, ptr alen) { // return uwrite(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 asa, ptr alen) { return ErrorCode::NOSYS; } -orbis::SysResult orbis::sys_sendfile(Thread *thread, sint fd, sint s, - off_t offset, size_t nbytes, - ptr hdtr, +orbis::SysResult orbis::sys_sendfile(Thread *thread, FileDescriptor fd, + FileDescriptor s, off_t offset, + size_t nbytes, ptr hdtr, ptr sbytes, sint flags) { return ErrorCode::NOSYS; } diff --git a/kernel/orbis/src/sys/sys_uipc_shm.cpp b/kernel/orbis/src/sys/sys_uipc_shm.cpp index 8a1369b51..330b1480e 100644 --- a/kernel/orbis/src/sys/sys_uipc_shm.cpp +++ b/kernel/orbis/src/sys/sys_uipc_shm.cpp @@ -4,6 +4,7 @@ #include "thread/Process.hpp" #include "thread/ProcessOps.hpp" #include "thread/Thread.hpp" +#include orbis::SysResult orbis::sys_shm_open(Thread *thread, ptr path, sint flags, mode_t mode) { @@ -20,7 +21,7 @@ orbis::SysResult orbis::sys_shm_open(Thread *thread, ptr 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; diff --git a/kernel/orbis/src/sys/sys_vfs.cpp b/kernel/orbis/src/sys/sys_vfs.cpp index 1da50ac8b..685ecf135 100644 --- a/kernel/orbis/src/sys/sys_vfs.cpp +++ b/kernel/orbis/src/sys/sys_vfs.cpp @@ -15,6 +15,7 @@ orbis::SysResult orbis::sys_quotactl(Thread *thread, ptr path, sint cmd, orbis::SysResult orbis::sys_statfs(Thread *thread, ptr path, ptr 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 path, thread->retval[0] = 1; return {}; } -orbis::SysResult orbis::sys_fstatfs(Thread *thread, sint fd, ptr buf) { +orbis::SysResult orbis::sys_fstatfs(Thread *thread, FileDescriptor fd, + ptr buf) { if (buf == 0) { thread->retval[0] = 1; return {}; @@ -48,7 +50,7 @@ orbis::SysResult orbis::sys_getfsstat(Thread *thread, ptr 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 path) { @@ -72,18 +74,18 @@ orbis::SysResult orbis::sys_open(Thread *thread, ptr 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 path, - sint flag, mode_t mode) { - ORBIS_LOG_WARNING(__FUNCTION__, fd, path, flag, mode); +orbis::SysResult orbis::sys_openat(Thread *thread, FileDescriptor fd, + ptr 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 path, sint mode, sint dev) { return ErrorCode::NOSYS; } -orbis::SysResult orbis::sys_mknodat(Thread *thread, sint fd, ptr path, - mode_t mode, dev_t dev) { +orbis::SysResult orbis::sys_mknodat(Thread *thread, FileDescriptor fd, + ptr path, mode_t mode, dev_t dev) { return ErrorCode::NOSYS; } orbis::SysResult orbis::sys_mkfifo(Thread *thread, ptr path, sint mode) { return ErrorCode::NOSYS; } -orbis::SysResult orbis::sys_mkfifoat(Thread *thread, sint fd, ptr path, - mode_t mode) { +orbis::SysResult orbis::sys_mkfifoat(Thread *thread, FileDescriptor fd, + ptr path, mode_t mode) { return ErrorCode::NOSYS; } orbis::SysResult orbis::sys_link(Thread *thread, ptr path, ptr link) { return ErrorCode::NOSYS; } -orbis::SysResult orbis::sys_linkat(Thread *thread, sint fd1, ptr path1, - sint fd2, ptr path2, sint flag) { +orbis::SysResult orbis::sys_linkat(Thread *thread, FileDescriptor fd1, + ptr path1, FileDescriptor fd2, + ptr path2, sint flag) { return ErrorCode::NOSYS; } orbis::SysResult orbis::sys_symlink(Thread *thread, ptr path, ptr link) { return ErrorCode::NOSYS; } -orbis::SysResult orbis::sys_symlinkat(Thread *thread, ptr path1, sint fd, - ptr path2) { +orbis::SysResult orbis::sys_symlinkat(Thread *thread, ptr path1, + FileDescriptor fd, ptr path2) { return ErrorCode::NOSYS; } orbis::SysResult orbis::sys_undelete(Thread *thread, ptr path) { @@ -136,16 +139,17 @@ orbis::SysResult orbis::sys_undelete(Thread *thread, ptr path) { } orbis::SysResult orbis::sys_unlink(Thread *thread, ptr 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 path, - sint flag) { +orbis::SysResult orbis::sys_unlinkat(Thread *thread, FileDescriptor fd, + ptr 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 = 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 path, sint flags) { @@ -200,8 +204,8 @@ orbis::SysResult orbis::sys_access(Thread *thread, ptr path, sint flags) { return ErrorCode::NOSYS; } -orbis::SysResult orbis::sys_faccessat(Thread *thread, sint fd, ptr path, - sint mode, sint flag) { +orbis::SysResult orbis::sys_faccessat(Thread *thread, FileDescriptor fd, + ptr path, sint mode, sint flag) { return ErrorCode::NOSYS; } orbis::SysResult orbis::sys_eaccess(Thread *thread, ptr path, @@ -235,8 +239,8 @@ orbis::SysResult orbis::sys_stat(Thread *thread, ptr path, ptr ub) { return uwrite(ub, _ub); } -orbis::SysResult orbis::sys_fstatat(Thread *thread, sint fd, ptr path, - ptr buf, sint flag) { +orbis::SysResult orbis::sys_fstatat(Thread *thread, FileDescriptor fd, + ptr path, ptr buf, sint flag) { return ErrorCode::NOSYS; } orbis::SysResult orbis::sys_lstat(Thread *thread, ptr path, @@ -261,6 +265,8 @@ orbis::SysResult orbis::sys_lpathconf(Thread *thread, ptr path, } orbis::SysResult orbis::sys_readlink(Thread *thread, ptr path, ptr 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 path, thread->retval[0] = pathLen; return {}; } -orbis::SysResult orbis::sys_readlinkat(Thread *thread, sint fd, ptr path, - ptr buf, size_t bufsize) { +orbis::SysResult orbis::sys_readlinkat(Thread *thread, FileDescriptor fd, + ptr path, ptr buf, + size_t bufsize) { return ErrorCode::NOSYS; } orbis::SysResult orbis::sys_chflags(Thread *thread, ptr path, @@ -290,36 +297,39 @@ orbis::SysResult orbis::sys_lchflags(Thread *thread, ptr 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 path, sint mode) { return {}; } -orbis::SysResult orbis::sys_fchmodat(Thread *thread, sint fd, ptr path, - mode_t mode, sint flag) { +orbis::SysResult orbis::sys_fchmodat(Thread *thread, FileDescriptor fd, + ptr path, mode_t mode, sint flag) { return ErrorCode::NOSYS; } orbis::SysResult orbis::sys_lchmod(Thread *thread, ptr 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 path, sint uid, sint gid) { return ErrorCode::NOSYS; } -orbis::SysResult orbis::sys_fchownat(Thread *thread, sint fd, ptr path, - uid_t uid, gid_t gid, sint flag) { +orbis::SysResult orbis::sys_fchownat(Thread *thread, FileDescriptor fd, + ptr path, uid_t uid, gid_t gid, + sint flag) { return ErrorCode::NOSYS; } orbis::SysResult orbis::sys_lchown(Thread *thread, ptr 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 path, ptr tptr) { return ErrorCode::NOSYS; } -orbis::SysResult orbis::sys_futimesat(Thread *thread, sint fd, ptr path, +orbis::SysResult orbis::sys_futimesat(Thread *thread, FileDescriptor fd, + ptr path, ptr times) { return ErrorCode::NOSYS; } @@ -335,12 +346,14 @@ orbis::SysResult orbis::sys_lutimes(Thread *thread, ptr path, ptr tptr) { return ErrorCode::NOSYS; } -orbis::SysResult orbis::sys_futimes(Thread *thread, sint fd, +orbis::SysResult orbis::sys_futimes(Thread *thread, FileDescriptor fd, ptr tptr) { return ErrorCode::NOSYS; } orbis::SysResult orbis::sys_truncate(Thread *thread, ptr path, off_t length) { + ORBIS_LOG_WARNING(__FUNCTION__, path, length); + rx::Ref 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 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 from, ptr 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 old, - sint newfd, ptr new_) { +orbis::SysResult orbis::sys_renameat(Thread *thread, FileDescriptor oldfd, + ptr old, FileDescriptor newfd, + ptr new_) { return ErrorCode::NOSYS; } orbis::SysResult orbis::sys_mkdir(Thread *thread, ptr path, sint mode) { @@ -377,8 +394,8 @@ orbis::SysResult orbis::sys_mkdir(Thread *thread, ptr path, sint mode) { } return ErrorCode::NOSYS; } -orbis::SysResult orbis::sys_mkdirat(Thread *thread, sint fd, ptr path, - mode_t mode) { +orbis::SysResult orbis::sys_mkdirat(Thread *thread, FileDescriptor fd, + ptr path, mode_t mode) { rx::Ref 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 path, } orbis::SysResult orbis::sys_rmdir(Thread *thread, ptr 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 buf, uint count, ptr basep) { - ORBIS_LOG_WARNING(__FUNCTION__, fd, (void *)buf, count, basep); + ORBIS_LOG_WARNING(__FUNCTION__, (int)fd, (void *)buf, count, basep); rx::Ref 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 buf, - size_t count) { - ORBIS_LOG_WARNING(__FUNCTION__, fd, (void *)buf, count); +orbis::SysResult orbis::sys_getdents(Thread *thread, FileDescriptor fd, + ptr 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 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; } diff --git a/kernel/orbis/src/sys/sys_vfs_aio.cpp b/kernel/orbis/src/sys/sys_vfs_aio.cpp index 74c40292f..ad3310927 100644 --- a/kernel/orbis/src/sys/sys_vfs_aio.cpp +++ b/kernel/orbis/src/sys/sys_vfs_aio.cpp @@ -9,7 +9,7 @@ orbis::SysResult orbis::sys_aio_suspend(Thread *thread, ptr 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 aiocbp) { return ErrorCode::NOSYS; } diff --git a/kernel/orbis/src/sys/sys_vfs_extattr.cpp b/kernel/orbis/src/sys/sys_vfs_extattr.cpp index 460e28a61..d15a410c9 100644 --- a/kernel/orbis/src/sys/sys_vfs_extattr.cpp +++ b/kernel/orbis/src/sys/sys_vfs_extattr.cpp @@ -6,7 +6,7 @@ orbis::SysResult orbis::sys_extattrctl(Thread *thread, ptr path, char cmd, ptr 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 attrname, ptr data, size_t nbytes) { @@ -25,7 +25,7 @@ orbis::SysResult orbis::sys_extattr_set_link(Thread *thread, ptr 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 attrname, ptr data, size_t nbytes) { @@ -44,7 +44,7 @@ orbis::SysResult orbis::sys_extattr_get_link(Thread *thread, ptr 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 attrname) { return ErrorCode::NOSYS; @@ -60,7 +60,7 @@ orbis::SysResult orbis::sys_extattr_delete_link(Thread *thread, ptr 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 data, size_t nbytes) { return ErrorCode::NOSYS; diff --git a/kernel/orbis/src/sys/sys_vm_mmap.cpp b/kernel/orbis/src/sys/sys_vm_mmap.cpp index 4a1833b8b..8348f0cf3 100644 --- a/kernel/orbis/src/sys/sys_vm_mmap.cpp +++ b/kernel/orbis/src/sys/sys_vm_mmap.cpp @@ -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 prot, - rx::EnumBitSet flags, sint fd, - off_t pos) { + rx::EnumBitSet 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 prot, rx::EnumBitSet 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, diff --git a/rpcsx/io-device.cpp b/rpcsx/io-device.cpp index cea81ce8c..a9b389fec 100644 --- a/rpcsx/io-device.cpp +++ b/rpcsx/io-device.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include struct HostFile : orbis::File { @@ -508,8 +508,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 {}; }