oribs: add type for file descriptor

allows improve tracing
This commit is contained in:
DH 2025-12-03 20:07:25 +03:00
parent f694b14a26
commit 7c3ee53d6e
20 changed files with 344 additions and 280 deletions

View file

@ -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 */);

View file

@ -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;

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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__,

View file

@ -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;
}

View file

@ -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) {

View file

@ -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;
}

View file

@ -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 {};
}

View file

@ -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;
}

View file

@ -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

View file

@ -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,

View file

@ -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;
}

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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,

View file

@ -27,7 +27,7 @@
#include <sys/uio.h>
#include <sys/un.h>
#include <thread>
#include <unistd.h>
#include <utility>
#include <vector>
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 {};
}