1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 21:58:10 +00:00

Implement utime() along with a naive /bin/touch.

This synchronous approach to inodes is silly, obviously. I need to rework
it so that the in-memory CoreInode object is the canonical inode, and then
we just need a sync() that flushes pending changes to disk.
This commit is contained in:
Andreas Kling 2018-12-19 21:14:55 +01:00
parent e03d341615
commit 038d8641f9
22 changed files with 122 additions and 22 deletions

View file

@ -1079,6 +1079,30 @@ int Process::sys$close(int fd)
return rc;
}
int Process::sys$utime(const char* pathname, const Unix::utimbuf* buf)
{
if (!validate_read_str(pathname))
return -EFAULT;
if (buf && !validate_read_typed(buf))
return -EFAULT;
String path(pathname);
int error;
auto descriptor = VFS::the().open(move(path), error, 0, cwd_inode()->identifier());
if (!descriptor)
return error;
Unix::time_t atime;
Unix::time_t mtime;
if (buf) {
atime = buf->actime;
mtime = buf->modtime;
} else {
auto now = RTC::now();
mtime = now;
atime = now;
}
return descriptor->set_atime_and_mtime(atime, mtime);
}
int Process::sys$access(const char* pathname, int mode)
{
(void) mode;