Commit Graph

209 Commits

Author SHA1 Message Date
Bananymous 225c7c6ab4 AOC2023: Implement day11 2023-12-11 14:36:33 +02:00
Bananymous 58633ca373 AOC2023: Remove unnecessary loop 2023-12-10 20:18:59 +02:00
Bananymous 00d57d783e LibC+userspace: Make everything compile with -Wall -Wextra -Werror
I added -Wall -Wextra -Werror as public compile flags to libc. Now
everything in userspace in compiled using these flags. I made all
necessary changes to allow compilation to work.

Only exception is execvp which has a large stack usage. Maybe it
should use malloc for the buffer but posix allows ENOMEM only when
kernel is out of memory... This can be fixed when fexecve is
implemented and there is no need for absolute path.
2023-12-10 19:20:14 +02:00
Bananymous f077e17b2a AOC2023: Implement day10 2023-12-10 18:28:04 +02:00
Bananymous a6bfbbf655 ls: Rewrite whole program for cleaner output
ls -l now sorts elements and aligns them by columns.
2023-12-10 01:05:12 +02:00
Bananymous c273bf98c9 ls+stat: show setuid, setgid and sticky bits 2023-12-09 19:43:25 +02:00
Bananymous 99a5b6e2ef AOC2023: Cleanup day9 code
Move tree building to its own function. Both parts can use the same
tree. This also decreaseas memory usage by one element by row :D
2023-12-09 19:08:13 +02:00
Bananymous 0c3e5980d6 AOC2023: Implement day9 2023-12-09 16:22:43 +02:00
Bananymous 2b927b9729 BAN: Restructure sort functions and namespaces 2023-12-08 18:58:47 +02:00
Bananymous b523ccb893 AOC2023: Implement day8
Second part was kinda weird. You are supposted to assume something
of the input, which necessarily is not true.
2023-12-08 17:13:20 +02:00
Bananymous 7bb3172591 AOC2023: Use the default sort algorithm 2023-12-08 00:10:59 +02:00
Bananymous 3bc7113cc5 sudo: fix some typos 2023-12-07 14:05:17 +02:00
Bananymous 24243268a6 Shell: do path resolution only if command doesn't contain '/' 2023-12-07 13:34:46 +02:00
Bananymous 669d55707e AOC2023: Use quick sort in solution 2023-12-07 11:55:28 +02:00
Bananymous 6caa9b6f95 BAN: implement quick sort and test for it 2023-12-07 11:55:28 +02:00
Bananymous 43458cc74f BAN: implement exchange sort and test for it 2023-12-07 11:55:28 +02:00
Bananymous 536bb74d53 AOC2023: optimize hand score calculation 2023-12-07 09:26:17 +02:00
Bananymous efd8be8207 AOC2023: implement day7 2023-12-07 07:56:56 +02:00
Bananymous 06a84da844 Userspace: Implement barebones sudo
This doesn't do any password checking or anything. Just sets uid and
gid before execvp()
2023-12-06 18:15:42 +02:00
Bananymous ff8b3be8dc Userspace: implement basic sleep command 2023-12-06 13:05:53 +02:00
Bananymous 56008869d6 Shell: Handle keyboard input that was interrupted by signal 2023-12-06 13:04:33 +02:00
Bananymous 531211e09d AOC2023: implement day6 2023-12-06 07:27:25 +02:00
Bananymous 82cb2ea20b AOC2023: implement day5 2023-12-05 09:13:13 +02:00
Bananymous 622007f2ee Shell: Verify that command exists before executing it
This prevents page fault somewhere when executing non-existing
commands.
2023-12-04 22:57:27 +02:00
Bananymous cf76d2e7d9 AOC2023: remove unnecessary loop 2023-12-04 17:54:10 +02:00
Bananymous 41f8974080 AOC2023: implement day4 2023-12-04 17:51:27 +02:00
Bananymous 3ed25425a3 AOC2023: implement day3
Solution to second puzzle is not optimal, it definately should be
O(1) space, but I didn't want to think about it.
2023-12-03 17:07:09 +02:00
Bananymous 49f8c4268f AOC2023: implement day2 2023-12-02 16:10:37 +02:00
Bananymous 70c224d8ea AOC2023: Cleanup day1 code 2023-12-01 13:31:55 +02:00
Bananymous 6a7335e5c9 AOC2023: implement day1 2023-12-01 12:38:01 +02:00
Bananymous 3aaa755c51 AOC2023: update buildsystem 2023-12-01 12:38:01 +02:00
Bananymous dabd79afa7 Userspace: Prepare aoc2023 environment :) 2023-12-01 01:22:53 +02:00
Bananymous 6ccb1bbbf9 init: set default termios on every username prompt
Before if e.g. Shell crashed init would have broken termios
2023-12-01 01:22:53 +02:00
Bananymous 8564b59e14 image: Remove inheritance from Netbpm
This inheritance made no sense
2023-11-29 20:56:05 +02:00
Bananymous 327b330338 Kernel: Make internal framebuffer bpp constexpr defined in libc 2023-11-29 20:07:33 +02:00
Bananymous 7090388c70 cp: allow copying all files except directories
The old condition seemed odd. This allows taking screen shots by
copying the /dev/fb0.
2023-11-29 16:13:40 +02:00
Bananymous ff550785a7 Userspace: Implement basic image rendering for Netbpm
You can now render Netbpm (P6) format image to framebuffer using
`image` command. I added basic test image to
/usr/share/images/sample.ppm
2023-11-29 16:11:35 +02:00
Bananymous 056586486d Shell: make clear use \e[2J instead of \e[J
This makes kernel to actually clear the full screen. If framebuffer
did not fit font exactly last row would be left partially uncleared
2023-11-28 23:55:37 +02:00
Bananymous 42a1d26d5b Userspace: Implement basic test for framebuffer mmap 2023-11-28 23:52:22 +02:00
Bananymous 4c3da66c92 mmap-shared-test: Add test case for msync 2023-11-22 22:45:16 +02:00
Bananymous bfe6d60e9e ls: print link targets when listing files 2023-11-11 23:17:18 +02:00
Bananymous 613d6640fe meminfo: better format for files without permissions 2023-11-07 02:41:01 +02:00
Bananymous f6c312a6b3 BuildSystem: using sysroot doesn't need root privileges anymore!
Sysroot is now created with fakeroot. This allows root access to be
only needed for disk image creation, since it uses loopback devices.
2023-11-04 17:50:43 +02:00
Bananymous a63006afaf Userspace: Add quick test for global ctors and dtors 2023-10-30 11:11:10 +02:00
Bananymous ea0d7156a4 rm: add option to remove recursively 2023-10-26 02:32:49 +03:00
Bananymous 81228d3401 Userspace: implement basic rm command 2023-10-25 21:45:27 +03:00
Bananymous 6ee4d10651 Kernel/LibC/Userspace: Implement mkdir and creat
Touch now uses creat insteadd of open with O_CREAT flag
2023-10-25 21:07:26 +03:00
Bananymous c445ea6266 cp: abort copy if write fails 2023-10-25 02:43:02 +03:00
Bananymous e685f38fd1 Userspace: Add basic chmod command 2023-10-25 02:37:19 +03:00
Bananymous 657f95d3f0 Userspace: Implement basic cp
This does not support any meaningful command line arguments but
is a good start.
2023-10-25 00:07:25 +03:00
Bananymous 07f8c972b3 Shell: Set get old termios earlier
I sourced the config file before getting old termios. Sourcing
updated the termios so old_termios was always in non canonical, non
echoing mode.
2023-10-24 19:10:53 +03:00
Bananymous 6f6ccbfa04 meminfo: fix g++ warning for oob write
g++ doesn't realize that read can only return -1
2023-10-24 16:50:21 +03:00
Bananymous 8c792f9c6d Shell: Fix parsing $ with unknown character 2023-10-12 22:24:27 +03:00
Bananymous bc4d272c4f cat: Use write() instead of puts to print file contents
This allows printing files that contain null bytes behave more like
you would expect
2023-10-04 22:16:19 +03:00
Bananymous 57605c2b3e meminfo: Print allocated physical memory percentage 2023-10-03 10:39:27 +03:00
Bananymous 1cd99631e1 Shell: source $HOME/.shellrc if found on Shell startup 2023-10-03 10:39:27 +03:00
Bananymous f67ed9a66e Shell: Implement sourcing scripts 2023-10-03 10:24:10 +03:00
Bananymous 6c11dac113 meminfo: Add process command line to the output 2023-09-30 23:17:31 +03:00
Bananymous 5ee3506474 Kernel: Add physical memory info to /proc/{pid}/meminfo 2023-09-30 22:11:45 +03:00
Bananymous c5119cda97 Userspace: Add meminfo command that parses /proc/{pid}/meminfo 2023-09-30 21:20:53 +03:00
Bananymous 6304388100 Shell: Quick fix to not freeze for multiple seconds
When sync is writing to disk, it reserves whole disk to itself.
This commit makes Shell to read username only once from getpwuid().
We used to get username every time prompt was printed.
2023-09-29 19:20:48 +03:00
Bananymous 96b1186c19 Userspace: Implement basic test for MAP_SHARED 2023-09-29 18:59:37 +03:00
Bananymous b57811b371 Userspace: Implement cat-mmap
This behaves exactly as cat, but uses mmap to read the file.
2023-09-29 17:24:55 +03:00
Bananymous 6eda65eea6 Kernel/LibC/Userspace: Add SYS_POWEROFF + cli tool
You can now shutdown/reboot banan-os with the poweroff cli tool.

Reboot doesn't seem to work on qemu.
2023-09-28 12:36:47 +03:00
Bananymous 4a01e4c3b4 Userspace: Use printf length modifiers when printing 2023-09-28 11:49:31 +03:00
Bananymous 399d5338c6 Shell: String leading and trailing whitespace from commands
This fixes a bug of inserting empty argument if command had trailing
whitespace
2023-09-28 10:28:49 +03:00
Bananymous b573701625 Sync: Add some argument parsing to sync(1)
You can specify --block to make the program wait until sync is
complete.
2023-09-27 00:37:23 +03:00
Bananymous 3ba15b41a3 Kernel/LibC: remove PATH resoltion from kernel
I have no idea why I had made PATH environment variable parsing
to be part of the kernel. Now the shell does the parsing and
environment syscall is no longer needed.
2023-09-23 03:08:14 +03:00
Bananymous 63dc2b6aa6 Kernel: Implement SYS_SYNC and add sync executable to userspace
You can (and have to) manually sync disk after writes to it.
2023-09-11 01:26:27 +03:00
Bananymous 9ebf29991d Kernel: Add basic dd command
This only supports if, of, bs, count and status=progress
2023-09-10 01:19:47 +03:00
Bananymous 921d95d18f All: Clear lines with only whitspace in them 2023-09-10 00:31:42 +03:00
Bananymous 41757b5f6c Shell: Clean exit on ^D and use getchar()
Use getchar() instead of fread(&ch, 1, sizeof(char), stdin). This
is much cleaner.
2023-09-07 15:51:05 +03:00
Bananymous c33c7f8b3b Init: use read instead of fread()
This allows actually correct behaviour. My fread implementation is
flawed. It should not return on '\n'
2023-09-07 15:47:59 +03:00
Bananymous 0d725f68e3 Snake render grid lines without extra space after last '#' 2023-09-05 14:35:53 +03:00
Bananymous c13b5aecfe Snake: Reorder apple generation/snake body update
If new apple was generated to heads previous position after update,
it would not render.
2023-09-05 14:30:30 +03:00
Bananymous ba7e1b9ca5 Kernel: Add /dev/tty symlink that targets the current tty 2023-09-05 01:07:52 +03:00
Bananymous e4041ce5ec Userspace: Implement basic snake game :) 2023-09-04 14:30:45 +03:00
Bananymous 80e7a89f67 BuildSystem: Base sysroot is now distributed as a tar ball
This allows file and directory permissions work as intended.

cmake is now filled with 'sudo' but with sudo timeout this should be
fine.
2023-08-23 10:38:21 +03:00
Bananymous b780df8be0 Shell: hostname is not parsed from /etc/hostname 2023-08-23 10:38:21 +03:00
Bananymous c4210b5810 Shell: use process groups more properly 2023-08-22 14:54:50 +03:00
Bananymous 2dcd4ed131 Shell/init: We now use pgrp instead of pid and init open terminal 2023-08-22 11:37:04 +03:00
Bananymous c1d82282d9 Id: Print username corresponding to uid/euid
Also print euid and egid if they differ from uid or gid.
2023-08-18 15:36:51 +03:00
Bananymous 089da2608c Shell: command execution and parsing support piped commands
There is still problems with "blocking" builtin commands (time),
return value, ...
2023-08-17 12:05:38 +03:00
Bananymous ed5f4d64a8 Shell: add basic printf test 2023-08-16 10:49:34 +03:00
Bananymous a09232a555 cat: use 1025 buffer. this allows reads to be 1024 byte
reading from disk currently returns ENOTSUP if buffer size is not
multiple of sector size.
2023-08-16 09:33:14 +03:00
Bananymous 5a94818210 Shell: $? returns last return value 2023-08-15 09:17:46 +03:00
Bananymous 2441f208c6 Userspace: Add basic whoami command 2023-08-15 09:03:51 +03:00
Bananymous db2eca697e Shell: '\u' in PS1 is replaced with username corresponding to euid 2023-08-14 14:55:23 +03:00
Bananymous 81d79cca61 Shell: ^A moves cursor to the beginning of line 2023-08-14 12:26:22 +03:00
Bananymous 77ff585248 Userspace: implement basic stat
I tried to format the output pretty much how linux does, except for
uid and git -> name resolution which is not implemented
2023-08-11 10:30:50 +03:00
Bananymous dddfa308d7 Shell: Print if the process exited because of a signal 2023-08-01 14:24:36 +03:00
Bananymous 2a851b52f1 BuildSystem: Edit build flags regarding sse and warnings 2023-07-31 22:31:17 +03:00
Bananymous 1d7795e22c Kernel: Hardware exceptions now sends signals to userspace 2023-07-30 14:34:15 +03:00
Bananymous 925df39107 Kernel: Userspace sets the foreground process and Shell handles ^C 2023-07-28 18:10:36 +03:00
Bananymous 2dce0a0415 Kernel: Userspace signal handlers are now called one at a time
I added a syscall for telling the kernel when signal execution has
finished. We should send a random hash or id to the signal trampoline
that we would include in the syscall, so validity of signal exit can
be confirmed.
2023-07-23 13:34:53 +03:00
Bananymous 10169d773d Kernel/LibC: Add SYS_KILL/kill() 2023-07-21 19:27:38 +03:00
Bananymous c2cf98e32f Kernel/LibC: Add bareboness signals
You can now call raise() to raise a signal. Signal handlers are
not yet supported, but the handling works :)
2023-07-21 15:45:02 +03:00
Bananymous fb4b363a16 Init: Use the new pwd.h api for user parsing 2023-07-13 12:01:41 +03:00
Bananymous 8cd91f5a6a Userspace: add basic 'touch' command 2023-07-10 16:38:15 +03:00
Bananymous f65e5f4190 tee: indent with tabs 2023-07-10 16:18:08 +03:00