+2006-09-01 Miklos Szeredi <miklos@szeredi.hu>
+
+ * Fix recursive lock bug in interrupt handling
+
+ * Add utimes() method to highlevel interface, which supports
+ setting times with nanosecond resolution
+
2006-08-18 Miklos Szeredi <miklos@szeredi.hu>
* kernel: fix page leak if fuse_readpages() failed in it's
#include <fcntl.h>
#include <dirent.h>
#include <errno.h>
+#include <sys/time.h>
#ifdef HAVE_SETXATTR
#include <sys/xattr.h>
#endif
return 0;
}
-static int xmp_utime(const char *path, struct utimbuf *buf)
+static int xmp_utimes(const char *path, const struct timespec ts[2])
{
int res;
+ struct timeval tv[2];
- res = utime(path, buf);
+ tv[0].tv_sec = ts[0].tv_sec;
+ tv[0].tv_usec = ts[0].tv_nsec / 1000;
+ tv[1].tv_sec = ts[1].tv_sec;
+ tv[1].tv_usec = ts[1].tv_nsec / 1000;
+
+ res = utimes(path, tv);
if (res == -1)
return -errno;
return 0;
}
-
static int xmp_open(const char *path, struct fuse_file_info *fi)
{
int res;
.chmod = xmp_chmod,
.chown = xmp_chown,
.truncate = xmp_truncate,
- .utime = xmp_utime,
+ .utimes = xmp_utimes,
.open = xmp_open,
.read = xmp_read,
.write = xmp_write,
#include <fcntl.h>
#include <dirent.h>
#include <errno.h>
+#include <sys/time.h>
#ifdef HAVE_SETXATTR
#include <sys/xattr.h>
#endif
return 0;
}
-static int xmp_utime(const char *path, struct utimbuf *buf)
+static int xmp_utimes(const char *path, const struct timespec ts[2])
{
int res;
+ struct timeval tv[2];
- res = utime(path, buf);
+ tv[0].tv_sec = ts[0].tv_sec;
+ tv[0].tv_usec = ts[0].tv_nsec / 1000;
+ tv[1].tv_sec = ts[1].tv_sec;
+ tv[1].tv_usec = ts[1].tv_nsec / 1000;
+
+ res = utimes(path, tv);
if (res == -1)
return -errno;
.chown = xmp_chown,
.truncate = xmp_truncate,
.ftruncate = xmp_ftruncate,
- .utime = xmp_utime,
+ .utimes = xmp_utimes,
.create = xmp_create,
.open = xmp_open,
.read = xmp_read,
#include "fuse_common.h"
#include <fcntl.h>
+#include <time.h>
#include <utime.h>
#include <sys/types.h>
#include <sys/stat.h>
/** Change the size of a file */
int (*truncate) (const char *, off_t);
- /** Change the access and/or modification times of a file */
+ /** Change the access and/or modification times of a file
+ *
+ * Deprecated, use utimes() instead.
+ */
int (*utime) (const char *, struct utimbuf *);
/** File open operation
*/
int (*lock) (const char *, struct fuse_file_info *, int cmd,
struct flock *, uint64_t owner);
+
+ /** Change the access and modification times of a file */
+ int (*utimes) (const char *, const struct timespec tv[2]);
};
/** Extra context that may be needed by some filesystems
return err;
}
-static int do_utime(struct fuse *f, const char *path, struct stat *attr)
+static int do_utimes(struct fuse *f, const char *path, struct stat *attr)
{
int err;
- struct utimbuf buf;
- buf.actime = attr->st_atime;
- buf.modtime = attr->st_mtime;
+
err = -ENOSYS;
- if (f->op.utime)
+ if (f->op.utimes) {
+ struct timespec tv[2];
+ tv[0] = attr->st_atim;
+ tv[1] = attr->st_mtim;
+ err = f->op.utimes(path, tv);
+ } else if (f->op.utime) {
+ struct utimbuf buf;
+ buf.actime = attr->st_atime;
+ buf.modtime = attr->st_mtime;
err = f->op.utime(path, &buf);
+ }
return err;
}
if (!err && (valid & FUSE_SET_ATTR_SIZE))
err = do_truncate(f, path, attr, fi);
if (!err && (valid & (FUSE_SET_ATTR_ATIME | FUSE_SET_ATTR_MTIME)) == (FUSE_SET_ATTR_ATIME | FUSE_SET_ATTR_MTIME))
- err = do_utime(f, path, attr);
+ err = do_utimes(f, path, attr);
if (!err)
err = f->op.getattr(path, &buf);
}
pthread_mutex_unlock(&f->lock);
}
-static void check_interrupt(struct fuse_ll *f, struct fuse_req *req)
+static struct fuse_req *check_interrupt(struct fuse_ll *f, struct fuse_req *req)
{
struct fuse_req *curr;
for (curr = f->interrupts.next; curr != &f->interrupts; curr = curr->next) {
if (curr->u.i.unique == req->unique) {
+ req->interrupted = 1;
list_del_req(curr);
free(curr);
- return;
+ return NULL;
}
}
curr = f->interrupts.next;
- if (curr != &f->interrupts)
- fuse_reply_err(curr, EAGAIN);
+ if (curr != &f->interrupts) {
+ list_del_req(curr);
+ list_init_req(curr);
+ return curr;
+ } else
+ return NULL;
}
static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
fuse_reply_err(req, ENOSYS);
else {
if (in->opcode != FUSE_INTERRUPT) {
+ struct fuse_req *intr;
pthread_mutex_lock(&f->lock);
- check_interrupt(f, req);
+ intr = check_interrupt(f, req);
list_add_req(req, &f->list);
pthread_mutex_unlock(&f->lock);
+ if (intr)
+ fuse_reply_err(intr, EAGAIN);
}
fuse_ll_ops[in->opcode].func(req, in->nodeid, inarg);
}