return 0;
}
-static int xmp_ftruncate(const char *path, off_t size,
- struct fuse_file_info *fi)
-{
- int res;
-
- (void) path;
-
- res = ftruncate(fi->fh, size);
- if(res == -1)
- return -errno;
-
- return 0;
-}
-
static int xmp_utime(const char *path, struct utimbuf *buf)
{
int res;
return 0;
}
-static int xmp_create(const char *path, mode_t mode, struct fuse_file_info *fi)
-{
- int fd;
- struct stat stbuf;
-
- fd = open(path, fi->flags | O_NOFOLLOW, mode);
- if(fd == -1)
- return -errno;
-
- if (fstat(fd, &stbuf) == -1) {
- close(fd);
- return -EIO;
- }
- if (!S_ISREG(stbuf.st_mode)) {
- close(fd);
- return -EISDIR;
- }
-
- fi->fh = fd;
- return 0;
-}
-
static int xmp_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
.chmod = xmp_chmod,
.chown = xmp_chown,
.truncate = xmp_truncate,
- .ftruncate = xmp_ftruncate,
.utime = xmp_utime,
.open = xmp_open,
.read = xmp_read,
.statfs = xmp_statfs,
.release = xmp_release,
.fsync = xmp_fsync,
- .create = xmp_create,
#ifdef HAVE_SETXATTR
.setxattr = xmp_setxattr,
.getxattr = xmp_getxattr,
* Introduced in version 2.3
*/
void (*destroy) (void *);
-
- /**
- * Check file access permissions
- *
- * Need not be implemented. Will only be called for the access()
- * system call, and for the open() system call, unless a new file
- * is created (file didn't exist and O_CREAT was given). If the
- * 'default_permissions' mount option is given, this method is
- * never called.
- *
- * Introduced in version 2.4
- */
- int (*access) (const char *, int);
-
- int (*create) (const char *, mode_t, struct fuse_file_info *);
-
- int (*ftruncate) (const char *, off_t, struct fuse_file_info *);
};
/** Extra context that may be needed by some filesystems
return err;
}
-static int do_truncate(struct fuse *f, const char *path, struct stat *attr,
- struct fuse_file_info *fi)
+static int do_truncate(struct fuse *f, const char *path, struct stat *attr)
{
int err;
err = -ENOSYS;
- if (fi && f->op.ftruncate)
- err = f->op.ftruncate(path, attr->st_size, fi);
- else if (f->op.truncate)
+ if (f->op.truncate)
err = f->op.truncate(path, attr->st_size);
return err;
char *path;
int err;
+ (void) fi;
+
err = -ENOENT;
pthread_rwlock_rdlock(&f->tree_lock);
path = get_path(f, ino);
if (!err && (valid & (FUSE_SET_ATTR_UID | FUSE_SET_ATTR_GID)))
err = do_chown(f, path, attr, valid);
if (!err && (valid & FUSE_SET_ATTR_SIZE))
- err = do_truncate(f, path, attr, fi);
+ err = do_truncate(f, path, attr);
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);
if (!err)