1 #include <sys/cdefs.h> 2 #include "namespace.h" 3 #include <lib.h> 4 5 #include <sys/stat.h> 6 #include <sys/time.h> 7 #include <string.h> 8 #include <errno.h> 9 10 #ifdef __weak_alias 11 __weak_alias(utimes, __utimes50) 12 #endif 13 14 int utimes(const char *name, const struct timeval tv[2]) 15 { 16 message m; 17 18 if (name == NULL) { 19 errno = EINVAL; 20 return -1; 21 } 22 if (name[0] == '\0') { /* X/Open requirement */ 23 errno = ENOENT; 24 return -1; 25 } 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; 32 } 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; 38 } 39 m.m_vfs_utimens.flags = 0; 40 41 return(_syscall(VFS_PROC_NR, VFS_UTIMENS, &m)); 42 } 43