mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:07:36 +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:
parent
e03d341615
commit
038d8641f9
22 changed files with 122 additions and 22 deletions
|
@ -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;
|
||||
|
|
|
@ -173,6 +173,7 @@ public:
|
|||
int sys$ioctl(int fd, unsigned request, unsigned arg);
|
||||
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*);
|
||||
|
||||
static void initialize();
|
||||
|
||||
|
|
|
@ -177,6 +177,8 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
|
|||
return current->sys$mkdir((const char*)arg1, (mode_t)arg2);
|
||||
case Syscall::SC_times:
|
||||
return current->sys$times((Unix::tms*)arg1);
|
||||
case Syscall::SC_utime:
|
||||
return current->sys$utime((const char*)arg1, (const Unix::utimbuf*)arg2);
|
||||
default:
|
||||
kprintf("<%u> int0x80: Unknown function %u requested {%x, %x, %x}\n", current->pid(), function, arg1, arg2, arg3);
|
||||
break;
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
__ENUMERATE_SYSCALL(ioctl) \
|
||||
__ENUMERATE_SYSCALL(mkdir) \
|
||||
__ENUMERATE_SYSCALL(times) \
|
||||
__ENUMERATE_SYSCALL(utime) \
|
||||
|
||||
|
||||
#define DO_SYSCALL_A0(function) Syscall::invoke((dword)(function))
|
||||
|
|
|
@ -30,6 +30,7 @@ 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
|
||||
sh sync-local.sh
|
||||
cp -v kernel.map mnt/
|
||||
ln -s dir_a mnt/dir_cur
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue