From 429df523678c01ed1ff39c3d6eed88d4e11bf3c4 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 2 Nov 2009 13:21:16 +0100 Subject: Add support for setting modification time (ifuse_utimens). Support for this is available since iphone OS 3.1, for devices prior to this version this operation just returns success. Signed-off-by: Matt Colyer --- src/ifuse.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src') diff --git a/src/ifuse.c b/src/ifuse.c index cefa66c..2570760 100644 --- a/src/ifuse.c +++ b/src/ifuse.c @@ -332,6 +332,24 @@ static int ifuse_write(const char *path, const char *buf, size_t size, off_t off return bytes; } +static int ifuse_utimens(const char *path, const struct timespec tv[2]) +{ + afc_client_t afc = fuse_get_context()->private_data; + uint64_t mtime = (uint64_t)tv[1].tv_sec * (uint64_t)1000000000 + (uint64_t)tv[1].tv_nsec; + + afc_error_t err = afc_set_file_time(afc, path, mtime); + if (err == AFC_E_UNKNOWN_PACKET_TYPE) { + /* ignore error for pre-3.1 devices as they do not support setting file modification times */ + return 0; + } + if (err != AFC_E_SUCCESS) { + int res = get_afc_error_as_errno(err); + return -res; + } + + return 0; +} + static int ifuse_fsync(const char *path, int datasync, struct fuse_file_info *fi) { return 0; @@ -567,6 +585,7 @@ static struct fuse_operations ifuse_oper = { .link = ifuse_link, .unlink = ifuse_unlink, .rename = ifuse_rename, + .utimens = ifuse_utimens, .fsync = ifuse_fsync, .release = ifuse_release, .init = ifuse_init_normal, -- cgit v1.1-32-gdbae