From 0bfc428d4500c4ca9e27db11422184eac456fb2f Mon Sep 17 00:00:00 2001 From: wangwang Date: Thu, 28 Mar 2019 11:27:36 +0800 Subject: [PATCH] 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 --- fs/sdcardfs/file.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) 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, -- 2.20.1