udf: Convert empty_dir() to new directory iteration code
Convert empty_dir() to new directory iteration code. Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
parent
9b06fbef42
commit
afb525f466
|
@ -869,69 +869,19 @@ out:
|
|||
|
||||
static int empty_dir(struct inode *dir)
|
||||
{
|
||||
struct fileIdentDesc *fi, cfi;
|
||||
struct udf_fileident_bh fibh;
|
||||
loff_t f_pos;
|
||||
loff_t size = udf_ext0_offset(dir) + dir->i_size;
|
||||
udf_pblk_t block;
|
||||
struct kernel_lb_addr eloc;
|
||||
uint32_t elen;
|
||||
sector_t offset;
|
||||
struct extent_position epos = {};
|
||||
struct udf_inode_info *dinfo = UDF_I(dir);
|
||||
struct udf_fileident_iter iter;
|
||||
int ret;
|
||||
|
||||
f_pos = udf_ext0_offset(dir);
|
||||
fibh.soffset = fibh.eoffset = f_pos & (dir->i_sb->s_blocksize - 1);
|
||||
|
||||
if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB)
|
||||
fibh.sbh = fibh.ebh = NULL;
|
||||
else if (inode_bmap(dir, f_pos >> dir->i_sb->s_blocksize_bits,
|
||||
&epos, &eloc, &elen, &offset) ==
|
||||
(EXT_RECORDED_ALLOCATED >> 30)) {
|
||||
block = udf_get_lb_pblock(dir->i_sb, &eloc, offset);
|
||||
if ((++offset << dir->i_sb->s_blocksize_bits) < elen) {
|
||||
if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
|
||||
epos.offset -= sizeof(struct short_ad);
|
||||
else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
|
||||
epos.offset -= sizeof(struct long_ad);
|
||||
} else
|
||||
offset = 0;
|
||||
|
||||
fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block);
|
||||
if (!fibh.sbh) {
|
||||
brelse(epos.bh);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
brelse(epos.bh);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (f_pos < size) {
|
||||
fi = udf_fileident_read(dir, &f_pos, &fibh, &cfi, &epos, &eloc,
|
||||
&elen, &offset);
|
||||
if (!fi) {
|
||||
if (fibh.sbh != fibh.ebh)
|
||||
brelse(fibh.ebh);
|
||||
brelse(fibh.sbh);
|
||||
brelse(epos.bh);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (cfi.lengthFileIdent &&
|
||||
(cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) == 0) {
|
||||
if (fibh.sbh != fibh.ebh)
|
||||
brelse(fibh.ebh);
|
||||
brelse(fibh.sbh);
|
||||
brelse(epos.bh);
|
||||
for (ret = udf_fiiter_init(&iter, dir, 0);
|
||||
!ret && iter.pos < dir->i_size;
|
||||
ret = udf_fiiter_advance(&iter)) {
|
||||
if (iter.fi.lengthFileIdent &&
|
||||
!(iter.fi.fileCharacteristics & FID_FILE_CHAR_DELETED)) {
|
||||
udf_fiiter_release(&iter);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (fibh.sbh != fibh.ebh)
|
||||
brelse(fibh.ebh);
|
||||
brelse(fibh.sbh);
|
||||
brelse(epos.bh);
|
||||
udf_fiiter_release(&iter);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue