2.9
[glibc/nacl-glibc.git] / sysdeps / mach / hurd / utimes.c
blobfdc1427feb86fd60f21943a92ca2bc0b9b418230
1 /* Copyright (C) 1991-1995,1997,1999,2000,2006
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <sys/time.h>
21 #include <errno.h>
22 #include <stddef.h>
23 #include <hurd.h>
25 /* Change the access time of FILE to TVP[0] and
26 the modification time of FILE to TVP[1]. */
27 int
28 __utimes (file, tvp)
29 const char *file;
30 const struct timeval tvp[2];
32 union tv
34 struct timeval tv;
35 time_value_t tvt;
37 const union tv *u = (const union tv *) tvp;
38 union tv nulltv[2];
39 error_t err;
40 file_t port;
42 if (tvp == NULL)
44 /* Setting the number of microseconds to `-1' tells the
45 underlying filesystems to use the current time. */
46 nulltv[0].tvt.microseconds = nulltv[1].tvt.microseconds = -1;
47 u = nulltv;
50 port = __file_name_lookup (file, 0, 0);
51 if (port == MACH_PORT_NULL)
52 return -1;
53 err = __file_utimes (port, u[0].tvt, u[1].tvt);
54 __mach_port_deallocate (__mach_task_self (), port);
55 if (err)
56 return __hurd_fail (err);
57 return 0;
59 weak_alias (__utimes, utimes)