aboutsummaryrefslogtreecommitdiff
path: root/src/bin/private_include
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2025-11-12 00:37:26 +0100
committerXavier Del Campo Romero <xavi92@disroot.org>2025-11-16 22:57:45 +0100
commit2ce58c995946f85666e793c4f06efff683e76ae4 (patch)
treefbf2658bb0b0f61dadcf4ca27f997eaded78aae5 /src/bin/private_include
parent5ce25ae3b5d8666d373f7d7e336546ce8508c213 (diff)
downloadwnix-master.tar.gz
Diffstat (limited to 'src/bin/private_include')
-rw-r--r--src/bin/private_include/bin/proc.h2
-rw-r--r--src/bin/private_include/bin/types.h16
-rw-r--r--src/bin/private_include/bin/wasi/errno.h105
-rw-r--r--src/bin/private_include/bin/wnix.h8
-rw-r--r--src/bin/private_include/bin/wnix/routines.h19
5 files changed, 39 insertions, 111 deletions
diff --git a/src/bin/private_include/bin/proc.h b/src/bin/private_include/bin/proc.h
index cf0c04e..92f1566 100644
--- a/src/bin/private_include/bin/proc.h
+++ b/src/bin/private_include/bin/proc.h
@@ -43,6 +43,8 @@ int bin_proc_s_pop(void *dst, size_t n, void *user);
int bin_proc_s_read(size_t offset, void *dst, size_t n, void *user);
int bin_proc_s_write(size_t offset, const void *dst, size_t n, void *user);
size_t bin_proc_s_ptr(void *user);
+struct bin_proc_fd *bin_proc_fd_find(const struct bin_proc *p, int fd);
+int bin_proc_fd_alloc(struct bin_proc *p, const struct fs_fd *fd, int flags);
extern const struct nw_inst_cfg bin_proc_cfg;
diff --git a/src/bin/private_include/bin/types.h b/src/bin/private_include/bin/types.h
index 2a498ed..6f231ae 100644
--- a/src/bin/private_include/bin/types.h
+++ b/src/bin/private_include/bin/types.h
@@ -28,7 +28,7 @@
#include <sys/types.h>
#include <stdbool.h>
-enum {BIN_IMPORTS = 9};
+enum {BIN_IMPORTS = 10};
struct bin_dbg
{
@@ -54,18 +54,25 @@ struct bin_global
size_t sz;
};
+struct bin_proc_fd
+{
+ int fd, flags;
+ struct fs_fd fs_fd;
+};
+
struct bin_proc
{
const struct bin_mod *mod;
struct nw_inst instance;
- union nw_value args[7];
+ union nw_value args[6];
struct bin_dbg dbg;
struct caio *caio;
char *path, **argv;
size_t argc;
- pid_t pid;
+ pid_t pid, parent;
uid_t uid;
gid_t gid;
+ mode_t umask;
char header[sizeof "asm"];
size_t i;
long retval;
@@ -73,7 +80,8 @@ struct bin_proc
struct bin_global global;
void *import;
struct page *linear;
- int *fds;
+ struct fs_stdstreams ss;
+ struct bin_proc_fd *fds;
size_t n_fds;
struct bin_proc *prev, *next;
};
diff --git a/src/bin/private_include/bin/wasi/errno.h b/src/bin/private_include/bin/wasi/errno.h
deleted file mode 100644
index 442e877..0000000
--- a/src/bin/private_include/bin/wasi/errno.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * wnix, a Unix-like operating system for WebAssembly applications.
- * Copyright (C) 2025 Xavier Del Campo Romero
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-#ifndef WASI_ERRNO_H
-#define WASI_ERRNO_H
-
-enum wasi_errno
-{
- WASI_SUCCESS,
- WASI_2BIG,
- WASI_ACCES,
- WASI_ADDRINUSE,
- WASI_ADDRNOTAVAIL,
- WASI_AFNOSUPPORT,
- WASI_AGAIN,
- WASI_ALREADY,
- WASI_BADF,
- WASI_BADMSG,
- WASI_BUSY,
- WASI_CANCELED,
- WASI_CHILD,
- WASI_CONNABORTED,
- WASI_CONNREFUSED,
- WASI_CONNRESET,
- WASI_DEADLK,
- WASI_DESTADDRREQ,
- WASI_DOM,
- WASI_DQUOT,
- WASI_EXIST,
- WASI_FAULT,
- WASI_FBIG,
- WASI_HOSTUNREACH,
- WASI_IDRM,
- WASI_ILSEQ,
- WASI_INPROGRESS,
- WASI_INTR,
- WASI_INVAL,
- WASI_IO,
- WASI_ISCONN,
- WASI_ISDIR,
- WASI_LOOP,
- WASI_MFILE,
- WASI_MLINK,
- WASI_MSGSIZE,
- WASI_MULTIHOP,
- WASI_NAMETOOLONG,
- WASI_NETDOWN,
- WASI_NETRESET,
- WASI_NETUNREACH,
- WASI_NFILE,
- WASI_NOBUFS,
- WASI_NODEV,
- WASI_NOENT,
- WASI_NOEXEC,
- WASI_NOLCK,
- WASI_NOLINK,
- WASI_NOMEM,
- WASI_NOMSG,
- WASI_NOPROTOOPT,
- WASI_NOSPC,
- WASI_NOSYS,
- WASI_NOTCONN,
- WASI_NOTDIR,
- WASI_NOTEMPTY,
- WASI_NOTRECOVERABLE,
- WASI_NOTSOCK,
- WASI_NOTSUP,
- WASI_NOTTY,
- WASI_NXIO,
- WASI_OVERFLOW,
- WASI_OWNERDEAD,
- WASI_PERM,
- WASI_PIPE,
- WASI_PROTO,
- WASI_PROTONOSUPPORT,
- WASI_PROTOTYPE,
- WASI_RANGE,
- WASI_ROFS,
- WASI_SPIPE,
- WASI_SRCH,
- WASI_STALE,
- WASI_TIMEDOUT,
- WASI_TXTBSY,
- WASI_XDEV,
- WASI_NOTCAPABLE
-};
-
-int wasi_errno(int error, enum wasi_errno *out);
-
-#endif
diff --git a/src/bin/private_include/bin/wnix.h b/src/bin/private_include/bin/wnix.h
index 07e7131..f3844c5 100644
--- a/src/bin/private_include/bin/wnix.h
+++ b/src/bin/private_include/bin/wnix.h
@@ -33,5 +33,13 @@ enum nw_state bin_wnix_mkdir(const union nw_value *params,
union nw_value *ret, void *user, struct nw_next *next);
enum nw_state bin_wnix_mount(const union nw_value *params,
union nw_value *ret, void *user, struct nw_next *next);
+enum nw_state bin_wnix_write(const union nw_value *params,
+ union nw_value *ret, void *user, struct nw_next *next);
+enum nw_state bin_wnix_umask(const union nw_value *params,
+ union nw_value *ret, void *user, struct nw_next *next);
+enum nw_state bin_wnix_open(const union nw_value *params,
+ union nw_value *ret, void *user, struct nw_next *next);
+enum nw_state bin_wnix_close(const union nw_value *params,
+ union nw_value *ret, void *user, struct nw_next *next);
#endif
diff --git a/src/bin/private_include/bin/wnix/routines.h b/src/bin/private_include/bin/wnix/routines.h
index aa488fb..3ba5118 100644
--- a/src/bin/private_include/bin/wnix/routines.h
+++ b/src/bin/private_include/bin/wnix/routines.h
@@ -23,7 +23,22 @@
#include <bin/types.h>
#include <nanowasm/nw.h>
-int bin_wnix_set_errno(struct bin_proc *p, int error, unsigned long addr,
- struct nw_next *next);
+struct bin_readstr
+{
+ unsigned long addr;
+ struct bin_proc *p;
+ char **str;
+ int (*error)(struct bin_proc *, int, struct nw_next *);
+};
+
+struct bin_set_errno
+{
+ int error;
+ unsigned long addr;
+ struct bin_proc *p;
+};
+
+int bin_wnix_readstr(const struct bin_readstr *cfg, struct nw_next *next);
+int bin_wnix_set_errno(const struct bin_set_errno *cfg, struct nw_next *next);
#endif