xref: /minix/minix/lib/libc/sys/futimes.c (revision 83133719)
1 #include <sys/cdefs.h>
2 #include "namespace.h"
3 #include <lib.h>
4 
5 #include <string.h>
6 #include <sys/stat.h>
7 #include <sys/time.h>
8 
9 #ifdef __weak_alias
10 __weak_alias(futimes, __futimes50)
11 #endif
12 
13 int futimes(int fd, const struct timeval tv[2])
14 {
15   message m;
16 
17   memset(&m, 0, sizeof(m));
18   m.m_vfs_utimens.fd = fd;
19   if (tv == NULL) {
20 	m.m_vfs_utimens.atime = m.m_vfs_utimens.mtime = 0;
21 	m.m_vfs_utimens.ansec = m.m_vfs_utimens.mnsec = UTIME_NOW;
22   }
23   else {
24 	m.m_vfs_utimens.atime = tv[0].tv_sec;
25 	m.m_vfs_utimens.mtime = tv[1].tv_sec;
26 	m.m_vfs_utimens.ansec = tv[0].tv_usec * 1000;
27 	m.m_vfs_utimens.mnsec = tv[1].tv_usec * 1000;
28   }
29   m.m_vfs_utimens.name = NULL;
30   m.m_vfs_utimens.flags = 0;
31 
32   return(_syscall(VFS_PROC_NR, VFS_UTIMENS, &m));
33 }
34