From 8642946bd00e0c6dff9f08d84a63d32ce6648538 Mon Sep 17 00:00:00 2001 From: Vladimir Zapolskiy Date: Wed, 2 Jun 2010 10:27:16 +0400 Subject: lutimes: add lutimes support This patch adds lutimes library call support. Signed-off-by: Vladimir Zapolskiy Signed-off-by: Bernhard Reutner-Fischer --- libc/sysdeps/linux/common/lutimes.c | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 libc/sysdeps/linux/common/lutimes.c (limited to 'libc/sysdeps/linux/common/lutimes.c') diff --git a/libc/sysdeps/linux/common/lutimes.c b/libc/sysdeps/linux/common/lutimes.c new file mode 100644 index 000000000..0b4a8ea45 --- /dev/null +++ b/libc/sysdeps/linux/common/lutimes.c @@ -0,0 +1,38 @@ +/* vi: set sw=4 ts=4: */ +/* + * lutimes() implementation for uClibc + * + * Copyright (C) 2010 Vladimir Zapolskiy + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include +#include + +#ifdef __NR_lutimes +_syscall2(int, lutimes, const char *, file, const struct timeval *, tvp) +#else +#include +#include + +int lutimes(const char *file, const struct timeval tvp[2]) +{ + struct timespec ts[2]; + + if (tvp != NULL) + { + if (tvp[0].tv_usec < 0 || tvp[0].tv_usec >= 1000000 + || tvp[1].tv_usec < 0 || tvp[1].tv_usec >= 1000000) + { + __set_errno(EINVAL); + return -1; + } + + TIMEVAL_TO_TIMESPEC(&tvp[0], &ts[0]); + TIMEVAL_TO_TIMESPEC(&tvp[1], &ts[1]); + } + + return utimensat(AT_FDCWD, file, tvp ? ts : NULL, AT_SYMLINK_NOFOLLOW); +} +#endif -- cgit v1.2.3