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

Commit e28d80f1 authored by Jan Kara's avatar Jan Kara Committed by Linus Torvalds
Browse files

udf: fix directory offset handling



Patch cleaning up UDF directory offset handling missed modifications in dir.c
(because I've submitted an old version :(). Fix it.

Signed-off-by: default avatarJan Kara <jack@suse.cz>
Reported-by: default avatarMarcin Slusarz <marcin.slusarz@gmail.com>
Tested-by: default avatarMarcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ac76cff2
Loading
Loading
Loading
Loading
+7 −7
Original line number Original line Diff line number Diff line
@@ -43,13 +43,13 @@ static int do_udf_readdir(struct inode *dir, struct file *filp,
	struct fileIdentDesc *fi = NULL;
	struct fileIdentDesc *fi = NULL;
	struct fileIdentDesc cfi;
	struct fileIdentDesc cfi;
	int block, iblock;
	int block, iblock;
	loff_t nf_pos = filp->f_pos - 1;
	loff_t nf_pos = (filp->f_pos - 1) << 2;
	int flen;
	int flen;
	char fname[UDF_NAME_LEN];
	char fname[UDF_NAME_LEN];
	char *nameptr;
	char *nameptr;
	uint16_t liu;
	uint16_t liu;
	uint8_t lfi;
	uint8_t lfi;
	loff_t size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
	loff_t size = udf_ext0_offset(dir) + dir->i_size;
	struct buffer_head *tmp, *bha[16];
	struct buffer_head *tmp, *bha[16];
	kernel_lb_addr eloc;
	kernel_lb_addr eloc;
	uint32_t elen;
	uint32_t elen;
@@ -63,13 +63,13 @@ static int do_udf_readdir(struct inode *dir, struct file *filp,
		return 0;
		return 0;


	if (nf_pos == 0)
	if (nf_pos == 0)
		nf_pos = (udf_ext0_offset(dir) >> 2);
		nf_pos = udf_ext0_offset(dir);


	fibh.soffset = fibh.eoffset = (nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
	fibh.soffset = fibh.eoffset = nf_pos & (dir->i_sb->s_blocksize - 1);
	iinfo = UDF_I(dir);
	iinfo = UDF_I(dir);
	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
		fibh.sbh = fibh.ebh = NULL;
		fibh.sbh = fibh.ebh = NULL;
	} else if (inode_bmap(dir, nf_pos >> (dir->i_sb->s_blocksize_bits - 2),
	} else if (inode_bmap(dir, nf_pos >> dir->i_sb->s_blocksize_bits,
			      &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
			      &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
		block = udf_get_lb_pblock(dir->i_sb, eloc, offset);
		block = udf_get_lb_pblock(dir->i_sb, eloc, offset);
		if ((++offset << dir->i_sb->s_blocksize_bits) < elen) {
		if ((++offset << dir->i_sb->s_blocksize_bits) < elen) {
@@ -111,7 +111,7 @@ static int do_udf_readdir(struct inode *dir, struct file *filp,
	}
	}


	while (nf_pos < size) {
	while (nf_pos < size) {
		filp->f_pos = nf_pos + 1;
		filp->f_pos = (nf_pos >> 2) + 1;


		fi = udf_fileident_read(dir, &nf_pos, &fibh, &cfi, &epos, &eloc,
		fi = udf_fileident_read(dir, &nf_pos, &fibh, &cfi, &epos, &eloc,
					&elen, &offset);
					&elen, &offset);
@@ -178,7 +178,7 @@ static int do_udf_readdir(struct inode *dir, struct file *filp,
		}
		}
	} /* end while */
	} /* end while */


	filp->f_pos = nf_pos + 1;
	filp->f_pos = (nf_pos >> 2) + 1;


	if (fibh.sbh != fibh.ebh)
	if (fibh.sbh != fibh.ebh)
		brelse(fibh.ebh);
		brelse(fibh.ebh);