]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/common/utime.c
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / common / utime.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * utime() for uClibc
4  *
5  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
6  *
7  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8  */
9
10 #include <sys/syscall.h>
11 #include <utime.h>
12
13 #if defined __NR_utimensat && !defined __NR_utime
14 # include <fcntl.h>
15 # include <stddef.h>
16
17 int utime(const char *file, const struct utimbuf *times)
18 {
19         struct timespec tspecs[2], *ts;
20
21         if (times) {
22                 ts = tspecs;
23                 ts[0].tv_sec = times->actime;
24                 ts[0].tv_nsec = 0;
25                 ts[1].tv_sec = times->modtime;
26                 ts[1].tv_nsec = 0;
27         } else {
28                 ts = NULL;
29         }
30
31         return utimensat(AT_FDCWD, file, ts, 0);
32 }
33
34 #elif defined(__NR_utime)
35 _syscall2(int, utime, const char *, file, const struct utimbuf *, times)
36 #elif defined __NR_utimes /* alpha || ia64 */
37 # define __need_NULL
38 # include <stddef.h>
39 # include <sys/time.h>
40
41 int utime(const char *file, const struct utimbuf *times)
42 {
43         struct timeval timevals[2];
44
45         if (times != NULL) {
46                 timevals[0].tv_usec = 0L;
47                 timevals[1].tv_usec = 0L;
48                 timevals[0].tv_sec = (time_t) times->actime;
49                 timevals[1].tv_sec = (time_t) times->modtime;
50         }
51         return utimes(file, times ? timevals : NULL);
52 }
53 #endif
54
55 #if (defined __NR_utimensat && !defined __NR_utime) || \
56         defined __NR_utime || defined __NR_utimes
57 link_warning(utime, "the use of OBSOLESCENT `utime' is discouraged, use `utimes'")
58 libc_hidden_def(utime)
59 #endif