Merge branch 'for-linus/samsung-2635' of git://git.fluff.org/bjdooks/linux
[cascardo/linux.git] / fs / omfs / file.c
index 810cff3..8a6d34f 100644 (file)
@@ -50,7 +50,7 @@ int omfs_shrink_inode(struct inode *inode)
        if (inode->i_size != 0)
                goto out;
 
-       bh = sb_bread(inode->i_sb, clus_to_blk(sbi, next));
+       bh = omfs_bread(inode->i_sb, next);
        if (!bh)
                goto out;
 
@@ -90,7 +90,7 @@ int omfs_shrink_inode(struct inode *inode)
                if (next == ~0)
                        break;
 
-               bh = sb_bread(inode->i_sb, clus_to_blk(sbi, next));
+               bh = omfs_bread(inode->i_sb, next);
                if (!bh)
                        goto out;
                oe = (struct omfs_extent *) (&bh->b_data[OMFS_EXTENT_CONT]);
@@ -222,7 +222,7 @@ static int omfs_get_block(struct inode *inode, sector_t block,
        struct buffer_head *bh;
        sector_t next, offset;
        int ret;
-       u64 new_block;
+       u64 uninitialized_var(new_block);
        u32 max_extents;
        int extent_count;
        struct omfs_extent *oe;
@@ -232,7 +232,7 @@ static int omfs_get_block(struct inode *inode, sector_t block,
        int remain;
 
        ret = -EIO;
-       bh = sb_bread(inode->i_sb, clus_to_blk(sbi, inode->i_ino));
+       bh = omfs_bread(inode->i_sb, inode->i_ino);
        if (!bh)
                goto out;
 
@@ -265,7 +265,7 @@ static int omfs_get_block(struct inode *inode, sector_t block,
                        break;
 
                brelse(bh);
-               bh = sb_bread(inode->i_sb, clus_to_blk(sbi, next));
+               bh = omfs_bread(inode->i_sb, next);
                if (!bh)
                        goto out;
                oe = (struct omfs_extent *) (&bh->b_data[OMFS_EXTENT_CONT]);
@@ -341,7 +341,29 @@ const struct file_operations omfs_file_operations = {
        .splice_read = generic_file_splice_read,
 };
 
+static int omfs_setattr(struct dentry *dentry, struct iattr *attr)
+{
+       struct inode *inode = dentry->d_inode;
+       int error;
+
+       error = inode_change_ok(inode, attr);
+       if (error)
+               return error;
+
+       if ((attr->ia_valid & ATTR_SIZE) &&
+           attr->ia_size != i_size_read(inode)) {
+               error = vmtruncate(inode, attr->ia_size);
+               if (error)
+                       return error;
+       }
+
+       setattr_copy(inode, attr);
+       mark_inode_dirty(inode);
+       return 0;
+}
+
 const struct inode_operations omfs_file_inops = {
+       .setattr = omfs_setattr,
        .truncate = omfs_truncate
 };