diff options
author | Ron Yorston <rmy@pobox.com> | 2023-07-16 08:49:50 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-07-16 08:49:50 +0100 |
commit | bc0d14ee8eb9720a5df097f5620c4b4c679b6c98 (patch) | |
tree | 8aaac80f79822ac2f590854dfecc4af91c0cedd4 /win32/mingw.c | |
parent | 51ba60c766e010f67dd410ad31a2c4814a8440e4 (diff) | |
download | busybox-w32-bc0d14ee8eb9720a5df097f5620c4b4c679b6c98.tar.gz busybox-w32-bc0d14ee8eb9720a5df097f5620c4b4c679b6c98.tar.bz2 busybox-w32-bc0d14ee8eb9720a5df097f5620c4b4c679b6c98.zip |
date: allow system date to be set
Implement clock_settime(2) and enable the '-s' option to allow
the system time to be set. This requires elevated privileges.
The code in date.c is now identical to upstream BusyBox.
Costs 256-272 bytes.
Diffstat (limited to 'win32/mingw.c')
-rw-r--r-- | win32/mingw.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index 86dc75861..5e9c71226 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -1008,6 +1008,29 @@ int clock_gettime(clockid_t clockid, struct timespec *tp) | |||
1008 | return 0; | 1008 | return 0; |
1009 | } | 1009 | } |
1010 | 1010 | ||
1011 | int clock_settime(clockid_t clockid, const struct timespec *tp) | ||
1012 | { | ||
1013 | SYSTEMTIME st; | ||
1014 | FILETIME ft; | ||
1015 | |||
1016 | if (clockid != CLOCK_REALTIME) { | ||
1017 | errno = ENOSYS; | ||
1018 | return -1; | ||
1019 | } | ||
1020 | |||
1021 | timespec_to_filetime(*tp, &ft); | ||
1022 | if (FileTimeToSystemTime(&ft, &st) == 0) { | ||
1023 | errno = EINVAL; | ||
1024 | return -1; | ||
1025 | } | ||
1026 | |||
1027 | if (SetSystemTime(&st) == 0) { | ||
1028 | errno = EPERM; | ||
1029 | return -1; | ||
1030 | } | ||
1031 | return 0; | ||
1032 | } | ||
1033 | |||
1011 | int pipe(int filedes[2]) | 1034 | int pipe(int filedes[2]) |
1012 | { | 1035 | { |
1013 | if (_pipe(filedes, PIPE_BUF, 0) < 0) | 1036 | if (_pipe(filedes, PIPE_BUF, 0) < 0) |