Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 034f8648 authored by Daniel Rosenberg's avatar Daniel Rosenberg
Browse files

ANDROID: sdcardfs: fix ->llseek to update upper and lower offset



Adapted from wrapfs
commit 1d1d23a47baa ("Wrapfs: fix ->llseek to update upper and lower
offsets")

Fixes bug: xfstests generic/257. f_pos consistently is required by and
only by dir_ops->wrapfs_readdir, main_ops is not affected.

Signed-off-by: default avatarErez Zadok <ezk@cs.sunysb.edu>
Signed-off-by: default avatarMengyang Li <li.mengyang@stonybrook.edu>
Signed-off-by: default avatarDaniel Rosenberg <drosen@google.com>
Bug: 35766959
Change-Id: I360a1368ac37ea8966910a58972b81504031d437
parent be35f037
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -316,6 +316,29 @@ static int sdcardfs_fasync(int fd, struct file *file, int flag)
	return err;
}

/*
 * Sdcardfs cannot use generic_file_llseek as ->llseek, because it would
 * only set the offset of the upper file.  So we have to implement our
 * own method to set both the upper and lower file offsets
 * consistently.
 */
static loff_t sdcardfs_file_llseek(struct file *file, loff_t offset, int whence)
{
	int err;
	struct file *lower_file;

	err = generic_file_llseek(file, offset, whence);
	if (err < 0)
		goto out;

	lower_file = sdcardfs_lower_file(file);
	err = generic_file_llseek(lower_file, offset, whence);

out:
	return err;
}


const struct file_operations sdcardfs_main_fops = {
	.llseek		= generic_file_llseek,
	.read		= sdcardfs_read,
@@ -334,7 +357,7 @@ const struct file_operations sdcardfs_main_fops = {

/* trimmed directory options */
const struct file_operations sdcardfs_dir_fops = {
	.llseek		= generic_file_llseek,
	.llseek		= sdcardfs_file_llseek,
	.read		= generic_read_dir,
	.iterate	= sdcardfs_readdir,
	.unlocked_ioctl	= sdcardfs_unlocked_ioctl,