Relatively broken local echo support
This commit is contained in:
parent
a8cc561cce
commit
71298a5c83
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,6 +7,7 @@ bootloader/stage1.bin
|
||||
bootloader/stage2.bin
|
||||
initrd/boot
|
||||
initrd/bin/*
|
||||
initrd/etc
|
||||
hdd/boot
|
||||
hdd/bin/*
|
||||
hdd/etc/hostname
|
||||
|
@ -24,6 +24,11 @@ static inline size_t pipe_unread(pipe_device_t * pipe) {
|
||||
}
|
||||
}
|
||||
|
||||
size_t pipe_size(fs_node_t * node) {
|
||||
pipe_device_t * pipe = (pipe_device_t *)node->inode;
|
||||
return pipe_unread(pipe);
|
||||
}
|
||||
|
||||
static inline size_t pipe_available(pipe_device_t * pipe) {
|
||||
if (pipe->read_ptr == pipe->write_ptr) {
|
||||
return pipe->size - 1;
|
||||
|
@ -18,5 +18,6 @@ typedef struct _pipe_device {
|
||||
} pipe_device_t;
|
||||
|
||||
fs_node_t * make_pipe(size_t size);
|
||||
size_t pipe_size(fs_node_t * node);
|
||||
|
||||
#endif
|
||||
|
@ -100,7 +100,7 @@ static int write(int fd, char * ptr, int len) {
|
||||
|
||||
static int wait(int child) {
|
||||
if (child < 1) {
|
||||
kprintf("lol nope\n");
|
||||
kprintf("[debug] Process %d requested group wait, which we can not do!\n", getpid());
|
||||
return 0;
|
||||
}
|
||||
process_t * volatile child_task = process_from_pid(child);
|
||||
@ -122,8 +122,13 @@ static int wait(int child) {
|
||||
}
|
||||
|
||||
static int open(const char * file, int flags, int mode) {
|
||||
kprintf("[debug] open(%s, 0x%x, 0x%x)\n", file, flags, mode);
|
||||
|
||||
validate((void *)file);
|
||||
fs_node_t * node = kopen((char *)file, 0);
|
||||
if (!node && (mode & 0x600)) {
|
||||
/* Um, make one */
|
||||
}
|
||||
if (!node) {
|
||||
return -1;
|
||||
}
|
||||
@ -242,6 +247,11 @@ static int stat(int fd, uint32_t st) {
|
||||
f->st_rdev = 0;
|
||||
f->st_size = fn->length;
|
||||
|
||||
if (fn->flags & FS_PIPE) {
|
||||
/* Pipes have dynamic sizes */
|
||||
f->st_size = pipe_size(fn);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -142,10 +142,7 @@ int main(int argc, char ** argv) {
|
||||
char * cmd = malloc(sizeof(char) * 1024);
|
||||
|
||||
draw_prompt(last_ret);
|
||||
#if 0
|
||||
fgets(cmd, 1024, stdin);
|
||||
#endif
|
||||
readline(cmd, 1024);
|
||||
cmd[strlen(cmd)-1] = '\0';
|
||||
char *p, *tokens[512], *last;
|
||||
int i = 0;
|
||||
|
@ -110,11 +110,14 @@ int main(int argc, char ** argv) {
|
||||
|
||||
fprintf(stdout, "%s login: ", _hostname);
|
||||
fflush(stdout);
|
||||
readline(username, 1024, 1);
|
||||
fgets(username, 1024, stdin);
|
||||
username[strlen(username)-1] = '\0';
|
||||
|
||||
fprintf(stdout, "password: ");
|
||||
fprintf(stdout, "password: \033[1001z");
|
||||
fflush(stdout);
|
||||
readline(password, 1024, 0);
|
||||
fgets(password, 1024, stdin);
|
||||
password[strlen(password)-1] = '\0';
|
||||
fprintf(stdout, "\033[1002z\n");
|
||||
|
||||
int uid = checkUserPass(username, password);
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_CACHE_H
|
||||
@ -175,12 +176,14 @@ ansi_put(
|
||||
{
|
||||
if (argc > 0) {
|
||||
int arg = atoi(argv[0]);
|
||||
switch (argc) {
|
||||
switch (arg) {
|
||||
case 1001:
|
||||
/* Local Echo Off */
|
||||
state.local_echo = 0;
|
||||
break;
|
||||
case 1002:
|
||||
/* Local Echo On */
|
||||
state.local_echo = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -2903,13 +2906,13 @@ int main(int argc, char ** argv) {
|
||||
#endif
|
||||
|
||||
int ofd = syscall_mkpipe();
|
||||
//int ifd = syscall_mkpipe();
|
||||
int ifd = syscall_mkpipe();
|
||||
|
||||
int pid = getpid();
|
||||
uint32_t f = fork();
|
||||
|
||||
if (getpid() != pid) {
|
||||
//syscall_dup2(ifd, 0);
|
||||
syscall_dup2(ifd, 0);
|
||||
syscall_dup2(ofd, 1);
|
||||
syscall_dup2(ofd, 2);
|
||||
char * tokens[] = {"/bin/login",NULL};
|
||||
@ -2918,9 +2921,25 @@ int main(int argc, char ** argv) {
|
||||
} else {
|
||||
char buf[1024];
|
||||
while (1) {
|
||||
int r = read(ofd, buf, 1024);
|
||||
for (uint32_t i = 0; i < r; ++i) {
|
||||
ansi_put(buf[i]);
|
||||
struct stat _stat;
|
||||
fstat(0, &_stat);
|
||||
if (_stat.st_size) {
|
||||
int r = read(0, buf, min(_stat.st_size, 1024));
|
||||
for (uint32_t i = 0; i < r; ++i) {
|
||||
if (state.local_echo) {
|
||||
ansi_put(buf[i]);
|
||||
}
|
||||
char b[1];
|
||||
b[0] = buf[i];
|
||||
write(ifd, b, 1);
|
||||
}
|
||||
}
|
||||
fstat(ofd, &_stat);
|
||||
if (_stat.st_size) {
|
||||
int r = read(ofd, buf, min(_stat.st_size, 1024));
|
||||
for (uint32_t i = 0; i < r; ++i) {
|
||||
ansi_put(buf[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
17
userspace/test-fs.c
Normal file
17
userspace/test-fs.c
Normal file
@ -0,0 +1,17 @@
|
||||
/* vim:tabstop=4 shiftwidth=4 noexpandtab
|
||||
*
|
||||
* File System Test Suite
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
printf("= Begin File System Testing =\n");
|
||||
|
||||
int fd = creat("/test.log", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
|
||||
printf("File descriptor generator: %d\n", fd);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user