mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:37:35 +00:00
Add unlink() syscall and /bin/rm.
This patch adds most of the plumbing for working file deletion in Ext2FS. Directory entries are removed and inode link counts updated. We don't yet update the inode or block bitmaps, I will do that separately.
This commit is contained in:
parent
2f2f28f212
commit
bda0c935c2
16 changed files with 142 additions and 6 deletions
|
@ -2009,3 +2009,13 @@ Inode* Process::cwd_inode()
|
|||
m_cwd = VFS::the().root_inode();
|
||||
return m_cwd.ptr();
|
||||
}
|
||||
|
||||
int Process::sys$unlink(const char* pathname)
|
||||
{
|
||||
if (!validate_read_str(pathname))
|
||||
return -EFAULT;
|
||||
int error;
|
||||
if (!VFS::the().unlink(String(pathname), *cwd_inode(), error))
|
||||
return error;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -191,6 +191,7 @@ public:
|
|||
int sys$mkdir(const char* pathname, mode_t mode);
|
||||
Unix::clock_t sys$times(Unix::tms*);
|
||||
int sys$utime(const char* pathname, const struct Unix::utimbuf*);
|
||||
int sys$unlink(const char* pathname);
|
||||
|
||||
int gui$create_window(const GUI_WindowParameters*);
|
||||
int gui$destroy_window(int window_id);
|
||||
|
|
|
@ -191,6 +191,8 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
|
|||
return current->sys$utime((const char*)arg1, (const Unix::utimbuf*)arg2);
|
||||
case Syscall::SC_sync:
|
||||
return sync();
|
||||
case Syscall::SC_unlink:
|
||||
return current->sys$unlink((const char*)arg1);
|
||||
case Syscall::SC_gui_create_window:
|
||||
return current->gui$create_window((const GUI_WindowParameters*)arg1);
|
||||
case Syscall::SC_gui_destroy_window:
|
||||
|
|
|
@ -74,6 +74,7 @@
|
|||
__ENUMERATE_SYSCALL(select) \
|
||||
__ENUMERATE_SYSCALL(gui_get_window_parameters) \
|
||||
__ENUMERATE_SYSCALL(gui_set_window_parameters) \
|
||||
__ENUMERATE_SYSCALL(unlink) \
|
||||
|
||||
|
||||
struct fd_set;
|
||||
|
|
|
@ -42,6 +42,7 @@ cp -v ../Userland/mkdir mnt/bin/mkdir
|
|||
cp -v ../Userland/touch mnt/bin/touch
|
||||
cp -v ../Userland/sync mnt/bin/sync
|
||||
cp -v ../Userland/more mnt/bin/more
|
||||
cp -v ../Userland/rm mnt/bin/rm
|
||||
cp -v ../Userland/guitest mnt/bin/guitest
|
||||
cp -v ../Userland/guitest2 mnt/bin/guitest2
|
||||
cp -v ../Userland/sysctl mnt/bin/sysctl
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue