etc/services - sync with NetBSD-8
[minix.git] / minix / lib / libc / sys / lutimes.c
blob9fcf0857dfcc00f6503ff3ff95896ddbb21e6da9
1 #include <sys/cdefs.h>
2 #include "namespace.h"
3 #include <lib.h>
5 #include <sys/stat.h>
6 #include <sys/time.h>
7 #include <fcntl.h>
8 #include <string.h>
9 #include <errno.h>
11 #ifdef __weak_alias
12 __weak_alias(lutimes, __lutimes50)
13 #endif
15 int lutimes(const char *name, const struct timeval tv[2])
17 message m;
19 if (name == NULL) {
20 errno = EINVAL;
21 return -1;
23 if (name[0] == '\0') { /* X/Open requirement */
24 errno = ENOENT;
25 return -1;
27 memset(&m, 0, sizeof(m));
28 m.m_vfs_utimens.len = strlen(name) + 1;
29 m.m_vfs_utimens.name = (char *) __UNCONST(name);
30 if (tv == NULL) {
31 m.m_vfs_utimens.atime = m.m_vfs_utimens.mtime = 0;
32 m.m_vfs_utimens.ansec = m.m_vfs_utimens.mnsec = UTIME_NOW;
34 else {
35 m.m_vfs_utimens.atime = tv[0].tv_sec;
36 m.m_vfs_utimens.mtime = tv[1].tv_sec;
37 m.m_vfs_utimens.ansec = tv[0].tv_usec * 1000;
38 m.m_vfs_utimens.mnsec = tv[1].tv_usec * 1000;
40 m.m_vfs_utimens.flags = AT_SYMLINK_NOFOLLOW;
42 return(_syscall(VFS_PROC_NR, VFS_UTIMENS, &m));