Skip to content

Commit e28d80f

Browse files
jankaraLinus Torvalds
authored andcommitted
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: Jan Kara <jack@suse.cz> Reported-by: Marcin Slusarz <marcin.slusarz@gmail.com> Tested-by: Marcin Slusarz <marcin.slusarz@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ac76cff commit e28d80f

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎fs/udf/dir.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ static int do_udf_readdir(struct inode *dir, struct file *filp,
4343
struct fileIdentDesc *fi = NULL;
4444
struct fileIdentDesc cfi;
4545
int block, iblock;
46-
loff_t nf_pos = filp->f_pos - 1;
46+
loff_t nf_pos = (filp->f_pos - 1) << 2;
4747
int flen;
4848
char fname[UDF_NAME_LEN];
4949
char *nameptr;
5050
uint16_t liu;
5151
uint8_t lfi;
52-
loff_t size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
52+
loff_t size = udf_ext0_offset(dir) + dir->i_size;
5353
struct buffer_head *tmp, *bha[16];
5454
kernel_lb_addr eloc;
5555
uint32_t elen;
@@ -63,13 +63,13 @@ static int do_udf_readdir(struct inode *dir, struct file *filp,
6363
return 0;
6464

6565
if (nf_pos == 0)
66-
nf_pos = (udf_ext0_offset(dir) >> 2);
66+
nf_pos = udf_ext0_offset(dir);
6767

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

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

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

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

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

0 commit comments

Comments
 (0)