summaryrefslogtreecommitdiff
path: root/src/fs/rootfs
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2025-07-07 13:22:53 +0200
committerXavier Del Campo Romero <xavi92@disroot.org>2025-07-25 14:16:41 +0200
commit14f60e4fd65c42f126eaee7e09cb4251c167c6ed (patch)
tree313b5e16d7d99cf1518c953e2efe5e5fc920dfbf /src/fs/rootfs
parent48a61c16eaa6dcfc75d00dba302537ce1492db98 (diff)
downloadwnix-tty.tar.gz
wiptty
Diffstat (limited to 'src/fs/rootfs')
-rw-r--r--src/fs/rootfs/CMakeLists.txt20
-rw-r--r--src/fs/rootfs/include/rootfs.h24
-rw-r--r--src/fs/rootfs/private_include/rootfs/ops.h42
-rw-r--r--src/fs/rootfs/private_include/rootfs/types.h32
-rw-r--r--src/fs/rootfs/src/CMakeLists.txt28
-rw-r--r--src/fs/rootfs/src/close.c25
-rw-r--r--src/fs/rootfs/src/flags.c26
-rw-r--r--src/fs/rootfs/src/mkdir.c30
-rw-r--r--src/fs/rootfs/src/mount.c42
-rw-r--r--src/fs/rootfs/src/open.c27
-rw-r--r--src/fs/rootfs/src/read.c26
-rw-r--r--src/fs/rootfs/src/register.c43
-rw-r--r--src/fs/rootfs/src/search.c29
-rw-r--r--src/fs/rootfs/src/stat.c28
-rw-r--r--src/fs/rootfs/src/write.c26
15 files changed, 448 insertions, 0 deletions
diff --git a/src/fs/rootfs/CMakeLists.txt b/src/fs/rootfs/CMakeLists.txt
new file mode 100644
index 0000000..b32fd82
--- /dev/null
+++ b/src/fs/rootfs/CMakeLists.txt
@@ -0,0 +1,20 @@
+# wanix, 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/>.
+
+add_library(rootfs)
+add_subdirectory(src)
+target_include_directories(rootfs PUBLIC include PRIVATE private_include)
+target_link_libraries(rootfs PUBLIC state c PRIVATE fs ramfs)
diff --git a/src/fs/rootfs/include/rootfs.h b/src/fs/rootfs/include/rootfs.h
new file mode 100644
index 0000000..c218b1c
--- /dev/null
+++ b/src/fs/rootfs/include/rootfs.h
@@ -0,0 +1,24 @@
+/*
+ * wanix, 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 ROOTFS_H
+#define ROOTFS_H
+
+int rootfs_register(void);
+
+#endif
diff --git a/src/fs/rootfs/private_include/rootfs/ops.h b/src/fs/rootfs/private_include/rootfs/ops.h
new file mode 100644
index 0000000..356e740
--- /dev/null
+++ b/src/fs/rootfs/private_include/rootfs/ops.h
@@ -0,0 +1,42 @@
+/*
+ * wanix, 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 ROOTFS_OPS_H
+#define ROOTFS_OPS_H
+
+#include <fs/fs.h>
+#include <fs/inode.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stddef.h>
+
+int rootfs_mount(const struct fs_mount *m, struct fs_ret *r);
+int rootfs_mkdir(const struct fs_mkdir *m, const struct fs_mp *mp,
+ const union inode_result *i, struct fs_ret *r);
+int rootfs_open(const struct fs_open *o, const struct fs_mp *mp,
+ const union inode_result *i, struct fs_ret *r);
+int rootfs_read(const struct fs_read *r, struct fs_ret *ret);
+int rootfs_write(const struct fs_write *w, struct fs_ret *r);
+int rootfs_stat(const struct fs_stat *s, const struct fs_mp *mp,
+ const union inode_result *inode, struct fs_ret *r);
+int rootfs_close(const struct fs_close *c, struct fs_ret *r);
+int rootfs_search(const char *path, const struct fs_mp *mp,
+ union inode_result *inode, struct fs_ret *r);
+int rootfs_flags(const union inode_result *i);
+
+#endif
diff --git a/src/fs/rootfs/private_include/rootfs/types.h b/src/fs/rootfs/private_include/rootfs/types.h
new file mode 100644
index 0000000..1ce40aa
--- /dev/null
+++ b/src/fs/rootfs/private_include/rootfs/types.h
@@ -0,0 +1,32 @@
+/*
+ * wanix, 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 ROOTFS_TYPES_H
+#define ROOTFS_TYPES_H
+
+#include <fs/fs.h>
+#include <ramfs.h>
+
+struct fs_mp_prv
+{
+ struct ramfs *rfs;
+};
+
+extern const struct fs rootfs;
+
+#endif
diff --git a/src/fs/rootfs/src/CMakeLists.txt b/src/fs/rootfs/src/CMakeLists.txt
new file mode 100644
index 0000000..b7fdcdb
--- /dev/null
+++ b/src/fs/rootfs/src/CMakeLists.txt
@@ -0,0 +1,28 @@
+# wanix, 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/>.
+
+target_sources(rootfs PRIVATE
+ close.c
+ flags.c
+ mount.c
+ mkdir.c
+ open.c
+ stat.c
+ read.c
+ register.c
+ search.c
+ write.c
+)
diff --git a/src/fs/rootfs/src/close.c b/src/fs/rootfs/src/close.c
new file mode 100644
index 0000000..51a7c45
--- /dev/null
+++ b/src/fs/rootfs/src/close.c
@@ -0,0 +1,25 @@
+/*
+ * wanix, 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/>.
+ */
+
+#include <rootfs.h>
+#include <fs/fs.h>
+
+int rootfs_close(const struct fs_close *const c, struct fs_ret *const r)
+{
+ return -1;
+}
diff --git a/src/fs/rootfs/src/flags.c b/src/fs/rootfs/src/flags.c
new file mode 100644
index 0000000..06496bb
--- /dev/null
+++ b/src/fs/rootfs/src/flags.c
@@ -0,0 +1,26 @@
+/*
+ * wanix, 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/>.
+ */
+
+#include <rootfs.h>
+#include <rootfs/ops.h>
+#include <fs/inode.h>
+
+int rootfs_flags(const union inode_result *const i)
+{
+ return i->memi->flags;
+}
diff --git a/src/fs/rootfs/src/mkdir.c b/src/fs/rootfs/src/mkdir.c
new file mode 100644
index 0000000..7136477
--- /dev/null
+++ b/src/fs/rootfs/src/mkdir.c
@@ -0,0 +1,30 @@
+/*
+ * wanix, 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/>.
+ */
+
+#include <rootfs.h>
+#include <rootfs/ops.h>
+#include <rootfs/types.h>
+#include <fs/fs.h>
+#include <fs/inode.h>
+#include <ramfs.h>
+
+int rootfs_mkdir(const struct fs_mkdir *const m, const struct fs_mp *const mp,
+ const union inode_result *const inode, struct fs_ret *const r)
+{
+ return ramfs_mkdir(m, mp->prv->rfs, inode, r);
+}
diff --git a/src/fs/rootfs/src/mount.c b/src/fs/rootfs/src/mount.c
new file mode 100644
index 0000000..f421918
--- /dev/null
+++ b/src/fs/rootfs/src/mount.c
@@ -0,0 +1,42 @@
+/*
+ * wanix, 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/>.
+ */
+
+#include <rootfs.h>
+#include <rootfs/types.h>
+#include <ramfs.h>
+#include <fs/fs.h>
+#include <stdlib.h>
+
+int rootfs_mount(const struct fs_mount *const m, struct fs_ret *const r)
+{
+ struct ramfs *rfs = NULL;
+ struct fs_mp_prv *const p = malloc(sizeof *p);
+
+ if (!p
+ || !(rfs = ramfs_mount(m, r))
+ || fs_mountpoint(m->src, m->tgt, &rootfs, NULL, p))
+ goto failure;
+
+ *p = (const struct fs_mp_prv){.rfs = rfs};
+ return 0;
+
+failure:
+ ramfs_free(rfs);
+ free(p);
+ return -1;
+}
diff --git a/src/fs/rootfs/src/open.c b/src/fs/rootfs/src/open.c
new file mode 100644
index 0000000..6fea301
--- /dev/null
+++ b/src/fs/rootfs/src/open.c
@@ -0,0 +1,27 @@
+/*
+ * wanix, 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/>.
+ */
+
+#include <rootfs.h>
+#include <rootfs/ops.h>
+#include <fs/fs.h>
+
+int rootfs_open(const struct fs_open *const o, const struct fs_mp *const mp,
+ const union inode_result *const i, struct fs_ret *const r)
+{
+ return -1;
+}
diff --git a/src/fs/rootfs/src/read.c b/src/fs/rootfs/src/read.c
new file mode 100644
index 0000000..d2cb757
--- /dev/null
+++ b/src/fs/rootfs/src/read.c
@@ -0,0 +1,26 @@
+/*
+ * wanix, 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/>.
+ */
+
+#include <rootfs.h>
+#include <fs/fs.h>
+#include <stddef.h>
+
+int rootfs_read(const struct fs_read *const r, struct fs_ret *const ret)
+{
+ return -1;
+}
diff --git a/src/fs/rootfs/src/register.c b/src/fs/rootfs/src/register.c
new file mode 100644
index 0000000..e578cf7
--- /dev/null
+++ b/src/fs/rootfs/src/register.c
@@ -0,0 +1,43 @@
+/*
+ * wanix, 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/>.
+ */
+
+#include <rootfs.h>
+#include <rootfs/ops.h>
+#include <fs/fs.h>
+
+const struct fs rootfs =
+{
+ .type = "rootfs",
+ .mount = rootfs_mount,
+ .stat = rootfs_stat,
+ .mkdir = rootfs_mkdir,
+ .open = rootfs_open,
+ .read = rootfs_read,
+ .write = rootfs_write,
+ .close = rootfs_close,
+ .iops =
+ {
+ .search = rootfs_search,
+ .flags = rootfs_flags
+ }
+};
+
+int rootfs_register(void)
+{
+ return fs_register(&rootfs);
+}
diff --git a/src/fs/rootfs/src/search.c b/src/fs/rootfs/src/search.c
new file mode 100644
index 0000000..3675f0a
--- /dev/null
+++ b/src/fs/rootfs/src/search.c
@@ -0,0 +1,29 @@
+/*
+ * wanix, 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/>.
+ */
+
+#include <rootfs.h>
+#include <rootfs/ops.h>
+#include <rootfs/types.h>
+#include <fs/fs.h>
+#include <ramfs.h>
+
+int rootfs_search(const char *const path, const struct fs_mp *const mp,
+ union inode_result *const inode, struct fs_ret *const r)
+{
+ return ramfs_search(path, mp->prv->rfs, inode, r);
+}
diff --git a/src/fs/rootfs/src/stat.c b/src/fs/rootfs/src/stat.c
new file mode 100644
index 0000000..2eff55c
--- /dev/null
+++ b/src/fs/rootfs/src/stat.c
@@ -0,0 +1,28 @@
+/*
+ * wanix, 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/>.
+ */
+
+#include <rootfs.h>
+#include <rootfs/ops.h>
+#include <fs/fs.h>
+#include <sys/stat.h>
+
+int rootfs_stat(const struct fs_stat *const s, const struct fs_mp *const mp,
+ const union inode_result *const inode, struct fs_ret *const r)
+{
+ return -1;
+}
diff --git a/src/fs/rootfs/src/write.c b/src/fs/rootfs/src/write.c
new file mode 100644
index 0000000..53b9704
--- /dev/null
+++ b/src/fs/rootfs/src/write.c
@@ -0,0 +1,26 @@
+/*
+ * wanix, 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/>.
+ */
+
+#include <rootfs.h>
+#include <fs/fs.h>
+#include <stddef.h>
+
+int rootfs_write(const struct fs_write *const w, struct fs_ret *const r)
+{
+ return -1;
+}