From 0dd93a6eb7fd0e546ed9a0bdd6e72a12c27c7001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 15 Nov 2002 22:44:08 +0000 Subject: [PATCH] Implemented utime(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1952 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/posix/Jamfile | 2 ++ src/kernel/libroot/posix/utime.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/kernel/libroot/posix/utime.c 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); +} +