1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 08:35:09 +00:00

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.
This commit is contained in:
Andreas Kling 2019-02-21 13:26:40 +01:00
parent b6115ee5b7
commit 7d288aafb2
13 changed files with 138 additions and 93 deletions

View file

@ -1143,9 +1143,11 @@ int Process::sys$utime(const char* pathname, const utimbuf* buf)
mtime = now;
atime = now;
}
inode.set_atime(atime);
inode.set_mtime(mtime);
return 0;
error = inode.set_atime(atime);
if (error)
return error;
error = inode.set_mtime(mtime);
return error;
}
int Process::sys$access(const char* pathname, int mode)
@ -2099,6 +2101,18 @@ Inode* Process::cwd_inode()
return m_cwd.ptr();
}
int Process::sys$link(const char* old_path, const char* new_path)
{
if (!validate_read_str(old_path))
return -EFAULT;
if (!validate_read_str(new_path))
return -EFAULT;
int error;
if (!VFS::the().link(String(old_path), String(new_path), *cwd_inode(), error))
return error;
return 0;
}
int Process::sys$unlink(const char* pathname)
{
if (!validate_read_str(pathname))