Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
with:
go-version: '1.22'
- name: install tools
run: sudo apt update && sudo apt install xorriso mtools grub-pc-bin zip gcc-i686-linux-gnu qemu-system-x86 vncsnapshot curl nasm jq -y
run: sudo apt update && sudo apt install xorriso mtools grub-pc-bin zip gcc-i686-linux-gnu qemu-system-x86 vncsnapshot curl nasm jq libunicorn-dev -y
- name: install fire
run: |
git clone https://github.com/Glowman554/FireStorm
Expand All @@ -49,4 +49,5 @@ jobs:
libs.zip
mckrnl/mckrnl.elf
mckrnl/mckrnl.syms
res/initrd.saf
res/initrd.saf
res/initrd-install.saf
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ libs.zip: all
cp user/libraries/libsyntax/include/* res/libs/include/. -rf

ifeq ($(GUI),1)
cp user/base/desktop/include/* res/libs/include/. -rf
cp user/desktop/libdesktop/include/* res/libs/include/. -rf
endif

zip -r libs.zip res/libs/
Expand Down
28 changes: 24 additions & 4 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ WEBHOOK_URL="$MESSAGE_WEBHOOK"
BUILD_TOKEN="$MICROOS_BUILD_TOKEN"

function do_release {
if [[ "$#" -lt 9 ]]; then
echo "Usage: release <name> <cdrom> <cdromMinimal> <libs> <message> <screenshot> <kernel> <symbols> <initrd>"
if [[ "$#" -lt 10 ]]; then
echo "Usage: release <name> <cdrom> <cdromMinimal> <libs> <message> <screenshot> <kernel> <symbols> <initrd> <initrd-install>"
exit 1
fi

Expand All @@ -22,11 +22,12 @@ function do_release {
local kernel="$7"
local symbols="$8"
local initrd="$9"
local initrd_install="${10}"

echo "Releasing: $name"

send_webhook "$name" "$cdrom" "$cdromMinimal" "$libs" "$message" "$screenshot" "$kernel" "$symbols" "$initrd"
trigger_build "$name" "$kernel" "$symbols" "$initrd"
trigger_build "$name" "$kernel" "$symbols" "$initrd_install"
}

function send_webhook {
Expand Down Expand Up @@ -116,8 +117,25 @@ function release {
local kernel=$(upload_file "mckrnl/core/mckrnl.elf")
local symbols=$(upload_file "mckrnl/core/mckrnl.syms")
local initrd=$(upload_file "res/initrd.saf")
local initrd_install=$(upload_file "res/initrd-install.saf")

do_release "$1" "$cdrom" "$cdrom_minimal" "$libs" "$2" "$screenshot" "$kernel" "$symbols" "$initrd"
do_release "$1" "$cdrom" "$cdrom_minimal" "$libs" "$2" "$screenshot" "$kernel" "$symbols" "$initrd" "$initrd_install"
}

function install_pkgs_initrd {
make -C tools/microemu -B
(
cp res/initrd res/initrd-install -rv
cd res/initrd-install
../../tools/microemu/microemu root:/bin/init.mex bin/terminal.mex <<EOF
cd pkgs
terminal all.msh
pwr off
EOF
rm -rf pkgs
)

./res/saf/saf-make ./res/initrd-install ./res/initrd-install.saf
}

applyPreset $1
Expand All @@ -135,4 +153,6 @@ make iso

screenshot microos.jpg

install_pkgs_initrd

release $1 "$2"
21 changes: 21 additions & 0 deletions tools/microemu/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
SRCS = $(shell find -name '*.[c]')
OBJS = $(addsuffix .o,$(basename $(SRCS)))


CFLAGS = -O2 -Wall -Iinclude -g
LDFLAGS = -lunicorn
PROGRAM ?= microemu

$(PROGRAM): $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS)

install: $(PROGRAM)
cp $(PROGRAM) ~/go/bin/$(PROGRAM)

%.o: %.c
@echo CC $^
@$(CC) $(CFLAGS) -c -o $@ $^

clean:
rm -f $(OBJS) $(PROGRAM)

161 changes: 161 additions & 0 deletions tools/microemu/fs/hostfs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
#include <fs/hostfs.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>

void hostfs_resolve(hostfs_t *hfs, const char *vpath, char *out, size_t out_size) {
snprintf(out, out_size, "%s%s", hfs->host_root, vpath);
}

file_t *hostfs_open(vfs_mount_t *mount, char *path, int flags) {
hostfs_t *hfs = (hostfs_t *)mount;
char resolved[1024];
hostfs_resolve(hfs, path, resolved, sizeof(resolved));

struct stat st;
if (stat(resolved, &st) == 0 && S_ISDIR(st.st_mode)) {
return NULL;
}

int oflags = O_RDONLY;
if (flags == FILE_OPEN_MODE_WRITE) {
oflags = O_WRONLY | O_CREAT;
} else if (flags == FILE_OPEN_MODE_READ_WRITE) {
oflags = O_RDWR | O_CREAT;
}

int fd = open(resolved, oflags, 0644);
if (fd < 0) {
return NULL;
}

file_t *f = calloc(1, sizeof(file_t));
f->mount = mount;
f->mode = flags;
f->driver_specific_data = (void *)(intptr_t)fd;
strncpy(f->path, path, sizeof(f->path) - 1);

if (fstat(fd, &st) == 0) {
f->size = st.st_size;
}

return f;
}

void hostfs_close(vfs_mount_t *mount, file_t *file) {
int fd = (int)(intptr_t)file->driver_specific_data;
close(fd);
free(file);
}

void hostfs_read(vfs_mount_t *mount, file_t *file, void *buf, size_t size, size_t offset) {
int fd = (int)(intptr_t)file->driver_specific_data;
pread(fd, buf, size, offset);
}

void hostfs_write(vfs_mount_t *mount, file_t *file, void *buf, size_t size, size_t offset) {
int fd = (int)(intptr_t)file->driver_specific_data;
pwrite(fd, buf, size, offset);
}

void hostfs_delete(vfs_mount_t *mount, file_t *file) {
hostfs_t *hfs = (hostfs_t *)mount;
char resolved[1024];
hostfs_resolve(hfs, file->path, resolved, sizeof(resolved));
int fd = (int)(intptr_t)file->driver_specific_data;
close(fd);
unlink(resolved);
free(file);
}

void hostfs_mkdir(vfs_mount_t *mount, char *path) {
hostfs_t *hfs = (hostfs_t *)mount;
char resolved[1024];
hostfs_resolve(hfs, path, resolved, sizeof(resolved));
mkdir(resolved, 0755);
}

void hostfs_touch(vfs_mount_t *mount, char *path) {
hostfs_t *hfs = (hostfs_t *)mount;
char resolved[1024];
hostfs_resolve(hfs, path, resolved, sizeof(resolved));
int fd = open(resolved, O_CREAT | O_WRONLY, 0644);
if (fd >= 0) {
close(fd);
}
}

dir_t hostfs_dir_at(vfs_mount_t *mount, int idx, char *path) {
hostfs_t *hfs = (hostfs_t *)mount;
char resolved[1024];
hostfs_resolve(hfs, path, resolved, sizeof(resolved));

dir_t d = { .is_none = true };

DIR *dp = opendir(resolved);
if (!dp) {
return d;
}

struct dirent *ent;
int i = 0;
while ((ent = readdir(dp)) != NULL) {
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) {
continue;
}

if (i == idx) {
strncpy(d.name, ent->d_name, 256);
d.name[255] = '\0';
d.idx = idx;
d.is_none = false;
d.type = (ent->d_type == DT_DIR) ? ENTRY_DIR : ENTRY_FILE;
break;
}
i++;
}
closedir(dp);
return d;
}

void hostfs_delete_dir(vfs_mount_t *mount, char *path) {
hostfs_t *hfs = (hostfs_t *)mount;
char resolved[1024];
hostfs_resolve(hfs, path, resolved, sizeof(resolved));
rmdir(resolved);
}

void hostfs_truncate(vfs_mount_t *mount, file_t *file, size_t new_size) {
int fd = (int)(intptr_t)file->driver_specific_data;
ftruncate(fd, new_size);
file->size = new_size;
}

char *hostfs_name(vfs_mount_t *mount) {
hostfs_t *hfs = (hostfs_t *)mount;
return hfs->mount_name;
}

hostfs_t *hostfs_create(const char *mount_name, const char *host_dir) {
hostfs_t *hfs = calloc(1, sizeof(hostfs_t));
strncpy(hfs->mount_name, mount_name, sizeof(hfs->mount_name) - 1);
strncpy(hfs->host_root, host_dir, sizeof(hfs->host_root) - 1);

hfs->mount.open = hostfs_open;
hfs->mount.close = hostfs_close;
hfs->mount.read = hostfs_read;
hfs->mount.write = hostfs_write;
hfs->mount._delete = hostfs_delete;
hfs->mount.mkdir = hostfs_mkdir;
hfs->mount.touch = hostfs_touch;
hfs->mount.dir_at = hostfs_dir_at;
hfs->mount.delete_dir = hostfs_delete_dir;
hfs->mount.truncate = hostfs_truncate;
hfs->mount.name = hostfs_name;

return hfs;
}
Loading
Loading