Commit Graph

27 Commits

Author SHA1 Message Date
Andreas Kling
e56fe71dbc Kernel: And some more KResult/KResultOr<T> porting work. 2019-03-06 22:30:13 +01:00
Andreas Kling
028afabf6b Kernel: Port more code to KResult and KResultOr<T>. 2019-03-06 22:14:31 +01:00
Andreas Kling
2c5a378ccc Kernel+Userland: Add symlink() syscall and add "-s" flag to /bin/ln.
It's now possible to create symbolic links! :^)

This exposed an issue in Ext2FS where we'd write uninitialized data past
the end of an inode's content. Fix this by zeroing out the tail end of
the last block in a file.
2019-03-02 01:52:24 +01:00
Andreas Kling
37f6844c6c Kernel: Port stat() to KResult/KResultOr<T>. 2019-03-02 00:11:27 +01:00
Andreas Kling
f75eb9af16 Kernel: Support chdir() to a directory that's executable but not readable.
Also the superuser should be allowed to resolve any possible path without
getting tripped up by EACCES.
2019-03-01 23:54:07 +01:00
Andreas Kling
1b16a29044 Kernel+Userland: Implement fchmod() syscall and use it to improve /bin/cp.
/bin/cp will now copy the permission bits from source to destination. :^)
2019-03-01 10:39:19 +01:00
Andreas Kling
60d0a48be5 Kernel: Use KResult in link(). 2019-02-27 15:31:26 +01:00
Andreas Kling
5b27f11b97 Kernel: Use KResult in unlink() and rmdir(). 2019-02-27 14:11:25 +01:00
Andreas Kling
1d2529b4a1 Add chown() syscall and a simple /bin/chown program. 2019-02-27 12:32:53 +01:00
Andreas Kling
a356746d04 Compat work towards porting vim. 2019-02-26 15:57:59 +01:00
Andreas Kling
5af4e622b9 Kernel: Add KResult and KResultOr<T> classes.
The idea here is to combine a potential syscall error code with an arbitrary
type in the case of success. I feel like this will end up much less error
prone than returning some arbitrary type that kinda sorta has bool semantics
(but sometimes not really) and passing the error through an out-param.

This patch only converts a few syscalls to using it. More to come.
2019-02-25 20:50:22 +01:00
Andreas Kling
a624fe06b8 Kernel: Add file permission checks to utime() syscall. 2019-02-21 16:37:41 +01:00
Andreas Kling
ce3b548077 Kernel: Separate VFS stat() from open().
It was very confusing that you had to open a FileDescriptor in order to stat
a file. This patch gives VFS a separate stat() function and uses it to
implement the stat() and lstat() syscalls.
2019-02-21 16:09:12 +01:00
Andreas Kling
7d288aafb2 Kernel: Add link() syscall to create hard links.
This accidentally grew into a little bit of VFS cleanup as well.

Also add a simple /bin/ln implementation to exercise it.
2019-02-21 13:26:40 +01:00
Andreas Kling
994279d56c Kernel: Add Device base class for CharacterDevice.
..to prepare for adding a BlockDevice class.
2019-02-16 00:47:20 +01:00
Andreas Kling
022f7790db Use modern C++ attributes instead of __attribute__ voodoo.
This is quite nice, although I wish [[gnu::always_inline]] implied inline.
Also "gnu::" is kind of a wart, but whatcha gonna do.
2019-02-15 12:30:48 +01:00
Andreas Kling
a1b63bb6d4 Bootloader: Locate the kernel's data segment and clear it.
This was a constant source of stupid bugs and I kept postponing it because
I wasn't in the mood to write assembly code. Until now! :^)
2019-02-06 16:02:10 +01:00
Andreas Kling
feed67ede2 Kernel: VFS::open/create should take base Inode& instead of InodeIdentifier. 2019-02-01 15:36:45 +01:00
Andreas Kling
6618411fba Kernel: mkdir() should use the containing directory's FS for inode creation. 2019-02-01 15:29:11 +01:00
Andreas Kling
ffab6897aa Big, possibly complete sweep of naming changes. 2019-01-31 17:31:23 +01:00
Andreas Kling
fc0b63ca3c Kernel: Include absolute paths of mount points in /proc/mounts 2019-01-31 06:13:55 +01:00
Andreas Kling
34e745b0b4 Add uid and gid to CharacterDevices.
The vast majority of them will be owned by 0:0 (the default.)
However, PTY pairs will now be owned by the uid:gid of the opening process.
2019-01-31 05:55:30 +01:00
Andreas Kling
c4fce9b3f9 Make stat() work on device files again.
FileDescriptor will now keep a pointer to the original inode even after
opening it resolves to a character device.

Fixed up /bin/ls to display major and minor device numbers instead of size
for device files.
2019-01-31 05:05:57 +01:00
Andreas Kling
b4e478aa50 Deallocate PTY's when they close.
This required a fair bit of plumbing. The CharacterDevice::close() virtual
will now be closed by ~FileDescriptor(), allowing device implementations to
do custom cleanup at that point.

One big problem remains: if the master PTY is closed before the slave PTY,
we go into crashy land.
2019-01-30 18:47:18 +01:00
Andreas Kling
c30e2c8d44 Implement basic chmod() syscall and /bin/chmod helper.
Only raw octal modes are supported right now.
This patch also changes mode_t from 32-bit to 16-bit to match the on-disk
type used by Ext2FS.

I also ran into EPERM being errno=0 which was confusing, so I inserted an
ESUCCESS in its place.
2019-01-29 04:55:08 +01:00
Andreas Kling
c95228b128 Add support for removing directories.
It's really only supported in Ext2FS since SynthFS doesn't really want you
mucking around with its files. This is pretty neat though :^)

I ran into some trouble with HashMap while working on this but opted to work
around it and leave that for a separate investigation.
2019-01-28 04:16:01 +01:00
Andreas Kling
754037874c Move VFS sources into Kernel/. 2019-01-23 05:14:00 +01:00