Commit Graph

529 Commits

Author SHA1 Message Date
Florian Fischer b149807ccc support and use the new uid syscalls from userspace 2024-02-29 17:55:48 +01:00
Florian Fischer 43c5bbaaff exec: support SUID and SGID bits 2024-02-29 17:55:48 +01:00
Florian Fischer 9f0d8eca0d implement effective and real user and group id separation
New syscalls:
  * geteuid
  * setreuid
  * getegid
  * setregid
2024-02-29 17:55:48 +01:00
Florian Fischer 9de28df51a stddef: make uid_t and gid_t signed
POSIX describes uid_t and gid_t as SIGNED integer types.
They need to be able to store -1 for various syscalls.
2024-02-29 17:55:47 +01:00
Florian Fischer 58ceead501 add simple id implementation 2024-02-29 17:55:47 +01:00
Enrico Fraccaroli (Galfurian) 7b6076b612 Add an explanation for the swap macro. 2024-02-29 11:07:55 -05:00
Enrico Fraccaroli (Galfurian) d213276817 Add missing comment for the offset argument of tokenize. Add error checko on the offset. 2024-02-29 11:06:04 -05:00
Enrico Fraccaroli (Galfurian) ed7454f1e0 Translate italian text to english. 2024-02-29 11:04:47 -05:00
Enrico Fraccaroli 806664f61c Merge pull request #32 from fischerling/stopcont-test
remove infinite loop in t_stopcont
2024-02-29 11:03:43 -05:00
Enrico Fraccaroli 8852d09693 Merge pull request #31 from fischerling/test-semflg-test
fix t_semflg test
2024-02-29 10:59:41 -05:00
Enrico Fraccaroli 8262982e87 Merge pull request #30 from fischerling/cleanup-tests
Some miscellaneous cleanups for the included tests
2024-02-29 10:56:34 -05:00
Enrico Fraccaroli fbff702922 Merge pull request #29 from fischerling/add-utils
Add false and stat util
2024-02-29 10:50:14 -05:00
Enrico Fraccaroli cd60f1602e Merge pull request #28 from fischerling/improve-syscall-doc
doc: update the implemented syscalls
2024-02-29 10:46:22 -05:00
Enrico Fraccaroli 354470b85b Merge pull request #27 from fischerling/add-german-keymap
add german keymap
2024-02-29 10:44:40 -05:00
Florian Fischer 43054529d5 add creat test
Tesing commit f7e53f9b00.
2024-02-29 16:12:09 +01:00
Florian Fischer fe4c4e337e remove infinite loop in t_stopcont
Remove useless preprocessor define.

Terminate the child after 15 seconds.

Since the parent is waiting for the child to terminate it is still
guaranteed that the child was continued.
2024-02-29 16:09:39 +01:00
Florian Fischer 63b8d9420a fix t_semflg test
Remove the double semaphore cleanup in the child and the parent.

Set nops to 1 since there is only one operation not two.

Use a blocking semaphore operation in the parent to wait for the
child increasing the semaphore value.
2024-02-29 16:07:50 +01:00
Florian Fischer 7b54ff8d2a tests: exit with 0 when the test succeeds. 2024-02-29 16:05:11 +01:00
Florian Fischer 65393843a5 tests: use files that actually exist
Commit af79958f1a removed
a lot of files including /home/user/test7.txt used in some tests.

Replace /home/user/test7.txt with /README.
2024-02-29 16:04:56 +01:00
Florian Fischer afa3d4fb66 tests: remove the not used t_exec_callee 2024-02-29 16:04:49 +01:00
Florian Fischer f124be1cf7 tests: add simple test for small consecutive writes
This test was written for: 4d4504486d.
2024-02-29 16:04:37 +01:00
Florian Fischer 88b1846a43 tests: fix paths to the other periodic tests 2024-02-29 15:58:48 +01:00
Florian Fischer 8e1696d701 add simple stat.1 implementation 2024-02-29 15:52:49 +01:00
Florian Fischer ebd07576fa programs: add simple false program 2024-02-29 15:52:34 +01:00
Florian Fischer ce99aff26b doc: update the implemented syscalls
Fix the listed source files for implemented syscalls and remove
the files for not implemented ones.
2024-02-29 15:48:27 +01:00
Florian Fischer 5b4c3bb0f4 add german keymap 2024-02-29 15:44:31 +01:00
Enrico Fraccaroli (Galfurian) 53d1e8ad68 Set the size of every new directory to the block_size 2024-02-28 12:14:54 -05:00
Enrico Fraccaroli (Galfurian) ed50926b46 Remove ext2_write_inode call from ext2_write_inode_block, because is already called by ext2_allocate_inode_block internally on success. 2024-02-28 12:13:35 -05:00
Enrico Fraccaroli (Galfurian) bc0c921316 Merge branch 'master' into develop 2024-02-28 12:10:37 -05:00
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 (Galfurian) 189f2ceb77 Merge branch 'master' into develop 2024-02-26 10:03:44 -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 e31e40ba2e Merge branch 'master' into develop 2024-01-25 16:03:26 +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