From: wangwang Date: Thu, 28 Mar 2019 03:27:36 +0000 (+0800) Subject: kernel:fs:update inode size when do lseek X-Git-Tag: MMI-QSAS30.62-33-3~170 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=67a68e1868d4ecba2b91416685e19967fda8063b;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git kernel:fs:update inode size when do lseek sdcardfs file node info was not updated when lowlevel file was updated force to update the inode size when do lseek systemcall Change-Id: I34802cc33f5cddd9dd8d304c5803cd0886805faf Signed-off-by: wangwang Reviewed-on: https://gerrit.mot.com/1328861 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- diff --git a/fs/sdcardfs/file.c b/fs/sdcardfs/file.c index 271c4c4cb760..1ec39fd02bf0 100644 --- a/fs/sdcardfs/file.c +++ b/fs/sdcardfs/file.c @@ -372,6 +372,29 @@ out: return err; } +static loff_t sdcardfs_wrapper_file_llseek(struct file *file, loff_t offset, int whence) +{ + loff_t pos; + struct dentry *dentry = file->f_path.dentry; + struct inode *inode = d_inode(dentry); + struct file *lower_file; + + lower_file = sdcardfs_lower_file(file); + + if (lower_file) { + if (sizeof(loff_t) > sizeof(long)) + inode_lock(inode); + fsstack_copy_inode_size(inode, file_inode(lower_file)); + fsstack_copy_attr_times(inode, file_inode(lower_file)); + if (sizeof(loff_t) > sizeof(long)) + inode_unlock(inode); + } + pos = generic_file_llseek(file, offset, whence); +// printk(KERN_ERR "sdcardfs file llseek %s, whence: %lld, returns:%lld\n", dentry->d_name.name, whence, pos); + + return pos; +} + /* * Sdcardfs read_iter, redirect modified iocb to lower read_iter */ @@ -433,7 +456,7 @@ out: } const struct file_operations sdcardfs_main_fops = { - .llseek = generic_file_llseek, + .llseek = sdcardfs_wrapper_file_llseek, .read = sdcardfs_read, .write = sdcardfs_write, .unlocked_ioctl = sdcardfs_unlocked_ioctl,