aboutsummaryrefslogtreecommitdiff
path: root/sshfs.c
diff options
context:
space:
mode:
authorDaniel Lublin <daniel@lublin.se>2018-06-18 20:12:38 +0200
committerNikolaus Rath <Nikolaus@rath.org>2018-06-18 19:12:38 +0100
commitf0452119e0e5365bd140e8dd47ff268d274f55de (patch)
treec302a30a447fd9b8e169573887a21664298ab91f /sshfs.c
parentfb174704ddbaa086ed801cfbb5c8326d28140a92 (diff)
downloadsshfs-f0452119e0e5365bd140e8dd47ff268d274f55de.tar
sshfs-f0452119e0e5365bd140e8dd47ff268d274f55de.tar.gz
sshfs-f0452119e0e5365bd140e8dd47ff268d274f55de.tar.bz2
sshfs-f0452119e0e5365bd140e8dd47ff268d274f55de.zip
Make utimens(NULL) work correctly
Diffstat (limited to 'sshfs.c')
-rw-r--r--sshfs.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sshfs.c b/sshfs.c
index bb1ef3a..e62c45a 100644
--- a/sshfs.c
+++ b/sshfs.c
@@ -2473,6 +2473,14 @@ static int sshfs_utimens(const char *path, const struct timespec tv[2],
int err;
struct buffer buf;
struct sshfs_file *sf = NULL;
+ time_t asec = tv[0].tv_sec, msec = tv[1].tv_sec;
+
+ struct timeval now;
+ gettimeofday(&now, NULL);
+ if (asec == 0)
+ asec = now.tv_sec;
+ if (msec == 0)
+ msec = now.tv_sec;
if (fi != NULL) {
sf = get_sshfs_file(fi);
@@ -2486,8 +2494,8 @@ static int sshfs_utimens(const char *path, const struct timespec tv[2],
else
buf_add_buf(&buf, &sf->handle);
buf_add_uint32(&buf, SSH_FILEXFER_ATTR_ACMODTIME);
- buf_add_uint32(&buf, tv[0].tv_sec);
- buf_add_uint32(&buf, tv[1].tv_sec);
+ buf_add_uint32(&buf, asec);
+ buf_add_uint32(&buf, msec);
err = sftp_request(sf == NULL ? SSH_FXP_SETSTAT : SSH_FXP_FSETSTAT,
&buf, SSH_FXP_STATUS, NULL);