497 Commits

Author SHA1 Message Date
Enrico Fraccaroli ee2f95e51d Merge pull request #26 from fischerling/fix-ext2-write
Fix some regressions in ext2_write
2024-02-28 12:09:56 -05:00
Enrico Fraccaroli b617fccee4 Merge pull request #25 from fischerling/improve-text-printing
Improve text printing
2024-02-26 10:02:01 -05:00
Enrico Fraccaroli 14474130ad Merge pull request #24 from fischerling/improve-ls-long-output
ls: improve --long output format
2024-02-26 10:00:24 -05:00
Enrico Fraccaroli 18504170ec Merge pull request #23 from fischerling/add-some-man-pages
add simple manual pages for rmdir, mkdir, showpid
2024-02-26 09:59:16 -05:00
Enrico Fraccaroli 404f4c20f0 Merge pull request #22 from fischerling/fix-execvp
libc: prevent execvp to search for files containing '/'
2024-02-26 09:57:46 -05:00
Florian Fischer dea54c7dae libc: prevent execvpe to search for files containing '/'
The current implementation always searches for the file in PATH
if it is not an absolute path.
This prevents executing relative paths like ./executable.

As specified by exec(3) the p-family of exec functions only search if
the filename does not contain slash '/' characters.
2024-02-14 11:37:06 +01:00
Florian Fischer 44b1acf33c ext2: update the vfs_file_t length after writing
The vfs_file_t->length field is initialized but never used afterwards.
It seams correct to updated it after the inode size possibly changed.
2024-02-13 21:59:57 +01:00
Florian Fischer 4d4504486d ext2: write the inode back if its size is updated
If there is enough space in an inode but the file grows the
inode is never written back to the device and thus the new size is
not persisted.

	int fd = creat("foo", 660);
	write(fd, "foo", 3); // New blocks are allocated and inode written back
	write(fd, "\n", 1); // size is adapted but not written back
	close(fd);
	// Reading the file afterwards will only return "foo".

The code snippet reproduces the bug.

This is fixed by always writing the inode back to the device if
the size is updated.
2024-02-13 21:59:57 +01:00
Florian Fischer f7e53f9b00 ext2: do not update inode size when allocating new blocks
New blocks for an inode are allocated when data blocks
should be written and not enough blocks are allocated yet
or during allocating new direntries in ext2_allocate_direntry.

When writing the first time to a newly created file (inode.size==0),
new blocks must be allocated and the inode size is erroneously set to
(blocks_count / fs->blocks_per_block_count) * fs->block_size
regardless of the actually written data.

	int fd = creat("foo", 0660);
	write(fd, "foo", 3);

This code snippet will create a new inode with size 4096 instead
of the correct size 3.

ext2_write_inode_data will correctly set the size to 3.
However, ext2_allocate_block called by ext2_write_inode_block will
set the inode size to 4096.

This is fixed by removing the size update during ext2_allocate_block.
2024-02-13 21:51:04 +01:00
Florian Fischer beacbde52e man: use cat as pager to print man pages
This reduces the required code in man and additionally,
replaces the old broken read/puts implementation.

Puts expects a null-terminated string, but write does not return
a null-terminted string.
2024-02-13 13:15:58 +01:00
Florian Fischer cad4804a95 cat: improve exist status
Exit with status 1 if one or more arguments could not be printed.
2024-02-13 13:15:36 +01:00
Florian Fischer e2e608b073 cat: properly output the read data
Using puts to output data retrieved through write is broken.
Puts expects a null-terminated string, which is not returned by read.
Use write to exactly output the data previously read.
2024-02-13 13:15:29 +01:00
Florian Fischer bb1bca458e ls: improve --long output format
Add padding using zeros instead of whitespace to the date values.
2024-02-13 13:11:03 +01:00
Florian Fischer b489df26ba add simple manual pages for rmdir, mkdir, showpid 2024-02-13 13:10:01 +01:00
Enrico Fraccaroli 1832c77fdb Merge pull request #21 from fischerling/fix-creat-fd-flags
creat: set flags in opened file descriptor
2024-01-29 05:24:58 +01:00
Enrico Fraccaroli ce98a0d3de Merge pull request #20 from fischerling/fix-dir-permission-check
vfs: fix permission check when creating files
2024-01-29 05:24:06 +01:00
Florian Fischer 89e6d75627 creat: set flags in opened file descriptor
creat.2 is supposed to be equivalent to open.2 with the
flags O_WRONLY|O_CREAT|O_TRUNC.

However, in MentOS the fd returned by creat.2 has no flags whatsoever
and is thus not writable.

Set the flags of the file descriptor before returning it.
2024-01-28 21:50:30 +01:00
Florian Fischer 4c6cbc3360 vfs: fix permission check when creating files
When creating new files in a directory the creating process
must be allowed to write the directory not to read it.
2024-01-28 21:47:50 +01:00
Enrico Fraccaroli c3c2ba824e Merge pull request #19 from fischerling/fix-grub-entry
Fix grub entry
2024-01-25 16:00:59 +01:00
Florian Fischer 015768793b fix bootloader file name in GRUB config
Fixes: 0b75cd9c
2024-01-24 19:52:16 +01:00
Enrico Fraccaroli (Galfurian) c0254bca6d Merge branch 'release/v0.6.0' v0.6.0 2024-01-17 13:50:06 +01:00
Enrico Fraccaroli (Galfurian) 30e01ba560 Update version 2024-01-17 13:49:48 +01:00
Enrico Fraccaroli (Galfurian) af79958f1a Clean up useless files from the filesystem 2024-01-17 13:38:53 +01:00
Enrico Fraccaroli (Galfurian) eca55dfed8 Clean up cmake files (Part 2)
I've kept just one cmake project, in the root directory. The
subdirectories just set up the targets.

