Commit Graph

187 Commits

Author SHA1 Message Date
76f48f095c Kernel: Rewrite a lot of ext2 code
This commit consists of multiple big changes

1. blocks for inodes are now allocated on demand
  - reading from non allocated block will just return zeroes
  - writing to non allocated block allocates it

2. code doesn't really use raw pointers anymore
  - all casts to uint32_t or structures are now replaced with
    spans. either as<T> or as_span<T> which both are bounds
	checked

3. code doesn't depend on random macros for accessing indirect blocks
  - i added some recursive functions which take care of this :)
2023-10-28 22:13:28 +03:00
35b46e37bb Kernel: Fix ext2 inode deletion cleanup
I now cleanup all blocks (including direct) in i_block array
2023-10-28 16:52:56 +03:00
38c267b4c8 Kernel: Fix ext2 inode deletion
fsck now reports clean filesystem even after deleting files
2023-10-26 02:05:05 +03:00
b7007016c0 BAN: Implement Ext2 file unlinking
Ext2 inodes can now be unlinked from directories and after last
inode closes (destructor gets called) we check if link count is 0
and cleanup the inode from filesystem
2023-10-25 21:43:36 +03:00
e9b7cf332d Kernel: Implement directory creation for RamFS 2023-10-25 19:41:34 +03:00
4ee2f0f789 Kernel: Implement Ext2 directory creation 2023-10-25 19:37:04 +03:00
18e90d305d Kernel: Add Inode API for creating directories 2023-10-25 19:36:04 +03:00
fd1b331b86 Kernel: Ext2FS now uses Ext2Inodes as cached values 2023-10-25 19:34:00 +03:00
627b8cc140 Kernel/LibC: implement chmod syscall + libc wrapper 2023-10-25 02:35:37 +03:00
f3d9da9549 Kernel: Rewrite all read/write functions to use BAN::ByteSpan
This allows us to not work with raw pointers and use sized containers
for reading and writing.
2023-10-24 11:56:00 +03:00
f21d4e794c Kernel: Rework whole ATA driver structure
Make ATA driver more compatible when we are adding SATA support
2023-10-08 02:50:23 +03:00
Bananymous
39bc6c43dc Kernel: Expose command line and environment to /proc 2023-09-30 23:01:33 +03:00
Bananymous
785de5f9b9 Kernel: /proc/{pid}/meminfo now reports per process memory usage 2023-09-30 21:20:18 +03:00
Bananymous
8f630a97df Kernel: Add procfs that contains only pids 2023-09-30 21:19:36 +03:00
Bananymous
9f0797047f Kernel/LibC: dirent now contains file type 2023-09-30 20:46:57 +03:00
Bananymous
e8a0eeb0b4 Kernel: RamInode verifies that you have not specified mode type
This is kinda weird behaviour, but it ensures the user cannot
create e.g. CharacterDevice with mode having IFLNK.

The Inode overrider is the only one setting the mode.
2023-09-30 20:46:57 +03:00
Bananymous
3e5645d453 Kernel: Add API for RamDirectoryInodes to delete containing inodes 2023-09-30 19:22:30 +03:00
Bananymous
2301654c4e Kernel: Rework RamInode API
RamInode is now a general RamInode with no data. RamFileInode is now
a inode for regular files. This is much cleaner and more intuitive
since there is no reason for most non-regular inodes to hold data
Vector.
2023-09-30 19:22:30 +03:00
Bananymous
43c23db4a6 Kernel: Implement MAP_SHARED for regular files
Every inode holds a weak pointer to shared file data. This contains
physical addresses of pages for inode file data. Physical addresses
are allocated and read on demand.

When last shared mapping is unmapped. The inodes shared data is freed
and written to the inode.
2023-09-29 18:59:20 +03:00
Bananymous
1e6930a3bc Kernel: SYS_SYNC now schedules sync to happen soon
You can pass non-zero argument to the syscall to block until the
sync has finished.
2023-09-27 00:34:00 +03:00
Bananymous
9d55cf1d80 Kernel: Ext2 inodes are now stored in cache
This allows faster inode access and ensures working inodes when
opened in multiple places.
2023-09-25 20:31:40 +03:00
Bananymous
669b2ace4e Kernel: Ext2 filesystem now holds 10 preallocated block buffers
Inodes can query blocks from this buffer. This allows allocation of
blocks to not fail during normal operations. Also less stress on
kmalloc.
2023-09-25 14:32:25 +03:00
Bananymous
0e67c6318b Kernel: Fix ext2 block allocation
Redo ext2 block allocation. This is now much "cleaner" although
I'm not too fond of the macros.
2023-09-25 13:17:44 +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
921d95d18f All: Clear lines with only whitspace in them 2023-09-10 00:31:42 +03:00
Bananymous
dd9af56e21 Kernel: Start work on making inodes more thread safe
All inode operations are now locked and thread blocked
2023-09-10 00:31:42 +03:00
Bananymous
ba7e1b9ca5 Kernel: Add /dev/tty symlink that targets the current tty 2023-09-05 01:07:52 +03:00
Bananymous
f0772e385c Kernel: Implement basic RamSymlinkInode 2023-09-05 01:07:52 +03:00
Bananymous
323de3c866 Kernel: Rework whole Terminal structure
Serial monitors can now be used as a output. This requires editing
init code for the stdio opening. Serial input is not supported, so qemu
still needs graphical window for ps/2 keyboard.
2023-09-04 19:34:18 +03:00
Bananymous
b2139c0b1e Kernel: Add basic support for O_NONBLOCK (only for tty) 2023-09-04 12:57:52 +03:00
Bananymous
a711462ef4 Kernel: Split ext2 implementation to multiple files 2023-09-01 15:10:23 +03:00
Bananymous
f31c6b847f Kernel: Start work on writable ext2 filesystem 2023-08-31 23:40:31 +03:00
Bananymous
195ccf4f53 Kernel: Add missing ififo() to Inode::Mode 2023-08-31 21:38:31 +03:00
Bananymous
cd64c1cfec Kernel: add is_tty() to inode 2023-07-24 22:19:59 +03:00
Bananymous
08cd285ca6 Kernel: move Device.h to its own directory 2023-07-19 23:55:38 +03:00
Bananymous
9bcfb34524 Kernel: Rewrite whole device structure
We now have DevFileSystem which is derived from RamFileSystem. All
devices are RamInodes. We don't have separate DeviceManager anymore.
To iterate over devices, you can loop througn every inode in devfs.
2023-07-10 23:17:14 +03:00
Bananymous
ee4ef6638c Kenrel: RamInode now implements truncate() 2023-07-10 16:07:09 +03:00
Bananymous
d6408bcf17 Kernel: add O_TRUNC
this is not supported by anything yet
2023-07-10 15:48:18 +03:00
Bananymous
89d4fa4d9b Kernel: Ext2 fill now return ENOTSUP on write
We used to crash the kernel
2023-07-10 15:34:25 +03:00
Bananymous
a0ecbed726 Kernel: You can now read/write to RamInodes
RamFS should be stored on physical pages and not in kmalloc, but
that will be implemented later :)
2023-07-10 14:09:35 +03:00
Bananymous
74fc0aa308 Kernel: Inode::create_file() now takes uid and gid as parameters 2023-07-10 13:32:10 +03:00
Bananymous
d5f0448e48 Kernel: start work on ram file system 2023-07-10 13:26:14 +03:00
Bananymous
d713f252aa Kenrel: Fix inode comparison
We should not compare rdevs
2023-07-10 11:48:11 +03:00
Bananymous
5ec2d85081 Kernel: Inode rename directory functions 2023-07-10 11:48:11 +03:00
Bananymous
0d132ee518 Kernel: Mark Ext2 classes final 2023-07-10 11:48:11 +03:00
Bananymous
4cd72992c8 Kernel/LibC: Add basic pipe() syscall and command
You can now create pipes :)
2023-07-06 22:16:26 +03:00
Bananymous
c7ec19c25c Kernel: Add basic Credentials for the system
Now filesystem access/open, etc confirm that you have access for rwxs
2023-06-11 20:06:06 +03:00
Bananymous
01311b470f Kernel: Rewrite directory listing so it can be integrated to libc 2023-06-11 00:17:18 +03:00
Bananymous
9228df0f23 Kernel: Inode/Device detection is done with overridden bool functions 2023-06-03 13:28:15 +03:00
Bananymous
7bbdee6cc4 Kernel: Symlinks are now working
We still have to implement loop or depth detection
2023-06-02 11:43:46 +03:00