etc/services - sync with NetBSD-8
[minix.git] / minix / lib / libc / sys / utimes.c
blobd3251178fcbd54160a89b3a1b9bab619b14d0464
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 <string.h>
8 #include <errno.h>
10 #ifdef __weak_alias
11 __weak_alias(utimes, __utimes50)
12 #endif
14 int utimes(const char *name, const struct timeval tv[2])
16 message m;
18 if (name == NULL) {
19 errno = EINVAL;
20 return -1;
22 if (name[0] == '\0') { /* X/Open requirement */
23 errno = ENOENT;
24 return -1;
26 memset(&m, 0, sizeof(m));
27 m.m_vfs_utimens.len = strlen(name) + 1;
28 m.m_vfs_utimens.name = __UNCONST(name);
29 if (tv == NULL) {
30 m.m_vfs_utimens.atime = m.m_vfs_utimens.mtime = 0;
31 m.m_vfs_utimens.ansec = m.m_vfs_utimens.mnsec = UTIME_NOW;
33 else {
34 m.m_vfs_utimens.atime = tv[0].tv_sec;
35 m.m_vfs_utimens.mtime = tv[1].tv_sec;
36 m.m_vfs_utimens.ansec = tv[0].tv_usec * 1000;
37 m.m_vfs_utimens.mnsec = tv[1].tv_usec * 1000;
39 m.m_vfs_utimens.flags = 0;
41 return(_syscall(VFS_PROC_NR, VFS_UTIMENS, &m));