Skip to content

Commit

Permalink
Implement utime
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Jul 8, 2019
1 parent 6ae1e86 commit 95cee3f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions kernel/calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ syscall_t syscall_table[] = {
[25] = (syscall_t) sys_stime,
[27] = (syscall_t) sys_alarm,
[29] = (syscall_t) sys_pause,
[30] = (syscall_t) sys_utime,
[33] = (syscall_t) sys_access,
[36] = (syscall_t) syscall_success_stub, // sync
[37] = (syscall_t) sys_kill,
Expand Down
3 changes: 2 additions & 1 deletion kernel/calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ dword_t sys_ftruncate64(fd_t f, dword_t size_low, dword_t size_high);
dword_t sys_fallocate(fd_t f, dword_t mode, dword_t offset_low, dword_t offset_high, dword_t len_low, dword_t len_high);
dword_t sys_mkdir(addr_t path_addr, mode_t_ mode);
dword_t sys_mkdirat(fd_t at_f, addr_t path_addr, mode_t_ mode);
dword_t sys_utimes(addr_t path_addr, addr_t times_addr);
dword_t sys_utimensat(fd_t at_f, addr_t path_addr, addr_t times_addr, dword_t flags);
dword_t sys_utimes(addr_t path_addr, addr_t times_addr);
dword_t sys_utime(addr_t path_addr, addr_t times_addr);
dword_t sys_times( addr_t tbuf);
dword_t sys_umask(dword_t mask);

Expand Down
20 changes: 20 additions & 0 deletions kernel/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,26 @@ dword_t sys_utimes(addr_t path_addr, addr_t times_addr) {
return sys_utime_common(AT_FDCWD_, path_addr, atime, mtime, 0);
}

dword_t sys_utime(addr_t path_addr, addr_t times_addr) {
struct timespec atime;
struct timespec mtime;
if (times_addr == 0) {
atime = mtime = timespec_now();
} else {
struct utimbuf_ {
time_t_ actime;
time_t_ modtime;
} times;
if (user_get(times_addr, times))
return _EFAULT;
atime.tv_sec = times.actime;
atime.tv_nsec = 0;
mtime.tv_sec = times.modtime;
mtime.tv_nsec = 0;
}
return sys_utime_common(AT_FDCWD_, path_addr, atime, mtime, 0);
}

dword_t sys_fchmod(fd_t f, dword_t mode) {
struct fd *fd = f_get(f);
if (fd == NULL)
Expand Down
1 change: 1 addition & 0 deletions misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ typedef sdword_t pid_t_;
typedef dword_t uid_t_;
typedef word_t mode_t_;
typedef sqword_t off_t_;
typedef dword_t time_t_;
typedef dword_t clock_t_;

#define uint(size) glue3(uint,size,_t)
Expand Down

0 comments on commit 95cee3f

Please sign in to comment.