The asm compiler is serached just one time, from the root
directory cmake file.

Global compilation flags are set in the root cmake file, and
each subdirectory cmake file sets specific flags if necessary
(e.g., programs need the -u_start specified)
2024-01-17 13:34:32 +01:00
Enrico Fraccaroli (Galfurian) 0b75cd9c2a Clean up cmake files (Part 1)
I've been cleaning up the way compilation flags are passed to the targets
and there are still some changes that must be made, in the next commit.

I've also done some renaming, all_programs into programs and the same for
tests.

The gdb initialization file now is just one, populated using the find command
and using realpath to get the absolute path to the files. I've tested if the
generated gdb.run file works and it does.
2024-01-17 13:16:50 +01:00
Enrico Fraccaroli 24367a58ae Update readme 2024-01-15 11:58:17 +01:00
Enrico Fraccaroli f40c4a6630 Update readme 2024-01-15 11:45:28 +01:00
Enrico Fraccaroli 7ad283d36a Remove windows github workflow 2024-01-15 11:36:04 +01:00
Enrico Fraccaroli e630f89547 Specify the linker 2024-01-15 11:30:52 +01:00
Enrico Fraccaroli 34eeedcbcf Improve the generation of programs and tests. 2024-01-15 11:26:20 +01:00
Enrico Fraccaroli 90ab346195 Remove github action for MacOs 2024-01-15 11:16:11 +01:00
Enrico Fraccaroli 5ce583fdd8 Rollback patch for archive creation that broke clang compilation 2024-01-15 11:14:34 +01:00
Enrico Fraccaroli c2f660f885 Merge pull request #18 from fischerling/improve-gdb-run
do not append to gdb.run
2024-01-15 11:11:11 +01:00
Enrico Fraccaroli 80af9c93fb Merge pull request #17 from fischerling/develop
Improve process termination
2024-01-15 11:10:52 +01:00
Florian Fischer 8b678be2b7 do not append to gdb.run
Currently each time the target gdbinit is executed a new line
containing 'target remote localhost:1234' will be added to the
gdb.run file.
2024-01-13 14:32:03 +01:00
Florian Fischer ef92ba670b exit: properly set the process' exit code when calling exit()
In order to detect the exit status using
WSTATUSCODE ((status & 0xff00) >> 8) the exit code must
be shifted by 8 to the left.

Separate the kernel process exit logic from the actual system call.
2024-01-13 14:31:00 +01:00
Florian Fischer 6f4d3b57f9 libc: fix waitpid not detecting process termination
Since 452aa40770 and the change to
properly return processes exit codes in the status argument, the
status will never be EXIT_ZOMBIE(16) except a process was terminated by
signal(16).

Return from waitpid if either an error occurred (__res < 0) or
we got the status of a child process (__res == cpid).

Additionally fix the weird alignment of the closing braces.
2024-01-13 14:31:00 +01:00
Enrico Fraccaroli (Galfurian) dd39e93194 Try to fix compilation under MacOS 2023-11-30 13:31:49 -05:00
Enrico Fraccaroli (Galfurian) 275cbbe7b3 Try to fix compilation under MacOS 2023-11-30 13:30:19 -05:00
Enrico Fraccaroli (Galfurian) 290ed59d0b Try to fix compilation under MacOS 2023-11-30 13:28:09 -05:00
Enrico Fraccaroli (Galfurian) 3e51197ae4 Try to fix compilation under MacOS 2023-11-30 13:16:09 -05:00
Enrico Fraccaroli (Galfurian) 3d49f0abf6 Try to fix compilation under MacOS 2023-11-30 13:07:13 -05:00
Enrico Fraccaroli (Galfurian) 391bba92a6 Try to fix compilation under MacOS 2023-11-30 13:04:10 -05:00
Enrico Fraccaroli (Galfurian) e96c13ff70 Try to fix compilation under MacOS 2023-11-30 13:02:55 -05:00
Enrico Fraccaroli (Galfurian) 9ef117cbc6 Try to fix compilation under MacOS 2023-11-30 13:01:56 -05:00
Enrico Fraccaroli (Galfurian) af95af6f3a Try to fix compilation under MacOS 2023-11-30 12:59:03 -05:00
Enrico Fraccaroli (Galfurian) d2fd6654eb Try to fix compilation under MacOS 2023-11-30 12:53:16 -05:00
Enrico Fraccaroli (Galfurian) 3fcc0f8964 Use gcc@11 under MacOS 2023-11-30 11:49:41 -05:00
Enrico Fraccaroli (Galfurian) 327e29791e Use gcc@11 under MacOS 2023-11-30 11:47:15 -05:00
Enrico Fraccaroli (Galfurian) f24b962e2b Use gcc@11 under MacOS 2023-11-30 11:44:42 -05:00