summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/cicd.yml2
-rw-r--r--src/lib/libc/src/l5/mount.c44
-rw-r--r--src/sys/compat/unix/os/os_filedesc.c49
-rw-r--r--src/sys/include/compat/unix/syscall.h4
-rw-r--r--src/sys/include/sys/mount.h31
-rw-r--r--src/sys/include/sys/syscall.h3
-rw-r--r--src/sys/os/os_null.c (renamed from src/sys/io/usb/ehci.c)67
-rw-r--r--src/sys/os/vfs_mount.c4
8 files changed, 159 insertions, 45 deletions
diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml
index c0744e1..bf98b57 100644
--- a/.github/workflows/cicd.yml
+++ b/.github/workflows/cicd.yml
@@ -18,6 +18,8 @@ jobs:
run: sudo apt-get install -y flex bison libfl-dev libmpc-dev
- name: Install tools
run: sudo apt-get install -y lld clang xorriso mtools
+ - name: Build toolchain
+ run: cd src/; tools/build-toolchain.sh
- name: Bootstrap project
run: cd src/; tools/bootstrap
- name: Build system
diff --git a/src/lib/libc/src/l5/mount.c b/src/lib/libc/src/l5/mount.c
new file mode 100644
index 0000000..4b26173
--- /dev/null
+++ b/src/lib/libc/src/l5/mount.c
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2025 Ian Marco Moffett and L5 engineers
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/syscall.h>
+
+int mount(
+ const char *source, const char *target, const char *fstype,
+ unsigned long mountflags, void *data)
+{
+ return syscall(
+ SYS_mount,
+ (uintptr_t)source,
+ (uintptr_t)target,
+ (uintptr_t)fstype,
+ (uintptr_t)mountflags,
+ (uintptr_t)data
+ );
+}
diff --git a/src/sys/compat/unix/os/os_filedesc.c b/src/sys/compat/unix/os/os_filedesc.c
index 86bb62b..48ea6be 100644
--- a/src/sys/compat/unix/os/os_filedesc.c
+++ b/src/sys/compat/unix/os/os_filedesc.c
@@ -28,14 +28,15 @@
*/
#include <sys/syscall.h>
+#include <sys/limits.h>
+#include <sys/syslog.h>
+#include <sys/mount.h>
#include <sys/errno.h>
#include <sys/types.h>
#include <os/systm.h>
#include <os/filedesc.h>
#include <compat/unix/syscall.h>
-#include <sys/syslog.h>
-
/*
* Write syscall
*
@@ -60,3 +61,47 @@ sys_write(struct syscall_args *scargs)
return write(fd, kbuf, count);
}
+
+/*
+ * ARG0: Source
+ * ARG1: Target
+ * ARG2: Filesystem type
+ * ARG3: Mountflags
+ * ARG4: Data
+ */
+scret_t
+sys_mount(struct syscall_args *scargs)
+{
+ struct mount_args args;
+ char source[NAME_MAX];
+ char target[NAME_MAX];
+ char fstype[FSNAME_MAX];
+ const char *u_source = SCARG(scargs, const char *, 0);
+ const char *u_target = SCARG(scargs, const char *, 1);
+ const char *u_fstype = SCARG(scargs, const char *, 2);
+ unsigned long u_mountflags = SCARG(scargs, unsigned long, 3);
+ int error;
+
+ /* Get the filesystem source */
+ error = copyinstr(u_source, source, sizeof(source));
+ if (error < 0) {
+ source[0] = '\0';
+ }
+
+ /* Get the filesystem target */
+ error = copyinstr(u_target, target, sizeof(target));
+ if (error < 0) {
+ return error;
+ }
+
+ /* Get the filesystem type */
+ error = copyinstr(u_fstype, fstype, sizeof(u_fstype));
+ if (error < 0) {
+ return error;
+ }
+
+ args.source = source;
+ args.target = target;
+ args.fstype = fstype;
+ return kmount(&args, u_mountflags);
+}
diff --git a/src/sys/include/compat/unix/syscall.h b/src/sys/include/compat/unix/syscall.h
index 1b51d26..14088f4 100644
--- a/src/sys/include/compat/unix/syscall.h
+++ b/src/sys/include/compat/unix/syscall.h
@@ -32,6 +32,7 @@
#include <sys/proc.h>
#include <sys/param.h>
+#include <sys/mount.h>
#include <sys/syscall.h>
/*
@@ -66,7 +67,8 @@ scret_t(*g_unix_sctab[])(struct syscall_args *) = {
[SYS_write] = sys_write,
[SYS_cross] = sys_cross,
[SYS_query] = sys_query,
- [SYS_spawn] = sys_spawn
+ [SYS_spawn] = sys_spawn,
+ [SYS_mount] = sys_mount
};
#endif /* !_NEED_UNIX_SCTAB */
diff --git a/src/sys/include/sys/mount.h b/src/sys/include/sys/mount.h
index 4e39279..6d041ee 100644
--- a/src/sys/include/sys/mount.h
+++ b/src/sys/include/sys/mount.h
@@ -31,22 +31,32 @@
#define _SYS_MOUNT_H_
#include <sys/queue.h>
+#include <sys/syscall.h>
#include <sys/types.h>
+#if defined(_KERNEL)
#include <os/vnode.h>
+#endif /* defined(_KERNEL) */
-#if defined(_KERNEL)
+/*
+ * Mount filesystem string names
+ */
+#define MOUNT_INITRD "initrd" /* Initial ramdisk */
+#define MOUNT_DEVFS "devfs" /* Device filesystem */
/*
- * Number of bytes allowed in a filesystem
- * name including the null termination
+ * The mount system call
*/
-#define FSNAME_MAX 16
+int mount(
+ const char *source, const char *target, const char *fstype,
+ unsigned long mountflags, void *data
+);
+#if defined(_KERNEL)
/*
- * Mount filesystem string names
+ * Number of bytes allowed in a filesystem
+ * name including the null termination
*/
-#define MOUNT_INITRD "initrd" /* Initial ramdisk */
-#define MOUNT_DEVFS "devfs" /* Device filesystem */
+#define FSNAME_MAX 16
/* Forward declarations */
struct fs_info;
@@ -155,7 +165,7 @@ int mount_lookup(const char *name, struct mount **mp_res);
* Returns zero on success, otherwise a less than zero
* failure upon failure.
*/
-int mount(struct mount_args *margs, uint32_t flags);
+int kmount(struct mount_args *margs, uint32_t flags);
/*
* Initialize a mountpoint to a known state
@@ -178,5 +188,10 @@ int mountlist_init(struct mountlist *mlp);
*/
int mount_alloc(const char *name, struct mount **mp_res);
+/*
+ * Mount system call
+ */
+scret_t sys_mount(struct syscall_args *scargs);
+
#endif /* !_KERNEL */
#endif /* !_SYS_MOUNT_H_ */
diff --git a/src/sys/include/sys/syscall.h b/src/sys/include/sys/syscall.h
index 7dcd266..181f734 100644
--- a/src/sys/include/sys/syscall.h
+++ b/src/sys/include/sys/syscall.h
@@ -49,7 +49,8 @@
#define SYS_sigaction 0x04
#define SYS_query 0x05 /* query a border (mandatory) */
#define SYS_spawn 0x06 /* spawn a process */
-#define SYS_open 0x07 /* open a file */
+#define SYS_mount 0x07 /* mount a filesystem */
+#define SYS_open 0x08 /* open a file */
typedef __ssize_t scret_t;
typedef __ssize_t scarg_t;
diff --git a/src/sys/io/usb/ehci.c b/src/sys/os/os_null.c
index 62c1c0e..e142c6f 100644
--- a/src/sys/io/usb/ehci.c
+++ b/src/sys/os/os_null.c
@@ -27,51 +27,56 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/types.h>
#include <sys/syslog.h>
-#include <io/pci/pci.h>
-#include <io/pci/bar.h>
#include <os/module.h>
+#include <fs/devfs.h>
-#define pr_trace(fmt, ...) printf("ehci: " fmt, ##__VA_ARGS__)
-#if defined(AHCI_DEBUG)
-#define dtrace(fmt, ...) printf("ehci: " fmt, ##__VA_ARGS__)
-#else
-#define dtrace(...) __nothing
-#endif /* AHCI_DEBUG */
+static struct cdevsw null_cdev;
-static struct pci_device dev;
-static struct pci_adv driver;
+/*
+ * Lie to the user and make them think they are
+ * reading data but give them nothing
+ */
+static ssize_t
+null_read(struct devfs_node *dnp, struct dev_iobuf *io, int flags)
+{
+ /* We give you a whole lot of nothing! */
+ return io->count;
+}
+
+/*
+ * Take the users carefully crafted bytes made with love
+ * and throw it in the trash
+ */
+static ssize_t
+null_write(struct devfs_node *dnp, struct dev_iobuf *io, int flags)
+{
+ return io->count;
+}
static int
-ehci_init(struct module *modp)
+init_devnull(struct module *modp)
{
int error;
- if ((error = pci_advoc(&driver)) < 0) {
- pr_trace("failed to advocate for xhc\n");
+ error = devfs_register(
+ "null",
+ DEVFS_CDEV,
+ &null_cdev,
+ 0
+ );
+
+ if (error < 0) {
+ printf("null: could not create /dev/null\n");
return error;
}
return 0;
}
-/*
- * Called when an EHCI host controller is detected
- * on the machine
- */
-static int
-ehci_attach(struct pci_adv *adv)
-{
- dev = adv->lookup;
- pr_trace("detected EHCI controller\n");
- return 0;
-}
-
-static struct pci_adv driver = {
- .lookup = PCI_CS_ID(0x0C, 0x03),
- .attach = ehci_attach,
- .classrev = 1,
+static struct cdevsw null_cdev = {
+ .read = null_read,
+ .write = null_write
};
-MODULE_EXPORT("ehci", MODTYPE_PCI, ehci_init);
+MODULE_EXPORT("null", MODTYPE_GENERIC, init_devnull);
diff --git a/src/sys/os/vfs_mount.c b/src/sys/os/vfs_mount.c
index 034b324..8048352 100644
--- a/src/sys/os/vfs_mount.c
+++ b/src/sys/os/vfs_mount.c
@@ -165,7 +165,7 @@ mount_alloc(const char *name, struct mount **mp_res)
* Mount a filesystem
*/
int
-mount(struct mount_args *margs, uint32_t flags)
+kmount(struct mount_args *margs, uint32_t flags)
{
const struct vfsops *vfsops;
struct mount *mpp;
@@ -256,6 +256,6 @@ mountlist_init(struct mountlist *mlp)
TAILQ_INIT(&mlp->list);
mlp->i = 1;
- mount(&margs, 0);
+ kmount(&margs, 0);
return 0;
}