From 7c11a45e6ebf8c17bc4f2f3ee6d3f79cd982b489 Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Tue, 14 Nov 2017 21:55:41 -0800 Subject: [PATCH] tst: passthrough-fuse: setcrtime --- tst/passthrough-fuse/passthrough-fuse.c | 12 ++++++++++++ tst/passthrough-fuse/winposix.c | 20 ++++++++++++++++++++ tst/passthrough-fuse/winposix.h | 1 + 3 files changed, 33 insertions(+) diff --git a/tst/passthrough-fuse/passthrough-fuse.c b/tst/passthrough-fuse/passthrough-fuse.c index 55cc7b4f..7128c0ac 100644 --- a/tst/passthrough-fuse/passthrough-fuse.c +++ b/tst/passthrough-fuse/passthrough-fuse.c @@ -259,6 +259,15 @@ static int ptfs_utimens(const char *path, const struct fuse_timespec tv[2]) } #endif +#if defined(_WIN64) || defined(_WIN32) +static int ptfs_setcrtime(const char *path, const struct fuse_timespec *tv) +{ + ptfs_impl_fullpath(path); + + return -1 != setcrtime(path, tv) ? 0 : -errno; +} +#endif + #if defined(FSP_FUSE_USE_STAT_EX) static int ptfs_chflags(const char *path, uint32_t flags) { @@ -297,6 +306,9 @@ static struct fuse_operations ptfs_ops = #if defined(PTFS_UTIMENS) .utimens = ptfs_utimens, #endif +#if defined(_WIN64) || defined(_WIN32) + .setcrtime = ptfs_setcrtime, +#endif #if defined(FSP_FUSE_USE_STAT_EX) .chflags = ptfs_chflags, #endif diff --git a/tst/passthrough-fuse/winposix.c b/tst/passthrough-fuse/winposix.c index 83cd79be..0531e32a 100644 --- a/tst/passthrough-fuse/winposix.c +++ b/tst/passthrough-fuse/winposix.c @@ -378,6 +378,26 @@ int utimensat(int dirfd, const char *path, const struct fuse_timespec times[2]) return res; } +int setcrtime(const char *path, const struct fuse_timespec *tv) +{ + HANDLE h = CreateFileA(path, + FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + 0, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); + if (INVALID_HANDLE_VALUE == h) + return error(); + + UINT64 CreationTime; + FspPosixUnixTimeToFileTime((void *)tv, &CreationTime); + + int res = SetFileTime(h, + (PFILETIME)&CreationTime, 0, 0) ? 0 : error(); + + CloseHandle(h); + + return res; +} + int unlink(const char *path) { if (!DeleteFileA(path)) diff --git a/tst/passthrough-fuse/winposix.h b/tst/passthrough-fuse/winposix.h index ea9c260e..ded928c4 100644 --- a/tst/passthrough-fuse/winposix.h +++ b/tst/passthrough-fuse/winposix.h @@ -55,6 +55,7 @@ int lchflags(const char *path, uint32_t flags); int truncate(const char *path, fuse_off_t size); int utime(const char *path, const struct fuse_utimbuf *timbuf); int utimensat(int dirfd, const char *path, const struct fuse_timespec times[2]); +int setcrtime(const char *path, const struct fuse_timespec *tv); int unlink(const char *path); int rename(const char *oldpath, const char *newpath);