From 6a479621e9d692b55e4069aa5a1afc04ff70cecf Mon Sep 17 00:00:00 2001 From: Ivan Baravy Date: Mon, 6 Feb 2023 14:16:35 +0000 Subject: [PATCH] Fix network on windows --- makefile | 2 +- shell.c | 6 +----- umka.asm | 4 ++-- vdisk/qcow2.c | 2 +- vdisk/raw.c | 2 +- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/makefile b/makefile index ae8fa93..3cadb51 100644 --- a/makefile +++ b/makefile @@ -62,7 +62,7 @@ umka_shell: umka_shell.o umka.o shell.o trace.o trace_lbr.o vdisk.o \ $(HOST)/vnet/tap.o vnet/file.o lodepng.o $(HOST)/pci.o \ $(HOST)/thread.o umkaio.o umkart.o deps/optparse/optparse.o \ deps/isocline/src/isocline.o - $(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld $(LIBS) + $(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld $(LIBS) -lws2_32 umka_fuse: umka_fuse.o umka.o trace.o trace_lbr.o vdisk.o vdisk/raw.o \ vdisk/qcow2.o deps/em_inflate/em_inflate.o $(HOST)/pci.o \ diff --git a/shell.c b/shell.c index 939d992..f1df132 100644 --- a/shell.c +++ b/shell.c @@ -1510,7 +1510,7 @@ cmd_set_keyboard_layout(struct shell_ctx *ctx, int argc, char **argv) { uint8_t layout[KOS_LAYOUT_SIZE]; if (!strcmp(argv[3], "-f") && argc == 5) { const char *fname = argv[4]; - FILE *f = fopen(fname, "r"); + FILE *f = fopen(fname, "rb"); if (!f) { fprintf(ctx->fout, "can't open file: %s\n", fname); fputs(usage, ctx->fout); @@ -2877,7 +2877,6 @@ cmd_load_dll(struct shell_ctx *ctx, int argc, char **argv) { } -#ifndef _WIN32 static void cmd_stack_init(struct shell_ctx *ctx, int argc, char **argv) { @@ -3630,7 +3629,6 @@ cmd_net_arp_del_entry(struct shell_ctx *ctx, int argc, char **argv) { } } -#endif // _WIN32 static void cmd_osloop(struct shell_ctx *ctx, int argc, char **argv) { @@ -3901,7 +3899,6 @@ func_table_t cmd_cmds[] = { { "ls80", cmd_ls80 }, { "move_window", cmd_move_window }, { "mouse_move", cmd_mouse_move }, -#ifndef _WIN32 { "stack_init", cmd_stack_init }, { "net_accept", cmd_net_accept }, { "net_add_device", cmd_net_add_device }, @@ -3934,7 +3931,6 @@ func_table_t cmd_cmds[] = { { "net_ipv4_set_subnet", cmd_net_ipv4_set_subnet }, { "net_listen", cmd_net_listen }, { "net_open_socket", cmd_net_open_socket }, -#endif // _WIN32 { "osloop", cmd_osloop }, { "pci_get_path", cmd_pci_get_path }, { "pci_set_path", cmd_pci_set_path }, diff --git a/umka.asm b/umka.asm index 22b41bd..94d141c 100644 --- a/umka.asm +++ b/umka.asm @@ -144,8 +144,8 @@ pubsym acpi_node_alloc_cnt, 'kos_acpi_node_alloc_cnt' pubsym acpi_node_free_cnt, 'kos_acpi_node_free_cnt' pubsym acpi.count_nodes, 'kos_acpi_count_nodes', 4 -pubsym stack_init, 'kos_stack_init' -pubsym net_add_device +pubsym stack_init, 'kos_stack_init', no_mangle +pubsym net_add_device, no_mangle pubsym draw_data pubsym img_background diff --git a/vdisk/qcow2.c b/vdisk/qcow2.c index da7ccb7..0c621c0 100644 --- a/vdisk/qcow2.c +++ b/vdisk/qcow2.c @@ -213,7 +213,7 @@ vdisk_init_qcow2(const char *fname, struct umka_io *io) { }; d->vdisk.io = io; d->prev_cluster_index = ~(uint64_t)0; - if (!(d->fd = open(fname, O_RDONLY))) { + if (!(d->fd = open(fname, O_RDONLY | O_BINARY))) { fprintf(stderr, "[vdisk.qcow2] can't open file '%s': %s\n", fname, strerror(errno)); vdisk_qcow2_close(d); diff --git a/vdisk/raw.c b/vdisk/raw.c index 76168b1..a6638a4 100644 --- a/vdisk/raw.c +++ b/vdisk/raw.c @@ -55,7 +55,7 @@ vdisk_raw_write(void *userdata, void *buffer, off_t startsector, struct vdisk* vdisk_init_raw(const char *fname, struct umka_io *io) { - int fd = open(fname, O_RDONLY); + int fd = open(fname, O_RDONLY | O_BINARY); if (!fd) { printf("[vdisk.raw]: can't open file '%s': %s\n", fname, strerror(errno)); return NULL;