From 4ecbee4f9400fe95df9c8709c90942bbe79194b4 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 26 Mar 2009 00:50:44 +0000 Subject: [PATCH] * Our error codes are already negative, so return ENOSYS instead of -ENOSYS. * fuse_fs_utimens(): Fall back to the utime() hook, if utimens() is not available. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29720 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../userlandfs/server/fuse/fuse_fs.cpp | 71 +++++++++++-------- 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_fs.cpp b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_fs.cpp index d7524a14ad..62831b171c 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_fs.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_fs.cpp @@ -16,7 +16,7 @@ int fuse_fs_getattr(struct fuse_fs* fs, const char* path, struct stat* buf) { if (fs->ops.getattr == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.getattr(path, buf); } @@ -26,7 +26,7 @@ fuse_fs_fgetattr(struct fuse_fs* fs, const char* path, struct stat* buf, struct fuse_file_info* fi) { if (fs->ops.fgetattr == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.fgetattr(path, buf, fi); } @@ -35,7 +35,7 @@ int fuse_fs_rename(struct fuse_fs* fs, const char* oldpath, const char* newpath) { if (fs->ops.rename == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.rename(oldpath, newpath); } @@ -44,7 +44,7 @@ int fuse_fs_unlink(struct fuse_fs* fs, const char* path) { if (fs->ops.unlink == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.unlink(path); } @@ -53,7 +53,7 @@ int fuse_fs_rmdir(struct fuse_fs* fs, const char* path) { if (fs->ops.rmdir == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.rmdir(path); } @@ -62,7 +62,7 @@ int fuse_fs_symlink(struct fuse_fs* fs, const char* linkname, const char* path) { if (fs->ops.symlink == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.symlink(linkname, path); } @@ -71,7 +71,7 @@ int fuse_fs_link(struct fuse_fs* fs, const char* oldpath, const char* newpath) { if (fs->ops.link == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.link(oldpath, newpath); } @@ -100,7 +100,7 @@ fuse_fs_read(struct fuse_fs* fs, const char* path, char *buf, size_t size, off_t off, struct fuse_file_info* fi) { if (fs->ops.read == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.read(path, buf, size, off, fi); } @@ -110,7 +110,7 @@ fuse_fs_write(struct fuse_fs* fs, const char* path, const char* buf, size_t size, off_t off, struct fuse_file_info* fi) { if (fs->ops.write == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.write(path, buf, size, off, fi); } @@ -120,7 +120,7 @@ fuse_fs_fsync(struct fuse_fs* fs, const char* path, int datasync, struct fuse_file_info* fi) { if (fs->ops.fsync == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.fsync(path, datasync, fi); } @@ -129,7 +129,7 @@ int fuse_fs_flush(struct fuse_fs* fs, const char* path, struct fuse_file_info* fi) { if (fs->ops.flush == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.flush(path, fi); } @@ -157,7 +157,7 @@ fuse_fs_readdir(struct fuse_fs* fs, const char* path, void* buf, fuse_fill_dir_t filler, off_t off, struct fuse_file_info* fi) { if (fs->ops.readdir == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.readdir(path, buf, filler, off, fi); } @@ -167,7 +167,7 @@ fuse_fs_fsyncdir(struct fuse_fs* fs, const char* path, int datasync, struct fuse_file_info* fi) { if (fs->ops.fsyncdir == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.fsyncdir(path, datasync, fi); } @@ -187,7 +187,7 @@ fuse_fs_create(struct fuse_fs* fs, const char* path, mode_t mode, struct fuse_file_info* fi) { if (fs->ops.create == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.create(path, mode, fi); } @@ -197,7 +197,7 @@ fuse_fs_lock(struct fuse_fs* fs, const char* path, struct fuse_file_info* fi, int cmd, struct flock* lock) { if (fs->ops.lock == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.lock(path, fi, cmd, lock); } @@ -206,7 +206,7 @@ int fuse_fs_chmod(struct fuse_fs* fs, const char* path, mode_t mode) { if (fs->ops.chmod == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.chmod(path, mode); } @@ -215,7 +215,7 @@ int fuse_fs_chown(struct fuse_fs* fs, const char* path, uid_t uid, gid_t gid) { if (fs->ops.chown == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.chown(path, uid, gid); } @@ -224,7 +224,7 @@ int fuse_fs_truncate(struct fuse_fs* fs, const char* path, off_t size) { if (fs->ops.truncate == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.truncate(path, size); } @@ -234,7 +234,7 @@ fuse_fs_ftruncate(struct fuse_fs* fs, const char* path, off_t size, struct fuse_file_info* fi) { if (fs->ops.ftruncate == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.ftruncate(path, size, fi); } @@ -243,9 +243,18 @@ int fuse_fs_utimens(struct fuse_fs* fs, const char* path, const struct timespec tv[2]) { - if (fs->ops.utimens == NULL) - return -ENOSYS; - return fs->ops.utimens(path, tv); + if (fs->ops.utimens != NULL) + return fs->ops.utimens(path, tv); + + if (fs->ops.utime != NULL) { + utimbuf timeBuffer = { + tv[0].tv_sec, // access time + tv[1].tv_sec // modification time + }; + return fs->ops.utime(path, &timeBuffer); + } + + return ENOSYS; } @@ -253,7 +262,7 @@ int fuse_fs_access(struct fuse_fs* fs, const char* path, int mask) { if (fs->ops.access == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.access(path, mask); } @@ -262,7 +271,7 @@ int fuse_fs_readlink(struct fuse_fs* fs, const char* path, char* buf, size_t len) { if (fs->ops.readlink == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.readlink(path, buf, len); } @@ -271,7 +280,7 @@ int fuse_fs_mknod(struct fuse_fs* fs, const char* path, mode_t mode, dev_t rdev) { if (fs->ops.mknod == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.mknod(path, mode, rdev); } @@ -280,7 +289,7 @@ int fuse_fs_mkdir(struct fuse_fs* fs, const char* path, mode_t mode) { if (fs->ops.mkdir == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.mkdir(path, mode); } @@ -290,7 +299,7 @@ fuse_fs_setxattr(struct fuse_fs* fs, const char* path, const char* name, const char* value, size_t size, int flags) { if (fs->ops.setxattr == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.setxattr(path, name, value, size, flags); } @@ -300,7 +309,7 @@ fuse_fs_getxattr(struct fuse_fs* fs, const char* path, const char* name, char* value, size_t size) { if (fs->ops.getxattr == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.getxattr(path, name, value, size); } @@ -309,7 +318,7 @@ int fuse_fs_listxattr(struct fuse_fs* fs, const char* path, char* list, size_t size) { if (fs->ops.listxattr == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.listxattr(path, list, size); } @@ -318,7 +327,7 @@ int fuse_fs_removexattr(struct fuse_fs* fs, const char* path, const char* name) { if (fs->ops.removexattr == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.removexattr(path, name); } @@ -328,7 +337,7 @@ fuse_fs_bmap(struct fuse_fs* fs, const char* path, size_t blocksize, uint64_t* idx) { if (fs->ops.bmap == NULL) - return -ENOSYS; + return ENOSYS; return fs->ops.bmap(path, blocksize, idx); }