ext2: increment block on large reads

This commit is contained in:
Michael Shaw 2025-02-14 16:31:16 -05:00
commit 5159a530c6
9 changed files with 184 additions and 72 deletions

View file

@ -11,7 +11,7 @@ SSRC := syscall.S
OBJ := $(CSRC:.c=.o) $(SSRC:.S=.o)
DEP := $(OBJ:.o=.d)
CFLAGS := -Wall -ffreestanding -mno-mmx -mno-sse2 -mno-sse -m64 -MMD -g
CFLAGS := -Wall -ffreestanding -mno-mmx -mno-sse2 -mno-sse -m64 -MMD
LDFLAGS := -nostdlib -static -m elf_x86_64
CURDIR := $(shell pwd | awk -F '/' '{print $$(NF-1),"/",$$NF}' | sed 's/ //g')

View file

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/* shtest: simple userland shell test */
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#define S_IFIFO 0x1000
@ -27,6 +29,48 @@ void _start()
exit(1);
char buf[256];
int n;
/* FIFOs!!!!!!!!! */
write(term, "mknod\n", 5);
int r = mknod("/dev/pts", S_IFIFO, 0);
write(term, "open\n", 5);
int fifofd = open("/dev/pts", 0);
if (fifofd < 0)
write(term, "open failed\n", 12);
/* write hello to fifo */
write(term, "write\n", 6);
int i = write(fifofd, "hello\n", 6);
/* read back from fifo */
write(term, "read\n", 5);
i = read(fifofd, buf, 6);
/* print output to terminal */
write(term, "read back from fifo: ", 22);
write(term, buf, i);
promptfd(term);
/* fork test */
while ((n = read(term, buf, 256)) > 0) {
write(term, buf, n);
if(buf[0] == 'q')
break;
}
exit(1234);
}
void end()
{
int term = open("/dev/tty0", 0);
if (term < 0)
exit(1);
char buf[256];
int n;
@ -42,24 +86,47 @@ void _start()
i = read(fifofd, buf, 6);
/* print output to terminal */
write(term, "read back from fifo: ", 22);
write(term, buf, i);
promptfd(term);
/* fork test */
while ((n = read(term, buf, 256)) > 0) {
write(term, buf, n);
if(buf[0] == 'q')
break;
}
exit(1234);
}
void lol()
{
int term = open("/dev/tty0", 0);
if (term < 0)
exit(1);
char buf[256];
int n;
/* FIFOs!!!!!!!!! */
int r = mknod("/dev/pts", S_IFIFO, 0);
int fifofd = open("/dev/pts", 0);
if (fifofd < 0)
write(term, "open failed\n", 12);
/* write hello to fifo */
int i = write(fifofd, "hello\n", 6);
/* read back from fifo */
i = read(fifofd, buf, 6);
/* print output to terminal */
write(term, "read back from fifo: ", 22);
write(term, buf, i);
promptfd(term);
/* fork test */
pid_t pid = fork();
if (pid < 0) {
write(term, "fork failed\n", 12);
exit(1);
}
if (pid == 0) {
write(term, "child\n", 6);
exit(1);
} else {
write(term, "parent\n", 7);
}
/* rw test */
while ((n = read(term, buf, 256)) > 0) {
write(term, buf, n);