diff --git a/src/kernel/libroot/posix/Jamfile b/src/kernel/libroot/posix/Jamfile index a1a9a9b196..e64598bf65 100644 --- a/src/kernel/libroot/posix/Jamfile +++ b/src/kernel/libroot/posix/Jamfile @@ -8,6 +8,7 @@ KernelMergeObject posix_main.o : <$(SOURCE_GRIST)>poll.c <$(SOURCE_GRIST)>pwd.c <$(SOURCE_GRIST)>rlimit.c + <$(SOURCE_GRIST)>utime.c : -fPIC -DPIC ; @@ -15,6 +16,7 @@ KernelMergeObject posix_main.o : MergeObjectFromObjects kernel_posix_main.o : <$(SOURCE_GRIST)>errno.o <$(SOURCE_GRIST)>poll.o + <$(SOURCE_GRIST)>utime.o ; SubInclude OBOS_TOP src kernel libroot posix malloc ; diff --git a/src/kernel/libroot/posix/utime.c b/src/kernel/libroot/posix/utime.c new file mode 100644 index 0000000000..f0ffcd74fe --- /dev/null +++ b/src/kernel/libroot/posix/utime.c @@ -0,0 +1,32 @@ +/* +** Copyright 2002, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ + + +#include +#include +#include + + +#define RETURN_AND_SET_ERRNO(err) \ + if (err < 0) { \ + errno = err; \ + return -1; \ + } \ + return err; + + +int +utime(const char *path, const struct utimbuf *buffer) +{ + struct stat stat; + status_t status; + + stat.st_atime = buffer->actime; + stat.st_mtime = buffer->modtime; + status = sys_write_path_stat(path, false, &stat, FS_WRITE_STAT_MTIME | FS_WRITE_STAT_ATIME); + + RETURN_AND_SET_ERRNO(status); +} +