Split I/O code to generic io* and platform specific io_async*

This commit is contained in:
2023-01-18 08:29:08 +00:00
parent 3345936052
commit 76c7819882
99 changed files with 453 additions and 259 deletions
+6 -4
View File
@@ -20,19 +20,21 @@ start:
mcall 12, 1
mcall 0, <100,200>, <100,100>, 0x34888888, , window_title
mcall 12, 2
DEBUGF 1, "abcde\n"
mcall 70, fs70
DEBUGF 1, "files in dir: %d\n", ebx
mcall 18, 19, 4, 0
.next:
mcall 37, 0
add eax, 0x00030003
add eax, 0x00020002
mov edx, eax
mcall 18, 19, 4
mcall 5, 1
; mov ecx, 0x1000000
; loopnz $
jmp .next
DEBUGF 1, "abcde\n"
mcall 70, fs70
DEBUGF 1, "files in dir: %d\n", ebx
mcall -1
exit:
; mcall 18, 9, 2
+52
View File
@@ -0,0 +1,52 @@
/*
SPDX-License-Identifier: GPL-2.0-or-later
UMKa - User-Mode KolibriOS developer tools
io - input/output platform specific code
Copyright (C) 2023 Ivan Baravy <dunkaist@gmail.com>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <inttypes.h>
#include "io.h"
#include "io_async.h"
struct umka_io *
io_init(int *running) {
struct umka_io *io = malloc(sizeof(struct umka_io));
io->running = running;
io->async = io_async_init();
return io;
}
void
io_close(struct umka_io *io) {
io_async_close(io->async);
free(io);
}
ssize_t
io_read(int fd, void *buf, size_t count, struct umka_io *io) {
ssize_t res;
if (!*io->running) {
res = read(fd, buf, count);
} else {
res = io_async_read(fd, buf, count, io->async);
}
return res;
}
ssize_t
io_write(int fd, const void *buf, size_t count, struct umka_io *io) {
ssize_t res;
if (!*io->running) {
res = write(fd, buf, count);
} else {
res = io_async_write(fd, buf, count, io->async);
}
return res;
}
+9 -7
View File
@@ -12,19 +12,21 @@
#include <unistd.h>
#define IO_DONT_CHANGE_TASK 0
#define IO_CHANGE_TASK 1
struct umka_io {
const int *running;
void *async; // platform specific
};
void *
io_init(int change_task);
struct umka_io *
io_init(int *running);
void
io_close(void *arg);
io_close(struct umka_io *io);
ssize_t
io_read(int fd, void *buf, size_t count, void *arg);
io_read(int fd, void *buf, size_t count, struct umka_io *io);
ssize_t
io_write(int fd, const void *buf, size_t count, void *arg);
io_write(int fd, const void *buf, size_t count, struct umka_io *io);
#endif // IO_H_INCLUDED
-51
View File
@@ -1,51 +0,0 @@
/*
SPDX-License-Identifier: GPL-2.0-or-later
UMKa - User-Mode KolibriOS developer tools
io - input/output platform specific code
Copyright (C) 2023 Ivan Baravy <dunkaist@gmail.com>
*/
#include <stdlib.h>
#include <unistd.h>
#include "io.h"
struct umka_io {
int change_task;
int uring_fd;
};
void *
io_init(int change_task) {
struct umka_io *io = malloc(sizeof(struct umka_io));
io->change_task = change_task;
if (change_task) {
io->uring_fd = 1;
}
return io;
}
void
io_close(void *arg) {
struct umka_io *io = arg;
free(io);
}
ssize_t
io_read(int fd, void *buf, size_t count, void *arg) {
struct umka_io *io = arg;
(void)io;
ssize_t res;
res = read(fd, buf, count);
return res;
}
ssize_t
io_write(int fd, const void *buf, size_t count, void *arg) {
struct umka_io *io = arg;
(void)io;
ssize_t res;
res = write(fd, buf, count);
return res;
}
+212
View File
@@ -0,0 +1,212 @@
/*
SPDX-License-Identifier: GPL-2.0-or-later
UMKa - User-Mode KolibriOS developer tools
io_async - input/output platform specific code
Copyright (C) 2023 Ivan Baravy <dunkaist@gmail.com>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <inttypes.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <linux/io_uring.h>
#include "../umka.h"
#define QUEUE_DEPTH 1
#define read_barrier() __asm__ __volatile__("":::"memory")
#define write_barrier() __asm__ __volatile__("":::"memory")
#define MAX(x, y) ((x) >= (y) ? (x) : (y))
struct io_uring_queue {
int fd;
void *base;
size_t base_mmap_len;
struct io_uring_params p;
uint32_t *array;
struct io_uring_sqe *sqes;
size_t sqes_mmap_len;
uint32_t *sq_head, *sq_tail;
uint32_t sq_mask;
struct io_uring_cqe *cqes;
uint32_t *cq_head, *cq_tail;
uint32_t cq_mask;
};
static int
io_uring_setup(unsigned entries, struct io_uring_params *p) {
return (int) syscall(__NR_io_uring_setup, entries, p);
}
static int
io_uring_enter(int ring_fd, unsigned int to_submit, unsigned int min_complete,
unsigned int flags) {
return (int) syscall(__NR_io_uring_enter, ring_fd, to_submit, min_complete,
flags, NULL, 0);
}
/*
static void
dump_scht(char *prefix, struct io_uring_queue *q) {
fprintf(stderr, "# async %s: %p %p\n", prefix, (void*)q, q->base);
size_t head, tail, mask;
read_barrier();
mask = q->sq_mask;
mask = *(uint32_t*)(((uintptr_t)q->base) + q->p.sq_off.ring_mask);
head = *q->sq_head & mask;
tail = *q->sq_tail & mask;
fprintf(stderr, "######### %s ######### sq %u:%u 0x%x\n", prefix, head, tail, mask);
mask = q->cq_mask;
mask = *(uint32_t*)(((uintptr_t)q->base) + q->p.cq_off.ring_mask);
head = *q->cq_head & mask;
tail = *q->cq_tail & mask;
fprintf(stderr, "######### %s ######### cq %u:%u 0x%x\n", prefix, head, tail, mask);
}
*/
int
cq_has_data(struct io_uring_queue *q) {
size_t head, tail;
read_barrier();
head = *q->cq_head & q->cq_mask;
tail = *q->cq_tail & q->cq_mask;
return head != tail;
}
static void
build_op_read(struct io_uring_sqe *sqe, int fd, void *data, size_t size,
off_t offset) {
sqe->fd = fd;
sqe->flags = 0;
sqe->opcode = IORING_OP_READ;
sqe->addr = (uintptr_t)data;
sqe->len = size;
sqe->off = offset;
sqe->user_data = 0;
}
static int
read_from_cq(struct io_uring_queue *q) {
size_t head, tail;
struct io_uring_cqe *cqe;
do {
read_barrier();
head = *q->cq_head & q->cq_mask;
tail = *q->cq_tail & q->cq_mask;
if (head == tail)
break;
/* Get the entry */
cqe = q->cqes + head;
if (cqe->res < 0) {
fprintf(stderr, "Read error: %s\n", strerror(abs(cqe->res)));
}
(*q->cq_head)++;
} while (head == tail);
write_barrier();
return cqe->res;
}
struct io_uring_queue *
io_async_init() {
struct io_uring_queue *q = calloc(1, sizeof(struct io_uring_queue));
q->fd = io_uring_setup(QUEUE_DEPTH, &q->p);
if (q->fd < 0) {
perror("io_uring_setup");
return NULL;
}
size_t sring_size = q->p.sq_off.array + q->p.sq_entries * sizeof(unsigned);
size_t cring_size = q->p.cq_off.cqes
+ q->p.cq_entries * sizeof(struct io_uring_cqe);
size_t rings_size = MAX(sring_size, cring_size);
q->base_mmap_len = rings_size;
if (!(q->p.features & IORING_FEAT_SINGLE_MMAP)) {
fprintf(stderr, "[io.uring] Your kernel doesn't support"
" IORING_FEAT_SINGLE_MMAP, upgrade to Linux 5.4\n");
return NULL;
}
q->base = mmap(0, rings_size, PROT_READ | PROT_WRITE, MAP_SHARED
| MAP_POPULATE, q->fd, IORING_OFF_SQ_RING);
if (q->base == MAP_FAILED) {
perror("[io.uring] Can't mmap io_uring rings");
return NULL;
}
q->sqes_mmap_len = q->p.sq_entries * sizeof(struct io_uring_sqe);
q->sqes = mmap(0, q->sqes_mmap_len, PROT_READ | PROT_WRITE, MAP_SHARED
| MAP_POPULATE, q->fd, IORING_OFF_SQES);
if (q->sqes == MAP_FAILED) {
perror("[io.uring] Can't mmap io_uring SQEs");
return NULL;
}
q->cqes = (struct io_uring_cqe*)((uintptr_t)q->base + q->p.cq_off.cqes);
q->array = (uint32_t*)((uintptr_t)q->base + q->p.sq_off.array);
q->sq_head = (uint32_t*)((uintptr_t)q->base + q->p.sq_off.head);
q->sq_tail = (uint32_t*)((uintptr_t)q->base + q->p.sq_off.tail);
q->sq_mask = *(uint32_t*)((uintptr_t)q->base + q->p.sq_off.ring_mask);
q->cq_head = (uint32_t*)((uintptr_t)q->base + q->p.cq_off.head);
q->cq_tail = (uint32_t*)((uintptr_t)q->base + q->p.cq_off.tail);
q->cq_mask = *(uint32_t*)((uintptr_t)q->base + q->p.cq_off.ring_mask);
return q;
}
void
io_async_close(void *arg) {
struct io_uring_queue *q = arg;
munmap(q->base, q->base_mmap_len);
munmap(q->sqes, q->sqes_mmap_len);
close(q->fd);
free(q);
}
static uint32_t
io_uring_wait_test() {
appdata_t *app;
__asm__ __volatile__ ("":"=b"(app)::);
struct io_uring_queue *q = app->wait_param;
int done = cq_has_data(q);
return done;
}
ssize_t
io_async_read(int fd, void *buf, size_t count, void *arg) {
struct io_uring_queue *q = arg;
read_barrier();
size_t tail = *q->sq_tail & q->sq_mask;
struct io_uring_sqe *sqe = q->sqes + tail;
build_op_read(sqe, fd, buf, count, -1);
q->array[tail] = tail;
(*q->sq_tail)++;
int ret = io_uring_enter(q->fd, 1, 0, IORING_ENTER_GETEVENTS);
if(ret < 0) {
perror("io_uring_enter");
return 1;
}
kos_wait_events(io_uring_wait_test, q);
ssize_t res = read_from_cq(q);
return res;
}
ssize_t
io_async_write(int fd, const void *buf, size_t count, void *arg) {
(void)fd;
(void)buf;
(void)count;
(void)arg;
return -1;
}
+27
View File
@@ -0,0 +1,27 @@
/*
SPDX-License-Identifier: GPL-2.0-or-later
UMKa - User-Mode KolibriOS developer tools
io_async - input/output platform specific code
Copyright (C) 2023 Ivan Baravy <dunkaist@gmail.com>
*/
#ifndef IO_ASYNC_H_INCLUDED
#define IO_ASYNC_H_INCLUDED
#include <unistd.h>
void *
io_async_init();
void
io_async_close(void *arg);
ssize_t
io_async_read(int fd, void *buf, size_t count, void *arg);
ssize_t
io_async_write(int fd, const void *buf, size_t count, void *arg);
#endif // IO_ASYNC_H_INCLUDED
+10 -7
View File
@@ -25,7 +25,7 @@ else
endif
CFLAGS=$(WARNINGS) $(NOWARNINGS) -std=c11 -g -O0 -DNDEBUG -masm=intel \
-D_POSIX_C_SOURCE=200809L -I$(HOST) -fno-pie
-D_POSIX_C_SOURCE=200809L -I$(HOST) -I. -fno-pie
CFLAGS_32=$(CFLAGS) -m32 -D_FILE_OFFSET_BITS=64 -D__USE_TIME_BITS64
LDFLAGS=-no-pie
LDFLAGS_32=$(LDFLAGS) -m32
@@ -57,18 +57,18 @@ test: umka_shell
umka_shell: umka_shell.o umka.o shell.o trace.o trace_lbr.o vdisk.o \
vdisk/raw.o vdisk/qcow2.o vdisk/miniz/miniz.a vnet.o lodepng.o \
$(HOST)/pci.o $(HOST)/thread.o $(HOST)/io.o util.o optparse.o \
bestline.o
$(HOST)/pci.o $(HOST)/thread.o io.o $(HOST)/io_async.o util.o \
optparse.o bestline.o
$(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld
umka_fuse: umka_fuse.o umka.o trace.o trace_lbr.o vdisk.o vdisk/raw.o \
vdisk/qcow2.o vdisk/miniz/miniz.a $(HOST)/pci.o $(HOST)/thread.o \
$(HOST)/io.o
io.o $(HOST)/io_async.o
$(CC) $(LDFLAGS_32) $^ -o $@ `pkg-config fuse3 --libs` -T umka.ld
umka_os: umka_os.o umka.o shell.o lodepng.o vdisk.o vdisk/raw.o vdisk/qcow2.o \
vdisk/miniz/miniz.a vnet.o trace.o trace_lbr.o $(HOST)/pci.o \
$(HOST)/thread.o $(HOST)/io.o util.o bestline.o optparse.o
$(HOST)/thread.o io.o $(HOST)/io_async.o util.o bestline.o optparse.o
$(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld
umka_gen_devices_dat: umka_gen_devices_dat.o umka.o $(HOST)/pci.o \
@@ -81,8 +81,11 @@ umka.o umka.fas: umka.asm
shell.o: shell.c lodepng.h
$(CC) $(CFLAGS_32) -c $<
$(HOST)/io.o: $(HOST)/io.c $(HOST)/io.h
$(CC) $(CFLAGS_32) -c $< -o $@
io.o: io.c io.h
$(CC) $(CFLAGS_32) -D_DEFAULT_SOURCE -c $< -o $@
$(HOST)/io_async.o: $(HOST)/io_async.c $(HOST)/io_async.h
$(CC) $(CFLAGS_32) -D_DEFAULT_SOURCE -c $< -o $@
$(HOST)/thread.o: $(HOST)/thread.c
$(CC) $(CFLAGS_32) -c $< -o $@
+11 -25
View File
@@ -323,7 +323,7 @@ get_last_dir(const char *path) {
static void
prompt(struct shell_ctx *ctx) {
if (cur_dir_changed) {
if (ctx->umka && ctx->umka->initialized) {
if (ctx->umka->booted) {
COVERAGE_ON();
umka_sys_get_cwd(cur_dir, PATH_MAX);
COVERAGE_OFF();
@@ -405,34 +405,19 @@ cmd_send_scancode(struct shell_ctx *ctx, int argc, char **argv) {
}
static void
cmd_umka_init(struct shell_ctx *ctx, int argc, char **argv) {
cmd_umka_boot(struct shell_ctx *ctx, int argc, char **argv) {
(void)ctx;
(void)argv;
const char *usage = \
"usage: umka_init <tool>\n"
" <tool> number or string: 1=shell, 2=fuse, 3=os";
if (argc != 2) {
"usage: umka_boot";
if (argc != 1) {
puts(usage);
return;
}
const char *tool_str = argv[1];
unsigned tool;
if (!strcmp(tool_str, "1") || !strcmp(tool_str, "shell")) {
tool = UMKA_SHELL;
} else if (!strcmp(tool_str, "2") || !strcmp(tool_str, "fuse")) {
tool = UMKA_FUSE;
} else if (!strcmp(tool_str, "3") || !strcmp(tool_str, "os")) {
tool = UMKA_OS;
} else {
printf("[!] bad tool value: '%s'\n", tool_str);
return;
}
COVERAGE_ON();
ctx->umka = umka_init(tool);
umka_boot();
COVERAGE_OFF();
if (!ctx->umka) {
printf("![shell] can't init umka\n");
}
}
static void
@@ -3706,7 +3691,7 @@ static void cmd_help(struct shell_ctx *ctx, int argc, char **argv);
func_table_t cmd_cmds[] = {
{ "send_scancode", cmd_send_scancode },
{ "umka_init", cmd_umka_init },
{ "umka_boot", cmd_umka_boot },
{ "umka_set_boot_params", cmd_umka_set_boot_params },
{ "acpi_call", cmd_acpi_call },
{ "acpi_enable", cmd_acpi_enable },
@@ -3912,9 +3897,10 @@ run_test(struct shell_ctx *ctx) {
}
struct shell_ctx *
shell_init(int reproducible, const char *hist_file, struct umka_io *io) {
shell_init(int reproducible, const char *hist_file, struct umka_ctx *umka,
struct umka_io *io) {
struct shell_ctx *ctx = malloc(sizeof(struct shell_ctx));
ctx->umka = NULL;
ctx->umka = umka;
ctx->io = io;
ctx->reproducible = reproducible;
ctx->hist_file = hist_file;
+3 -2
View File
@@ -33,7 +33,7 @@ struct shell_var {
};
struct shell_ctx {
struct umka_ctx *umka;
const struct umka_ctx *umka;
struct umka_io *io;
int reproducible;
const char *hist_file;
@@ -41,7 +41,8 @@ struct shell_ctx {
};
struct shell_ctx *
shell_init(int reproducible, const char *hist_file, struct umka_io *io);
shell_init(int reproducible, const char *hist_file, struct umka_ctx *umka,
struct umka_io *io);
void
shell_close(struct shell_ctx *shell);
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_v4_ftype1_s05k_b2k_n8k.qcow2 hd0 -c 0
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=614400 (300 MiB)
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_v4_ftype1_s05k_b2k_n8k.qcow2 hd0 -c 0
disk_add ../img/xfs_short_dir_i8.qcow2 hd1 -c 0
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=614400 (300 MiB)
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k.qcow2 hd0 -c 524288
ls70 /hd0/1/sf_empty
ls70 /hd0/1/sf
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_v4_files_s05k_b4k_n8k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=614400 (300 MiB)
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_v4_files_s05k_b4k_n8k.qcow2 hd0 -c 524288
# zero length
read70 /hd0/1/no_hole 0 0 -b
+1 -1
View File
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_v4_files_s05k_b4k_n8k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=614400 (300 MiB)
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_v4_files_s05k_b4k_n8k.qcow2 hd0 -c 524288
stat70 /hd0/1/
stat70 /hd0/1/hole_begin
+1 -1
View File
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_v4_files_s05k_b4k_n8k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=614400 (300 MiB)
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_v4_files_s05k_b4k_n8k.qcow2 hd0 -c 524288
pwd
cd /hd0
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_v4_files_s05k_b4k_n8k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=614400 (300 MiB)
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_v4_files_s05k_b4k_n8k.qcow2 hd0 -c 524288
# hole begin
# zero length
+1 -1
View File
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_v4_ftype1_s05k_b2k_n8k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=614400 (300 MiB)
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_v4_ftype1_s05k_b2k_n8k.qcow2 hd0 -c 524288
stat70 /hd0/1/sf_empty
stat70 /hd0/1/sf_empty/.
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_v4_ftype0_s4k_b4k_n8k.qcow2 hd0 -c 524288
/hd0: sector_size=4096, capacity=77312 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=256 (1 MiB), length=76800 (300 MiB)
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_v4_ftype0_s4k_b4k_n8k.qcow2 hd0 -c 524288
ls70 /hd0/1/sf
ls70 /hd0/1/block
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k_xattr.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=614400 (300 MiB)
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k_xattr.qcow2 hd0 -c 524288
ls70 /hd0/1/sf_empty
ls70 /hd0/1/sf
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k_xattr.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=614400 (300 MiB)
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_v4_ftype0_s05k_b2k_n8k_xattr.qcow2 hd0 -c 524288
stat70 /hd0/1/sf_empty
stat70 /hd0/1/sf_empty/.
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_v4_unicode.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=614400 (300 MiB)
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_v4_unicode.qcow2 hd0 -c 524288
stat80 /hd0/1/dir0
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_v5_ftype1_s05k_b2k_n8k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=614400 (300 MiB)
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_v5_ftype1_s05k_b2k_n8k.qcow2 hd0 -c 524288
ls70 /hd0/1/sf_empty
ls70 /hd0/1/sf
+1 -1
View File
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_v5_ftype1_s05k_b2k_n8k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=614400 (300 MiB)
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_v5_ftype1_s05k_b2k_n8k.qcow2 hd0 -c 524288
stat70 /hd0/1/sf_empty
stat70 /hd0/1/sf_empty/.
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_v5_files_s05k_b4k_n8k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=614400 (300 MiB)
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_v5_files_s05k_b4k_n8k.qcow2 hd0 -c 524288
# hole begin
# zero length
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_v5_files_s05k_b4k_n8k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=614400 (300 MiB)
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_v5_files_s05k_b4k_n8k.qcow2 hd0 -c 524288
# zero length
read70 /hd0/1/no_hole 0 0 -b
+1 -1
View File
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> set_mouse_pos_screen 40 30
/> #disk_add ../img/kolibri.raw rd -c 0
/> ramdisk_init ../img/kolibri.raw
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
set_mouse_pos_screen 40 30
#disk_add ../img/kolibri.raw rd -c 0
ramdisk_init ../img/kolibri.raw
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_v4_files_s05k_b4k_n8k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=614400 (300 MiB)
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_v4_files_s05k_b4k_n8k.qcow2 hd0 -c 524288
read70 /hd0/1/4GiB_plus 0x3ff4 11 -b
+1 -1
View File
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/jfs.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=32768 (16 MiB), num_partitions=1
/hd0/1: fs=???, start=2048 (1 MiB), length=28672 (14 MiB)
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/jfs.qcow2 hd0 -c 524288
disk_del hd0
disk_add ../img/xfs_borg_bit.qcow2 hd0 -c 524288
+1 -1
View File
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_v4_btrees_l2.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=614400 (300 MiB)
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_v4_btrees_l2.qcow2 hd0 -c 524288
ls80 /hd0/1/dir_btree_l2 -f 0 -c 1
+1 -1
View File
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> i40 18 16
eax = 00040000 262144 262144
ebx = 00000010 16 16
+1 -1
View File
@@ -1,2 +1,2 @@
umka_init shell
umka_boot
i40 18 16
+1 -1
View File
@@ -1,5 +1,5 @@
/> umka_set_boot_params --x_res 44 --y_res 44
/> umka_init shell
/> umka_boot
/> ramdisk_init ../img/kolibri.raw
/rd: sector_size=512, capacity=2880 (1440 kiB), num_partitions=1
/rd/1: fs=fat, start=0 (0 B), length=2880 (1440 kiB)
+1 -1
View File
@@ -1,5 +1,5 @@
umka_set_boot_params --x_res 44 --y_res 44
umka_init shell
umka_boot
ramdisk_init ../img/kolibri.raw
set_skin /sys/DEFAULT.SKN
+1 -1
View File
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/fat32_test0.raw hd0 -c 0
/hd0: sector_size=512, capacity=131072 (64 MiB), num_partitions=1
/hd0/1: fs=fat, start=2048 (1 MiB), length=126976 (62 MiB)
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/fat32_test0.raw hd0 -c 0
ls80 /hd0/1/
read70 /hd0/1/A 0 16388096 -h
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/exfat_s05k_c16k_b16k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=exfat, start=2048 (1 MiB), length=614400 (300 MiB)
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/exfat_s05k_c16k_b16k.qcow2 hd0 -c 524288
ls70 /hd0/1/dir_0 -f 0 -c 0
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/exfat_s05k_c8k_b8k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=exfat, start=2048 (1 MiB), length=614400 (300 MiB)
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/exfat_s05k_c8k_b8k.qcow2 hd0 -c 524288
stat70 /hd0/1/dir_000
+1 -1
View File
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/>
/> get_keyboard_mode
keyboard_mode: 0 - ASCII
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
get_keyboard_mode
get_keyboard_lang
+1 -1
View File
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/>
/> get_mouse_pos_screen
x y: 200 150
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
get_mouse_pos_screen
get_mouse_pos_window
+1 -1
View File
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> #set_mouse_pos_screen 40 30
/> ramdisk_init ../img/kolibri.raw
/rd: sector_size=512, capacity=2880 (1440 kiB), num_partitions=1
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
#set_mouse_pos_screen 40 30
ramdisk_init ../img/kolibri.raw
set_skin /sys/DEFAULT.SKN
+1 -1
View File
@@ -1,3 +1,3 @@
umka_init shell
umka_boot
check_for_event
check_for_event
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/>
/> ramdisk_init ../img/kolibri.raw
/rd: sector_size=512, capacity=2880 (1440 kiB), num_partitions=1
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
ramdisk_init ../img/kolibri.raw
set_skin /sys/DEFAULT.SKN
+1 -1
View File
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_bigtime.qcow2 hd0 -c 0
/hd0: sector_size=512, capacity=618496 (302 MiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=614400 (300 MiB)
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_bigtime.qcow2 hd0 -c 0
ls70 /hd0/1/
ls70 /hd0/1/dira
+1 -1
View File
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_nrext64.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=6291456 (3 GiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=6287360 (3070 MiB)
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_nrext64.qcow2 hd0 -c 524288
stat70 /hd0/1/dir_sf
stat70 /hd0/1/dir_block
+1 -1
View File
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_lookup_v5.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=10485760 (5 GiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=10481664 (5118 MiB)
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_lookup_v5.qcow2 hd0 -c 524288
cd /hd0/1/dir_sf
stat70 d0000000000/d0000000000
+1 -1
View File
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_lookup_v4.qcow2 hd0 -c 1048576
/hd0: sector_size=512, capacity=6291456 (3 GiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=6287360 (3070 MiB)
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_lookup_v4.qcow2 hd0 -c 1048576
cd /hd0/1/dir_sf
stat70 d0000000000/d0000000000
+1 -1
View File
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/gpt_partitions_s05k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=2097152 (1 GiB), num_partitions=24
/hd0/1: fs=???, start=2048 (1 MiB), length=2048 (1 MiB)
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/gpt_partitions_s05k.qcow2 hd0 -c 524288
disk_del hd0
disk_add ../img/gpt_partitions_s4k.qcow2 hd0 -c 524288
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/ext2_s05k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=10485760 (5 GiB), num_partitions=1
/hd0/1: fs=ext, start=2048 (1 MiB), length=10481664 (5118 MiB)
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/ext2_s05k.qcow2 hd0 -c 524288
ls70 /hd0/1/dir_a
ls70 /hd0/1/dir_b
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/ext4_s05k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=10485760 (5 GiB), num_partitions=1
/hd0/1: fs=???, start=2048 (1 MiB), length=10481664 (5118 MiB)
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/ext4_s05k.qcow2 hd0 -c 524288
ls70 /hd0/1/dir_a
ls70 /hd0/1/dir_b
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/fat12_s05k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=524288 (256 MiB), num_partitions=1
/hd0/1: fs=fat, start=2048 (1 MiB), length=520192 (254 MiB)
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/fat12_s05k.qcow2 hd0 -c 524288
ls70 /hd0/1/dir_a
ls70 /hd0/1/dir_b
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/fat16_s05k.qcow2 hd0 -c 524288
/hd0: sector_size=512, capacity=8388608 (4 GiB), num_partitions=1
/hd0/1: fs=fat, start=2048 (1 MiB), length=8384481 (4292854272 B)
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/fat16_s05k.qcow2 hd0 -c 524288
ls70 /hd0/1/dir_a
ls70 /hd0/1/dir_b
@@ -1,4 +1,4 @@
/> umka_init shell
/> umka_boot
/> disk_add ../img/xfs_samehash_s05k.raw hd0 -c 0
/hd0: sector_size=512, capacity=2097152 (1 GiB), num_partitions=1
/hd0/1: fs=xfs, start=2048 (1 MiB), length=2093056 (1022 MiB)
@@ -1,4 +1,4 @@
umka_init shell
umka_boot
disk_add ../img/xfs_samehash_s05k.raw hd0 -c 0
ls70 /hd0/1/dir_sf
ls70 /hd0/1/dir_block
+12 -13
View File
@@ -116,6 +116,7 @@ pubsym sha3_256_oneshot, 'hash_oneshot'
pubsym kos_time_to_epoch
pubsym umka_init, 4
pubsym umka_close, 4
pubsym umka_boot
pubsym current_process, 'kos_current_process'
pubsym current_slot, 'kos_current_slot'
@@ -570,18 +571,15 @@ proc kos_eth_input c uses ebx esi edi ebp, buffer_ptr
endp
struct umka_ctx
tool dd ?
initialized dd ?
booted dd ?
running dd ?
ends
proc umka_init c uses ebx esi edi ebp, _tool
proc umka_init c uses ebx esi edi ebp
call umka._.check_alignment
stdcall kos_init
stdcall kernel_alloc, sizeof.umka_ctx
mov ecx, [_tool]
mov [umka_tool], ecx
mov [eax+umka_ctx.tool], ecx
mov [eax+umka_ctx.initialized], 1
mov eax, umka
mov [eax+umka_ctx.booted], 0
mov [eax+umka_ctx.running], 0
ret
endp
@@ -590,7 +588,8 @@ proc umka_close c, _ctx
ret
endp
proc kos_init uses ebx esi edi ebp
proc umka_boot uses ebx esi edi ebp
mov [umka.booted], 1
mov edi, endofcode
mov ecx, uglobals_size
xor eax, eax
@@ -1035,8 +1034,8 @@ bios32_entry equ bios32_entry_pew
tmp_page_tabs equ tmp_page_tabs_pew
macro jmp target {
if target eq osloop
cmp [umka_tool], UMKA_SHELL
jnz osloop
cmp [umka.running], 1
jz osloop
ret
else
jmp target
@@ -1079,7 +1078,7 @@ else
error "Your OS is not supported"
end if
umka_tool dd ?
umka umka_ctx
fpu_owner dd ?
uglobal
+5 -2
View File
@@ -29,8 +29,8 @@ typedef void siginfo_t;
#define STDCALL __attribute__((__stdcall__))
struct umka_ctx {
uint32_t tool;
uint32_t initialized;
int booted;
int running;
};
#define UMKA_DEFAULT_DISPLAY_BPP 32
@@ -547,6 +547,9 @@ umka_init(int tool);
void
umka_close(struct umka_ctx *ctx);
void
umka_boot(void);
void
i40(void);
+2 -2
View File
@@ -36,8 +36,8 @@ struct umka_fuse_ctx {
static struct umka_fuse_ctx *
umka_fuse_init() {
struct umka_fuse_ctx *ctx = malloc(sizeof(struct umka_fuse_ctx));
ctx->umka = NULL;
ctx->io = io_init(IO_DONT_CHANGE_TASK);
ctx->umka = umka_init(UMKA_FUSE);
ctx->io = io_init(&ctx->umka->running);
return ctx;
}
+4 -3
View File
@@ -52,10 +52,10 @@ hw_int_mouse(void *arg) {
struct umka_os_ctx *
umka_os_init() {
struct umka_os_ctx *ctx = malloc(sizeof(struct umka_os_ctx));
ctx->umka = NULL;
ctx->io = io_init(IO_DONT_CHANGE_TASK);
ctx->umka = umka_init(UMKA_OS);
ctx->io = io_init(&ctx->umka->running);
ctx->shell = shell_init(SHELL_LOG_NONREPRODUCIBLE, history_filename,
ctx->io);
ctx->umka, ctx->io);
return ctx;
}
@@ -315,6 +315,7 @@ main(int argc, char *argv[]) {
setitimer(ITIMER_PROF, &timeout, NULL);
ctx->umka->running = 1;
umka_osloop(); // doesn't return
if (coverage)
+1 -1
View File
@@ -1,4 +1,4 @@
umka_init os
umka_boot
ramdisk_init ../img/kolibri.raw
set_skin /sys/DEFAULT.SKN
disk_add ../img/xfs_samehash_s05k.raw hd0 -c 0
+3 -3
View File
@@ -33,9 +33,9 @@ char history_filename[PATH_MAX];
struct umka_shell_ctx *
umka_shell_init(int reproducible) {
struct umka_shell_ctx *ctx = malloc(sizeof(struct umka_shell_ctx));
ctx->umka = NULL;
ctx->io = io_init(IO_DONT_CHANGE_TASK);
ctx->shell = shell_init(reproducible, history_filename, ctx->io);
ctx->umka = umka_init(UMKA_SHELL);
ctx->io = io_init(&ctx->umka->running);
ctx->shell = shell_init(reproducible, history_filename, ctx->umka, ctx->io);
return ctx;
}
+2 -2
View File
@@ -49,10 +49,10 @@ vdisk_init(const char *fname, int adjust_cache_size, size_t cache_size,
struct vdisk *disk;
if (fname_len > dot_raw_len
&& !strcmp(fname + fname_len - dot_raw_len, RAW_SUFFIX)) {
disk = (struct vdisk*)vdisk_init_raw(fname);
disk = (struct vdisk*)vdisk_init_raw(fname, io);
} else if (fname_len > dot_qcow2_len
&& !strcmp(fname + fname_len - dot_qcow2_len, QCOW2_SUFFIX)) {
disk = (struct vdisk*)vdisk_init_qcow2(fname);
disk = (struct vdisk*)vdisk_init_qcow2(fname, io);
} else {
fprintf(stderr, "[vdisk] file has unknown format: %s\n", fname);
return NULL;
+8 -6
View File
@@ -14,6 +14,7 @@
#include "../trace.h"
#include "qcow2.h"
#include "miniz/miniz.h"
#include "io.h"
struct vdisk_qcow2 {
struct vdisk vdisk;
@@ -96,7 +97,7 @@ qcow2_read_guest_sector(struct vdisk_qcow2 *d, uint64_t sector, uint8_t *buf) {
uint64_t l2_entry;
uint64_t l1_entry_offset = d->l1_table_offset + l1_index*sizeof(l1_entry);
lseek(d->fd, l1_entry_offset, SEEK_SET);
if (!read(d->fd, &l1_entry, sizeof(l1_entry))) {
if (!io_read(d->fd, &l1_entry, sizeof(l1_entry), d->vdisk.io)) {
fprintf(stderr, "[vdisk.qcow2] can't read from image file: %s\n",
strerror(errno));
return;
@@ -109,7 +110,7 @@ qcow2_read_guest_sector(struct vdisk_qcow2 *d, uint64_t sector, uint8_t *buf) {
return;
}
lseek(d->fd, l2_table_offset + l2_index*sizeof(l2_entry), SEEK_SET);
if (!read(d->fd, &l2_entry, sizeof(l2_entry))) {
if (!io_read(d->fd, &l2_entry, sizeof(l2_entry), d->vdisk.io)) {
fprintf(stderr, "[vdisk.qcow2] can't read from image file: %s\n",
strerror(errno));
return;
@@ -124,7 +125,7 @@ qcow2_read_guest_sector(struct vdisk_qcow2 *d, uint64_t sector, uint8_t *buf) {
}
cluster_offset = l2_entry & L2_ENTRY_STD_OFFSET;
lseek(d->fd, cluster_offset, SEEK_SET);
if (!read(d->fd, d->cluster, d->cluster_size)) {
if (!io_read(d->fd, d->cluster, d->cluster_size, d->vdisk.io)) {
fprintf(stderr, "[vdisk.qcow2] can't read from image file: %s\n",
strerror(errno));
return;
@@ -139,7 +140,7 @@ qcow2_read_guest_sector(struct vdisk_qcow2 *d, uint64_t sector, uint8_t *buf) {
size_t additional_sectors = (l2_entry & d->l2_entry_cmp_sect_cnt_mask)
>> d->l2_entry_cmp_x;
size_t cmp_size = 512 - (cmp_offset & 511) + additional_sectors*512;
if (!read(d->fd, d->cmp_cluster, d->cluster_size)) {
if (!io_read(d->fd, d->cmp_cluster, d->cluster_size, d->vdisk.io)) {
fprintf(stderr, "[vdisk.qcow2] can't read from image file: %s\n",
strerror(errno));
return;
@@ -193,7 +194,7 @@ vdisk_qcow2_write(void *userdata, void *buffer, off_t startsector,
}
struct vdisk*
vdisk_init_qcow2(const char *fname) {
vdisk_init_qcow2(const char *fname, struct umka_io *io) {
struct vdisk_qcow2 *d =
(struct vdisk_qcow2*)calloc(1, sizeof(struct vdisk_qcow2));
d->vdisk.diskfunc = (diskfunc_t) {.strucsize = sizeof(diskfunc_t),
@@ -201,6 +202,7 @@ vdisk_init_qcow2(const char *fname) {
.read = vdisk_qcow2_read,
.write = vdisk_qcow2_write,
};
d->vdisk.io = io;
if (!d) {
fprintf(stderr, "[vdisk.qcow2] can't allocate memory: %s\n",
strerror(errno));
@@ -219,7 +221,7 @@ vdisk_init_qcow2(const char *fname) {
}
struct qcow2_header header;
if (!read(d->fd, &header, sizeof(struct qcow2_header))) {
if (!io_read(d->fd, &header, sizeof(struct qcow2_header), d->vdisk.io)) {
fprintf(stderr, "[vdisk.qcow2] can't read from image file: %s\n",
strerror(errno));
vdisk_qcow2_close(d);
+3 -2
View File
@@ -11,11 +11,12 @@
#define VDISK_QCOW2_H_INCLUDED
#include <stdio.h>
#include "../vdisk.h"
#include "vdisk.h"
#include "io.h"
#define QCOW2_SUFFIX ".qcow2"
struct vdisk*
vdisk_init_qcow2(const char *fname);
vdisk_init_qcow2(const char *fname, struct umka_io *io);
#endif // VDISK_QCOW2_H_INCLUDED
+3 -2
View File
@@ -54,8 +54,8 @@ vdisk_raw_write(void *userdata, void *buffer, off_t startsector,
}
struct vdisk*
vdisk_init_raw(const char *fname) {
int fd = open(fname, O_RDWR);
vdisk_init_raw(const char *fname, struct umka_io *io) {
int fd = open(fname, O_RDONLY);
if (!fd) {
printf("[vdisk.raw]: can't open file '%s': %s\n", fname, strerror(errno));
return NULL;
@@ -75,6 +75,7 @@ vdisk_init_raw(const char *fname) {
},
.sect_size = sect_size,
.sect_cnt = (uint64_t)fsize / sect_size,
.io = io,
},
.fd = fd,
};
+3 -2
View File
@@ -11,11 +11,12 @@
#define VDISK_RAW_H_INCLUDED
#include <stdio.h>
#include "../vdisk.h"
#include "vdisk.h"
#include "io.h"
#define RAW_SUFFIX ".raw"
struct vdisk*
vdisk_init_raw(const char *fname);
vdisk_init_raw(const char *fname, struct umka_io *io);
#endif // VDISK_RAW_H_INCLUDED
-27
View File
@@ -1,27 +0,0 @@
/*
SPDX-License-Identifier: GPL-2.0-or-later
UMKa - User-Mode KolibriOS developer tools
io - input/output platform specific code
Copyright (C) 2023 Ivan Baravy <dunkaist@gmail.com>
*/
#include <unistd.h>
#include "io.h"
ssize_t
io_read(int fd, void *buf, size_t count, int change_task) {
(void)change_task;
ssize_t res;
res = read(fd, buf, count);
return res;
}
ssize_t
io_write(int fd, const void *buf, size_t count, int change_task) {
(void)change_task;
ssize_t res;
res = write(fd, buf, count);
return res;
}
-21
View File
@@ -1,21 +0,0 @@
/*
SPDX-License-Identifier: GPL-2.0-or-later
UMKa - User-Mode KolibriOS developer tools
io - input/output platform specific code
Copyright (C) 2023 Ivan Baravy <dunkaist@gmail.com>
*/
#ifndef IO_H_INCLUDED
#define IO_H_INCLUDED
#include <unistd.h>
ssize_t
io_read(int fd, void *buf, size_t count, int change_task);
ssize_t
io_write(int fd, const void *buf, size_t count, int change_task);
#endif // IO_H_INCLUDED