]>
Commit | Line | Data |
---|---|---|
11bf311e UD |
1 | /* Copyright (C) 1991-1995,1997,1999,2000,2006 |
2 | Free Software Foundation, Inc. | |
ebbad4cc | 3 | This file is part of the GNU C Library. |
28f540f4 | 4 | |
ebbad4cc | 5 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
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. | |
28f540f4 | 9 | |
ebbad4cc UD |
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 | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
28f540f4 | 14 | |
41bdb6e2 AJ |
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. */ | |
28f540f4 | 19 | |
28f540f4 RM |
20 | #include <sys/time.h> |
21 | #include <errno.h> | |
22 | #include <stddef.h> | |
23 | #include <hurd.h> | |
24 | ||
25 | /* Change the access time of FILE to TVP[0] and | |
26 | the modification time of FILE to TVP[1]. */ | |
27 | int | |
ebbad4cc UD |
28 | __utimes (file, tvp) |
29 | const char *file; | |
0ed99ce4 | 30 | const struct timeval tvp[2]; |
28f540f4 | 31 | { |
11bf311e UD |
32 | union tv |
33 | { | |
34 | struct timeval tv; | |
35 | time_value_t tvt; | |
36 | }; | |
37 | const union tv *u = (const union tv *) tvp; | |
38 | union tv nulltv[2]; | |
28f540f4 | 39 | error_t err; |
d3132360 RM |
40 | file_t port; |
41 | ||
42 | if (tvp == NULL) | |
43 | { | |
44 | /* Setting the number of microseconds to `-1' tells the | |
45 | underlying filesystems to use the current time. */ | |
11bf311e UD |
46 | nulltv[0].tvt.microseconds = nulltv[1].tvt.microseconds = -1; |
47 | u = nulltv; | |
d3132360 RM |
48 | } |
49 | ||
50 | port = __file_name_lookup (file, 0, 0); | |
51 | if (port == MACH_PORT_NULL) | |
28f540f4 | 52 | return -1; |
11bf311e | 53 | err = __file_utimes (port, u[0].tvt, u[1].tvt); |
d3132360 | 54 | __mach_port_deallocate (__mach_task_self (), port); |
28f540f4 RM |
55 | if (err) |
56 | return __hurd_fail (err); | |
57 | return 0; | |
58 | } | |
28f540f4 | 59 | weak_alias (__utimes, utimes) |