[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Add Hurd support for UTIME_OMIT and UTIME_NOW.
From: |
Flávio Cruz |
Subject: |
[PATCH] Add Hurd support for UTIME_OMIT and UTIME_NOW. |
Date: |
Sat, 29 Aug 2015 03:37:48 +0100 |
From: Flávio Cruz <flaviocruz@gmail.com>
This fixes the bug described in
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=762677
---
sysdeps/mach/hurd/bits/stat.h | 4 ++++
sysdeps/mach/hurd/futimens.c | 17 ++++++++++-------
sysdeps/mach/hurd/futimes.c | 25 ++++++++++++++-----------
sysdeps/mach/hurd/lutimes.c | 25 ++++++++++++++-----------
sysdeps/mach/hurd/utimes.c | 25 ++++++++++++++-----------
5 files changed, 56 insertions(+), 40 deletions(-)
diff --git a/sysdeps/mach/hurd/bits/stat.h b/sysdeps/mach/hurd/bits/stat.h
index f60a58a..c2d0cc2 100644
--- a/sysdeps/mach/hurd/bits/stat.h
+++ b/sysdeps/mach/hurd/bits/stat.h
@@ -246,6 +246,10 @@ struct stat64
# define SF_NOUNLINK 0x00100000 /* file may not be removed or renamed */
# define SF_SNAPSHOT 0x00200000 /* snapshot inode */
+/* Time flags for futimens. */
+#define UTIME_NOW -1 /* corresponds to the current time */
+#define UTIME_OMIT -2 /* target time is omitted */
+
__BEGIN_DECLS
/* Set file flags for FILE to FLAGS. */
diff --git a/sysdeps/mach/hurd/futimens.c b/sysdeps/mach/hurd/futimens.c
index 4f82f1e..e3c30ae 100644
--- a/sysdeps/mach/hurd/futimens.c
+++ b/sysdeps/mach/hurd/futimens.c
@@ -27,21 +27,24 @@
int
__futimens (int fd, const struct timespec tsp[2])
{
- time_value_t atime, mtime;
+ struct timespec atime, mtime;
error_t err;
if (tsp == NULL)
{
- /* Setting the number of microseconds to `-1' tells the
+ /* Setting the number of nanoseconds to UTIME_NOW tells the
underlying filesystems to use the current time. */
- atime.microseconds = mtime.microseconds = -1;
+ atime.tv_sec = 0;
+ atime.tv_nsec = UTIME_NOW;
+ mtime.tv_sec = 0;
+ mtime.tv_nsec = UTIME_NOW;
}
else
{
- atime.seconds = tsp[0].tv_sec;
- atime.microseconds = tsp[0].tv_nsec / 1000;
- mtime.seconds = tsp[1].tv_sec;
- mtime.microseconds = tsp[1].tv_nsec / 1000;
+ atime.tv_sec = tsp[0].tv_sec;
+ atime.tv_nsec = tsp[0].tv_nsec;
+ mtime.tv_sec = tsp[1].tv_sec;
+ mtime.tv_nsec = tsp[1].tv_nsec;
}
err = HURD_DPORT_USE (fd, __file_utimes (port, atime, mtime));
diff --git a/sysdeps/mach/hurd/futimes.c b/sysdeps/mach/hurd/futimes.c
index c325d44..d2440e8 100644
--- a/sysdeps/mach/hurd/futimes.c
+++ b/sysdeps/mach/hurd/futimes.c
@@ -27,24 +27,27 @@
int
__futimes (int fd, const struct timeval tvp[2])
{
- union tv
- {
- struct timeval tv;
- time_value_t tvt;
- };
- const union tv *u = (const union tv *) tvp;
- union tv nulltv[2];
+ struct timespec u[2];
error_t err;
if (tvp == NULL)
{
- /* Setting the number of microseconds to `-1' tells the
+ /* Setting the number of microseconds to UTIME_NOW tells the
underlying filesystems to use the current time. */
- nulltv[0].tvt.microseconds = nulltv[1].tvt.microseconds = -1;
- u = nulltv;
+ u[0].tv_sec = 0;
+ u[0].tv_nsec = UTIME_NOW;
+ u[1].tv_sec = 0;
+ u[2].tv_nsec = UTIME_NOW;
+ }
+ else
+ {
+ u[0].tv_sec = tvp[0].tv_sec;
+ u[0].tv_nsec = tvp[0].tv_usec * 1000;
+ u[1].tv_sec = tvp[1].tv_sec;
+ u[1].tv_nsec = tvp[1].tv_usec * 1000;
}
- err = HURD_DPORT_USE (fd, __file_utimes (port, u[0].tvt, u[1].tvt));
+ err = HURD_DPORT_USE (fd, __file_utimes (port, u[0], u[1]));
return err ? __hurd_dfail (fd, err) : 0;
}
weak_alias (__futimes, futimes)
diff --git a/sysdeps/mach/hurd/lutimes.c b/sysdeps/mach/hurd/lutimes.c
index 260842d..32a5a9c 100644
--- a/sysdeps/mach/hurd/lutimes.c
+++ b/sysdeps/mach/hurd/lutimes.c
@@ -27,28 +27,31 @@
int
__lutimes (const char *file, const struct timeval tvp[2])
{
- union tv
- {
- struct timeval tv;
- time_value_t tvt;
- };
- const union tv *u = (const union tv *) tvp;
- union tv nulltv[2];
+ struct timespec u[2];
error_t err;
file_t port;
if (tvp == NULL)
{
- /* Setting the number of microseconds to `-1' tells the
+ /* Setting the number of microseconds to UTIME_NOW tells the
underlying filesystems to use the current time. */
- nulltv[0].tvt.microseconds = nulltv[1].tvt.microseconds = -1;
- u = nulltv;
+ u[0].tv_sec = 0;
+ u[0].tv_nsec = UTIME_NOW;
+ u[1].tv_sec = 0;
+ u[2].tv_nsec = UTIME_NOW;
+ }
+ else
+ {
+ u[0].tv_sec = tvp[0].tv_sec;
+ u[0].tv_nsec = tvp[0].tv_usec * 1000;
+ u[1].tv_sec = tvp[1].tv_sec;
+ u[1].tv_nsec = tvp[1].tv_usec * 1000;
}
port = __file_name_lookup (file, O_NOLINK, 0);
if (port == MACH_PORT_NULL)
return -1;
- err = __file_utimes (port, u[0].tvt, u[1].tvt);
+ err = __file_utimes (port, u[0], u[1]);
__mach_port_deallocate (__mach_task_self (), port);
if (err)
return __hurd_fail (err);
diff --git a/sysdeps/mach/hurd/utimes.c b/sysdeps/mach/hurd/utimes.c
index 6739b79..97f61d7 100644
--- a/sysdeps/mach/hurd/utimes.c
+++ b/sysdeps/mach/hurd/utimes.c
@@ -27,28 +27,31 @@ __utimes (file, tvp)
const char *file;
const struct timeval tvp[2];
{
- union tv
- {
- struct timeval tv;
- time_value_t tvt;
- };
- const union tv *u = (const union tv *) tvp;
- union tv nulltv[2];
+ struct timespec u[2];
error_t err;
file_t port;
if (tvp == NULL)
{
- /* Setting the number of microseconds to `-1' tells the
+ /* Setting the number of microseconds to UTIME_NOW tells the
underlying filesystems to use the current time. */
- nulltv[0].tvt.microseconds = nulltv[1].tvt.microseconds = -1;
- u = nulltv;
+ u[0].tv_sec = 0;
+ u[0].tv_nsec = UTIME_NOW;
+ u[1].tv_sec = 0;
+ u[2].tv_nsec = UTIME_NOW;
+ }
+ else
+ {
+ u[0].tv_sec = tvp[0].tv_sec;
+ u[0].tv_nsec = tvp[0].tv_usec * 1000;
+ u[1].tv_sec = tvp[1].tv_sec;
+ u[1].tv_nsec = tvp[1].tv_usec * 1000;
}
port = __file_name_lookup (file, 0, 0);
if (port == MACH_PORT_NULL)
return -1;
- err = __file_utimes (port, u[0].tvt, u[1].tvt);
+ err = __file_utimes (port, u[0], u[1]);
__mach_port_deallocate (__mach_task_self (), port);
if (err)
return __hurd_fail (err);
--
2.5.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] Add Hurd support for UTIME_OMIT and UTIME_NOW.,
Flávio Cruz <=