Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 74379
b: refs/heads/master
c: bcb4be8
h: refs/heads/master
i:
  74377: 399e33c
  74375: 973f560
v: v3
  • Loading branch information
Miklos Szeredi authored and Linus Torvalds committed Nov 29, 2007
1 parent 214b496 commit a2566a8
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b6fd6ecb830444636bc4e9d626f214082c91fffe
refs/heads/master: bcb4be809d2a804ff040d95db4a664113833e702
48 changes: 29 additions & 19 deletions trunk/fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,31 @@ static int fuse_do_getattr(struct inode *inode, struct kstat *stat,
return err;
}

int fuse_update_attributes(struct inode *inode, struct kstat *stat,
struct file *file, bool *refreshed)
{
struct fuse_inode *fi = get_fuse_inode(inode);
int err;
bool r;

if (fi->i_time < get_jiffies_64()) {
r = true;
err = fuse_do_getattr(inode, stat, file);
} else {
r = false;
err = 0;
if (stat) {
generic_fillattr(inode, stat);
stat->mode = fi->orig_i_mode;
}
}

if (refreshed != NULL)
*refreshed = r;

return err;
}

/*
* Calling into a user-controlled filesystem gives the filesystem
* daemon ptrace-like capabilities over the requester process. This
Expand Down Expand Up @@ -862,14 +887,9 @@ static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd)
*/
if ((fc->flags & FUSE_DEFAULT_PERMISSIONS) ||
((mask & MAY_EXEC) && S_ISREG(inode->i_mode))) {
struct fuse_inode *fi = get_fuse_inode(inode);
if (fi->i_time < get_jiffies_64()) {
err = fuse_do_getattr(inode, NULL, NULL);
if (err)
return err;

refreshed = true;
}
err = fuse_update_attributes(inode, NULL, NULL, &refreshed);
if (err)
return err;
}

if (fc->flags & FUSE_DEFAULT_PERMISSIONS) {
Expand Down Expand Up @@ -1173,22 +1193,12 @@ static int fuse_getattr(struct vfsmount *mnt, struct dentry *entry,
struct kstat *stat)
{
struct inode *inode = entry->d_inode;
struct fuse_inode *fi = get_fuse_inode(inode);
struct fuse_conn *fc = get_fuse_conn(inode);
int err;

if (!fuse_allow_task(fc, current))
return -EACCES;

if (fi->i_time < get_jiffies_64())
err = fuse_do_getattr(inode, stat, NULL);
else {
err = 0;
generic_fillattr(inode, stat);
stat->mode = fi->orig_i_mode;
}

return err;
return fuse_update_attributes(inode, stat, NULL, NULL);
}

static int fuse_setxattr(struct dentry *entry, const char *name,
Expand Down
21 changes: 20 additions & 1 deletion trunk/fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,25 @@ static int fuse_readpages(struct file *file, struct address_space *mapping,
return err;
}

static ssize_t fuse_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos)
{
struct inode *inode = iocb->ki_filp->f_mapping->host;

if (pos + iov_length(iov, nr_segs) > i_size_read(inode)) {
int err;
/*
* If trying to read past EOF, make sure the i_size
* attribute is up-to-date.
*/
err = fuse_update_attributes(inode, NULL, iocb->ki_filp, NULL);
if (err)
return err;
}

return generic_file_aio_read(iocb, iov, nr_segs, pos);
}

static void fuse_write_fill(struct fuse_req *req, struct fuse_file *ff,
struct inode *inode, loff_t pos, size_t count,
int writepage)
Expand Down Expand Up @@ -887,7 +906,7 @@ static sector_t fuse_bmap(struct address_space *mapping, sector_t block)
static const struct file_operations fuse_file_operations = {
.llseek = generic_file_llseek,
.read = do_sync_read,
.aio_read = generic_file_aio_read,
.aio_read = fuse_file_aio_read,
.write = do_sync_write,
.aio_write = generic_file_aio_write,
.mmap = fuse_file_mmap,
Expand Down
3 changes: 3 additions & 0 deletions trunk/fs/fuse/fuse_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -593,3 +593,6 @@ int fuse_valid_type(int m);
int fuse_allow_task(struct fuse_conn *fc, struct task_struct *task);

u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id);

int fuse_update_attributes(struct inode *inode, struct kstat *stat,
struct file *file, bool *refreshed);

0 comments on commit a2566a8

Please sign in to comment.