summaryrefslogtreecommitdiff
path: root/Kernel/Process.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-12-19 21:14:55 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-12-19 21:14:55 +0100
commit038d8641f9394aa587c0fa06878b6798a80dbcda (patch)
treeab29b5465d3db41e21e8470915d82fdb24f9fea3 /Kernel/Process.cpp
parente03d341615119788037f9e50c9043a30a2449894 (diff)
downloadserenity-038d8641f9394aa587c0fa06878b6798a80dbcda.zip
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.
Diffstat (limited to 'Kernel/Process.cpp')
-rw-r--r--Kernel/Process.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 1a92f1ea7c..3e1048e9be 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -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;