1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:57:44 +00:00

Add sync() syscall and a /bin/sync.

It walks all the live Inode objects and flushes pending metadata changes
wherever needed.

This could be optimized by keeping a separate list of dirty Inodes,
but let's not get ahead of ourselves.
This commit is contained in:
Andreas Kling 2018-12-20 00:39:29 +01:00
parent d0f06e5f3f
commit ed7ae6c02c
14 changed files with 78 additions and 24 deletions

View file

@ -1105,7 +1105,6 @@ int Process::sys$utime(const char* pathname, const Unix::utimbuf* buf)
}
inode.set_atime(atime);
inode.set_mtime(mtime);
inode.flush_metadata();
return 0;
}

View file

@ -44,6 +44,12 @@ void initialize()
kprintf("syscall: int 0x80 handler installed\n");
}
static int sync()
{
VFS::the().sync();
return 0;
}
static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2, dword arg3)
{
ASSERT_INTERRUPTS_ENABLED();
@ -179,6 +185,8 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
return current->sys$times((Unix::tms*)arg1);
case Syscall::SC_utime:
return current->sys$utime((const char*)arg1, (const Unix::utimbuf*)arg2);
case Syscall::SC_sync:
return sync();
default:
kprintf("<%u> int0x80: Unknown function %u requested {%x, %x, %x}\n", current->pid(), function, arg1, arg2, arg3);
break;

View file

@ -65,6 +65,7 @@
__ENUMERATE_SYSCALL(mkdir) \
__ENUMERATE_SYSCALL(times) \
__ENUMERATE_SYSCALL(utime) \
__ENUMERATE_SYSCALL(sync) \
#define DO_SYSCALL_A0(function) Syscall::invoke((dword)(function))

View file

@ -23,14 +23,13 @@ cp -v ../Userland/cat mnt/bin/cat
cp -v ../Userland/uname mnt/bin/uname
cp -v ../Userland/clear mnt/bin/clear
cp -v ../Userland/tst mnt/bin/tst
cp -v ../Userland/ft mnt/bin/ft
cp -v ../Userland/ft2 mnt/bin/ft2
cp -v ../Userland/mm mnt/bin/mm
cp -v ../Userland/kill mnt/bin/kill
cp -v ../Userland/tty mnt/bin/tty
cp -v ../Userland/strsignal mnt/bin/strsignal
cp -v ../Userland/mkdir mnt/bin/mkdir
cp -v ../Userland/touch mnt/bin/touch
cp -v ../Userland/sync mnt/bin/sync
sh sync-local.sh
cp -v kernel.map mnt/
ln -s dir_a mnt/dir_cur