Merge tag 'v3.10.103' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / ubifs / file.c
index a335e4e6aba1f10b43b16eccac05558b9f93a40b..4a624c01a2e2ea6f9a4e65c2fc3d934b5ae8b10d 100644 (file)
@@ -80,6 +80,10 @@ static int read_block(struct inode *inode, void *addr, unsigned int block,
                goto dump;
 
        dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;
+
+       if (UBIFS_COMPR_LZ4K ==  le16_to_cpu(dn->compr_type))
+         out_len = len; //Jack modify for lz4k decompress      
+       else
        out_len = UBIFS_BLOCK_SIZE;
        err = ubifs_decompress(&dn->data, dlen, addr, &out_len,
                               le16_to_cpu(dn->compr_type));
@@ -649,6 +653,10 @@ static int populate_page(struct ubifs_info *c, struct page *page,
                                goto out_err;
 
                        dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;
+                       
+                       if (UBIFS_COMPR_LZ4K ==  le16_to_cpu(dn->compr_type))                           
+                         out_len = len; //Jack modify for lz4k decompress      
+                       else
                        out_len = UBIFS_BLOCK_SIZE;
                        err = ubifs_decompress(&dn->data, dlen, addr, &out_len,
                                               le16_to_cpu(dn->compr_type));
@@ -1572,6 +1580,31 @@ static int ubifs_file_mmap(struct file *file, struct vm_area_struct *vma)
        return 0;
 }
 
+//MTK add for cts
+long ubifs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
+{
+       int err;
+       struct inode *inode = file->f_mapping->host;
+       struct ubifs_info *c = inode->i_sb->s_fs_info;
+       struct iattr newattrs;
+
+       loff_t new_len = offset + len;
+       if (len < 0 || offset < 0)
+               return -EINVAL;
+
+       if(new_len < inode->i_size)
+               return -EINVAL;
+       
+       newattrs.ia_size = new_len;
+        newattrs.ia_valid = ATTR_SIZE | ATTR_MTIME|ATTR_CTIME;
+       newattrs.ia_file = file;
+       newattrs.ia_valid |= ATTR_FILE;
+
+       
+       err = do_setattr(c, inode, &newattrs);
+       return err;
+}
+
 const struct address_space_operations ubifs_file_address_operations = {
        .readpage       = ubifs_readpage,
        .writepage      = ubifs_writepage,
@@ -1599,6 +1632,10 @@ const struct inode_operations ubifs_symlink_inode_operations = {
        .follow_link = ubifs_follow_link,
        .setattr     = ubifs_setattr,
        .getattr     = ubifs_getattr,
+       .setxattr    = ubifs_setxattr,
+       .getxattr    = ubifs_getxattr,
+       .listxattr   = ubifs_listxattr,
+       .removexattr = ubifs_removexattr,
 };
 
 const struct file_operations ubifs_file_operations = {
@@ -1615,4 +1652,5 @@ const struct file_operations ubifs_file_operations = {
 #ifdef CONFIG_COMPAT
        .compat_ioctl   = ubifs_compat_ioctl,
 #endif
+        .fallocate      = ubifs_fallocate,
 };