Kernel/LibC: Implement utime* family functions
This patch adds *working* - utime - utimes - utimensat - futimens
This commit is contained in:
@@ -53,3 +53,13 @@ int mkdir(const char* path, mode_t mode)
|
||||
{
|
||||
return syscall(SYS_CREATE_DIR, path, __UMASKED_MODE(mode));
|
||||
}
|
||||
|
||||
int futimens(int fd, const struct timespec times[2])
|
||||
{
|
||||
return utimensat(fd, nullptr, times, 0);
|
||||
}
|
||||
|
||||
int utimensat(int fd, const char* path, const struct timespec times[2], int flag)
|
||||
{
|
||||
return syscall(SYS_UTIMENSAT, fd, path, times, flag);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
@@ -26,3 +27,20 @@ int setitimer(int which, const struct itimerval* __restrict value, struct itimer
|
||||
{
|
||||
return syscall(SYS_SETITIMER, which, value, ovalue);
|
||||
}
|
||||
|
||||
int utimes(const char* path, const struct timeval times[2])
|
||||
{
|
||||
if (times == nullptr)
|
||||
return utimensat(AT_FDCWD, path, nullptr, 0);
|
||||
const timespec times_ts[2] {
|
||||
timespec {
|
||||
.tv_sec = times[0].tv_sec,
|
||||
.tv_nsec = times[0].tv_usec * 1000,
|
||||
},
|
||||
timespec {
|
||||
.tv_sec = times[1].tv_sec,
|
||||
.tv_nsec = times[1].tv_usec * 1000,
|
||||
},
|
||||
};
|
||||
return utimensat(AT_FDCWD, path, times_ts, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user