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

Commit 03c3fa0a authored by Linus Torvalds's avatar Linus Torvalds
Browse files
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-udf-2.6:
  udf: Don't write integrity descriptor too often
  udf: Try anchor in block 256 first
  udf: Some type fixes and cleanups
  udf: use hardware sector size
  udf: fix novrs mount option
  udf: Fix oops when invalid character in filename occurs
  udf: return f_fsid for statfs(2)
  udf: Add checks to not underflow sector_t
  udf: fix default mode and dmode options handling
  udf: fix sparse warnings:
  udf: unsigned last[i] cannot be less than 0
  udf: implement mode and dmode mounting options
  udf: reduce stack usage of udf_get_filename
  udf: reduce stack usage of udf_load_pvoldesc
  Fix the udf code not to pass structs on stack where possible.
  Remove struct typedefs from fs/udf/ecma_167.h et al.
parents 3e850509 146bca72
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -24,6 +24,8 @@ The following mount options are supported:


	gid=		Set the default group.
	gid=		Set the default group.
	umask=		Set the default umask.
	umask=		Set the default umask.
	mode=		Set the default file permissions.
	dmode=		Set the default directory permissions.
	uid=		Set the default user.
	uid=		Set the default user.
	bs=		Set the block size.
	bs=		Set the block size.
	unhide		Show otherwise hidden files.
	unhide		Show otherwise hidden files.
+67 −83
Original line number Original line Diff line number Diff line
@@ -87,12 +87,12 @@ static int read_block_bitmap(struct super_block *sb,
{
{
	struct buffer_head *bh = NULL;
	struct buffer_head *bh = NULL;
	int retval = 0;
	int retval = 0;
	kernel_lb_addr loc;
	struct kernel_lb_addr loc;


	loc.logicalBlockNum = bitmap->s_extPosition;
	loc.logicalBlockNum = bitmap->s_extPosition;
	loc.partitionReferenceNum = UDF_SB(sb)->s_partition;
	loc.partitionReferenceNum = UDF_SB(sb)->s_partition;


	bh = udf_tread(sb, udf_get_lb_pblock(sb, loc, block));
	bh = udf_tread(sb, udf_get_lb_pblock(sb, &loc, block));
	if (!bh)
	if (!bh)
		retval = -EIO;
		retval = -EIO;


@@ -140,27 +140,29 @@ static inline int load_block_bitmap(struct super_block *sb,
	return slot;
	return slot;
}
}


static bool udf_add_free_space(struct udf_sb_info *sbi,
static void udf_add_free_space(struct super_block *sb, u16 partition, u32 cnt)
				u16 partition, u32 cnt)
{
{
	struct udf_sb_info *sbi = UDF_SB(sb);
	struct logicalVolIntegrityDesc *lvid;
	struct logicalVolIntegrityDesc *lvid;


	if (sbi->s_lvid_bh == NULL)
	if (!sbi->s_lvid_bh)
		return false;
		return;


	lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data;
	lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data;
	le32_add_cpu(&lvid->freeSpaceTable[partition], cnt);
	le32_add_cpu(&lvid->freeSpaceTable[partition], cnt);
	return true;
	udf_updated_lvid(sb);
}
}


static void udf_bitmap_free_blocks(struct super_block *sb,
static void udf_bitmap_free_blocks(struct super_block *sb,
				   struct inode *inode,
				   struct inode *inode,
				   struct udf_bitmap *bitmap,
				   struct udf_bitmap *bitmap,
				   kernel_lb_addr bloc, uint32_t offset,
				   struct kernel_lb_addr *bloc,
				   uint32_t offset,
				   uint32_t count)
				   uint32_t count)
{
{
	struct udf_sb_info *sbi = UDF_SB(sb);
	struct udf_sb_info *sbi = UDF_SB(sb);
	struct buffer_head *bh = NULL;
	struct buffer_head *bh = NULL;
	struct udf_part_map *partmap;
	unsigned long block;
	unsigned long block;
	unsigned long block_group;
	unsigned long block_group;
	unsigned long bit;
	unsigned long bit;
@@ -169,17 +171,17 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
	unsigned long overflow;
	unsigned long overflow;


	mutex_lock(&sbi->s_alloc_mutex);
	mutex_lock(&sbi->s_alloc_mutex);
	if (bloc.logicalBlockNum < 0 ||
	partmap = &sbi->s_partmaps[bloc->partitionReferenceNum];
	    (bloc.logicalBlockNum + count) >
	if (bloc->logicalBlockNum < 0 ||
		sbi->s_partmaps[bloc.partitionReferenceNum].s_partition_len) {
	    (bloc->logicalBlockNum + count) >
		partmap->s_partition_len) {
		udf_debug("%d < %d || %d + %d > %d\n",
		udf_debug("%d < %d || %d + %d > %d\n",
			  bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count,
			  bloc->logicalBlockNum, 0, bloc->logicalBlockNum,
			  sbi->s_partmaps[bloc.partitionReferenceNum].
			  count, partmap->s_partition_len);
							s_partition_len);
		goto error_return;
		goto error_return;
	}
	}


	block = bloc.logicalBlockNum + offset +
	block = bloc->logicalBlockNum + offset +
		(sizeof(struct spaceBitmapDesc) << 3);
		(sizeof(struct spaceBitmapDesc) << 3);


	do {
	do {
@@ -207,7 +209,7 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
			} else {
			} else {
				if (inode)
				if (inode)
					vfs_dq_free_block(inode, 1);
					vfs_dq_free_block(inode, 1);
				udf_add_free_space(sbi, sbi->s_partition, 1);
				udf_add_free_space(sb, sbi->s_partition, 1);
			}
			}
		}
		}
		mark_buffer_dirty(bh);
		mark_buffer_dirty(bh);
@@ -218,9 +220,6 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
	} while (overflow);
	} while (overflow);


error_return:
error_return:
	sb->s_dirt = 1;
	if (sbi->s_lvid_bh)
		mark_buffer_dirty(sbi->s_lvid_bh);
	mutex_unlock(&sbi->s_alloc_mutex);
	mutex_unlock(&sbi->s_alloc_mutex);
}
}


@@ -277,9 +276,7 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb,
	} while (block_count > 0);
	} while (block_count > 0);


out:
out:
	if (udf_add_free_space(sbi, partition, -alloc_count))
	udf_add_free_space(sb, partition, -alloc_count);
		mark_buffer_dirty(sbi->s_lvid_bh);
	sb->s_dirt = 1;
	mutex_unlock(&sbi->s_alloc_mutex);
	mutex_unlock(&sbi->s_alloc_mutex);
	return alloc_count;
	return alloc_count;
}
}
@@ -409,9 +406,7 @@ got_block:


	mark_buffer_dirty(bh);
	mark_buffer_dirty(bh);


	if (udf_add_free_space(sbi, partition, -1))
	udf_add_free_space(sb, partition, -1);
		mark_buffer_dirty(sbi->s_lvid_bh);
	sb->s_dirt = 1;
	mutex_unlock(&sbi->s_alloc_mutex);
	mutex_unlock(&sbi->s_alloc_mutex);
	*err = 0;
	*err = 0;
	return newblock;
	return newblock;
@@ -425,26 +420,28 @@ error_return:
static void udf_table_free_blocks(struct super_block *sb,
static void udf_table_free_blocks(struct super_block *sb,
				  struct inode *inode,
				  struct inode *inode,
				  struct inode *table,
				  struct inode *table,
				  kernel_lb_addr bloc, uint32_t offset,
				  struct kernel_lb_addr *bloc,
				  uint32_t offset,
				  uint32_t count)
				  uint32_t count)
{
{
	struct udf_sb_info *sbi = UDF_SB(sb);
	struct udf_sb_info *sbi = UDF_SB(sb);
	struct udf_part_map *partmap;
	uint32_t start, end;
	uint32_t start, end;
	uint32_t elen;
	uint32_t elen;
	kernel_lb_addr eloc;
	struct kernel_lb_addr eloc;
	struct extent_position oepos, epos;
	struct extent_position oepos, epos;
	int8_t etype;
	int8_t etype;
	int i;
	int i;
	struct udf_inode_info *iinfo;
	struct udf_inode_info *iinfo;


	mutex_lock(&sbi->s_alloc_mutex);
	mutex_lock(&sbi->s_alloc_mutex);
	if (bloc.logicalBlockNum < 0 ||
	partmap = &sbi->s_partmaps[bloc->partitionReferenceNum];
	    (bloc.logicalBlockNum + count) >
	if (bloc->logicalBlockNum < 0 ||
		sbi->s_partmaps[bloc.partitionReferenceNum].s_partition_len) {
	    (bloc->logicalBlockNum + count) >
		partmap->s_partition_len) {
		udf_debug("%d < %d || %d + %d > %d\n",
		udf_debug("%d < %d || %d + %d > %d\n",
			  bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count,
			  bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count,
			  sbi->s_partmaps[bloc.partitionReferenceNum].
			  partmap->s_partition_len);
							s_partition_len);
		goto error_return;
		goto error_return;
	}
	}


@@ -453,11 +450,10 @@ static void udf_table_free_blocks(struct super_block *sb,
	   could occure, but.. oh well */
	   could occure, but.. oh well */
	if (inode)
	if (inode)
		vfs_dq_free_block(inode, count);
		vfs_dq_free_block(inode, count);
	if (udf_add_free_space(sbi, sbi->s_partition, count))
	udf_add_free_space(sb, sbi->s_partition, count);
		mark_buffer_dirty(sbi->s_lvid_bh);


	start = bloc.logicalBlockNum + offset;
	start = bloc->logicalBlockNum + offset;
	end = bloc.logicalBlockNum + offset + count - 1;
	end = bloc->logicalBlockNum + offset + count - 1;


	epos.offset = oepos.offset = sizeof(struct unallocSpaceEntry);
	epos.offset = oepos.offset = sizeof(struct unallocSpaceEntry);
	elen = 0;
	elen = 0;
@@ -483,7 +479,7 @@ static void udf_table_free_blocks(struct super_block *sb,
				start += count;
				start += count;
				count = 0;
				count = 0;
			}
			}
			udf_write_aext(table, &oepos, eloc, elen, 1);
			udf_write_aext(table, &oepos, &eloc, elen, 1);
		} else if (eloc.logicalBlockNum == (end + 1)) {
		} else if (eloc.logicalBlockNum == (end + 1)) {
			if ((0x3FFFFFFF - elen) <
			if ((0x3FFFFFFF - elen) <
					(count << sb->s_blocksize_bits)) {
					(count << sb->s_blocksize_bits)) {
@@ -502,7 +498,7 @@ static void udf_table_free_blocks(struct super_block *sb,
				end -= count;
				end -= count;
				count = 0;
				count = 0;
			}
			}
			udf_write_aext(table, &oepos, eloc, elen, 1);
			udf_write_aext(table, &oepos, &eloc, elen, 1);
		}
		}


		if (epos.bh != oepos.bh) {
		if (epos.bh != oepos.bh) {
@@ -532,8 +528,8 @@ static void udf_table_free_blocks(struct super_block *sb,
		 */
		 */


		int adsize;
		int adsize;
		short_ad *sad = NULL;
		struct short_ad *sad = NULL;
		long_ad *lad = NULL;
		struct long_ad *lad = NULL;
		struct allocExtDesc *aed;
		struct allocExtDesc *aed;


		eloc.logicalBlockNum = start;
		eloc.logicalBlockNum = start;
@@ -541,9 +537,9 @@ static void udf_table_free_blocks(struct super_block *sb,
			(count << sb->s_blocksize_bits);
			(count << sb->s_blocksize_bits);


		if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
		if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
			adsize = sizeof(short_ad);
			adsize = sizeof(struct short_ad);
		else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
		else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
			adsize = sizeof(long_ad);
			adsize = sizeof(struct long_ad);
		else {
		else {
			brelse(oepos.bh);
			brelse(oepos.bh);
			brelse(epos.bh);
			brelse(epos.bh);
@@ -563,7 +559,7 @@ static void udf_table_free_blocks(struct super_block *sb,
			elen -= sb->s_blocksize;
			elen -= sb->s_blocksize;


			epos.bh = udf_tread(sb,
			epos.bh = udf_tread(sb,
					udf_get_lb_pblock(sb, epos.block, 0));
					udf_get_lb_pblock(sb, &epos.block, 0));
			if (!epos.bh) {
			if (!epos.bh) {
				brelse(oepos.bh);
				brelse(oepos.bh);
				goto error_return;
				goto error_return;
@@ -601,15 +597,15 @@ static void udf_table_free_blocks(struct super_block *sb,
			if (sbi->s_udfrev >= 0x0200)
			if (sbi->s_udfrev >= 0x0200)
				udf_new_tag(epos.bh->b_data, TAG_IDENT_AED,
				udf_new_tag(epos.bh->b_data, TAG_IDENT_AED,
					    3, 1, epos.block.logicalBlockNum,
					    3, 1, epos.block.logicalBlockNum,
					    sizeof(tag));
					    sizeof(struct tag));
			else
			else
				udf_new_tag(epos.bh->b_data, TAG_IDENT_AED,
				udf_new_tag(epos.bh->b_data, TAG_IDENT_AED,
					    2, 1, epos.block.logicalBlockNum,
					    2, 1, epos.block.logicalBlockNum,
					    sizeof(tag));
					    sizeof(struct tag));


			switch (iinfo->i_alloc_type) {
			switch (iinfo->i_alloc_type) {
			case ICBTAG_FLAG_AD_SHORT:
			case ICBTAG_FLAG_AD_SHORT:
				sad = (short_ad *)sptr;
				sad = (struct short_ad *)sptr;
				sad->extLength = cpu_to_le32(
				sad->extLength = cpu_to_le32(
					EXT_NEXT_EXTENT_ALLOCDECS |
					EXT_NEXT_EXTENT_ALLOCDECS |
					sb->s_blocksize);
					sb->s_blocksize);
@@ -617,7 +613,7 @@ static void udf_table_free_blocks(struct super_block *sb,
					cpu_to_le32(epos.block.logicalBlockNum);
					cpu_to_le32(epos.block.logicalBlockNum);
				break;
				break;
			case ICBTAG_FLAG_AD_LONG:
			case ICBTAG_FLAG_AD_LONG:
				lad = (long_ad *)sptr;
				lad = (struct long_ad *)sptr;
				lad->extLength = cpu_to_le32(
				lad->extLength = cpu_to_le32(
					EXT_NEXT_EXTENT_ALLOCDECS |
					EXT_NEXT_EXTENT_ALLOCDECS |
					sb->s_blocksize);
					sb->s_blocksize);
@@ -635,7 +631,7 @@ static void udf_table_free_blocks(struct super_block *sb,


		/* It's possible that stealing the block emptied the extent */
		/* It's possible that stealing the block emptied the extent */
		if (elen) {
		if (elen) {
			udf_write_aext(table, &epos, eloc, elen, 1);
			udf_write_aext(table, &epos, &eloc, elen, 1);


			if (!epos.bh) {
			if (!epos.bh) {
				iinfo->i_lenAlloc += adsize;
				iinfo->i_lenAlloc += adsize;
@@ -653,7 +649,6 @@ static void udf_table_free_blocks(struct super_block *sb,
	brelse(oepos.bh);
	brelse(oepos.bh);


error_return:
error_return:
	sb->s_dirt = 1;
	mutex_unlock(&sbi->s_alloc_mutex);
	mutex_unlock(&sbi->s_alloc_mutex);
	return;
	return;
}
}
@@ -666,7 +661,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
	struct udf_sb_info *sbi = UDF_SB(sb);
	struct udf_sb_info *sbi = UDF_SB(sb);
	int alloc_count = 0;
	int alloc_count = 0;
	uint32_t elen, adsize;
	uint32_t elen, adsize;
	kernel_lb_addr eloc;
	struct kernel_lb_addr eloc;
	struct extent_position epos;
	struct extent_position epos;
	int8_t etype = -1;
	int8_t etype = -1;
	struct udf_inode_info *iinfo;
	struct udf_inode_info *iinfo;
@@ -677,9 +672,9 @@ static int udf_table_prealloc_blocks(struct super_block *sb,


	iinfo = UDF_I(table);
	iinfo = UDF_I(table);
	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
		adsize = sizeof(short_ad);
		adsize = sizeof(struct short_ad);
	else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
	else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
		adsize = sizeof(long_ad);
		adsize = sizeof(struct long_ad);
	else
	else
		return 0;
		return 0;


@@ -707,7 +702,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
			alloc_count = block_count;
			alloc_count = block_count;
			eloc.logicalBlockNum += alloc_count;
			eloc.logicalBlockNum += alloc_count;
			elen -= (alloc_count << sb->s_blocksize_bits);
			elen -= (alloc_count << sb->s_blocksize_bits);
			udf_write_aext(table, &epos, eloc,
			udf_write_aext(table, &epos, &eloc,
					(etype << 30) | elen, 1);
					(etype << 30) | elen, 1);
		} else
		} else
			udf_delete_aext(table, epos, eloc,
			udf_delete_aext(table, epos, eloc,
@@ -718,10 +713,8 @@ static int udf_table_prealloc_blocks(struct super_block *sb,


	brelse(epos.bh);
	brelse(epos.bh);


	if (alloc_count && udf_add_free_space(sbi, partition, -alloc_count)) {
	if (alloc_count)
		mark_buffer_dirty(sbi->s_lvid_bh);
		udf_add_free_space(sb, partition, -alloc_count);
		sb->s_dirt = 1;
	}
	mutex_unlock(&sbi->s_alloc_mutex);
	mutex_unlock(&sbi->s_alloc_mutex);
	return alloc_count;
	return alloc_count;
}
}
@@ -735,7 +728,7 @@ static int udf_table_new_block(struct super_block *sb,
	uint32_t spread = 0xFFFFFFFF, nspread = 0xFFFFFFFF;
	uint32_t spread = 0xFFFFFFFF, nspread = 0xFFFFFFFF;
	uint32_t newblock = 0, adsize;
	uint32_t newblock = 0, adsize;
	uint32_t elen, goal_elen = 0;
	uint32_t elen, goal_elen = 0;
	kernel_lb_addr eloc, uninitialized_var(goal_eloc);
	struct kernel_lb_addr eloc, uninitialized_var(goal_eloc);
	struct extent_position epos, goal_epos;
	struct extent_position epos, goal_epos;
	int8_t etype;
	int8_t etype;
	struct udf_inode_info *iinfo = UDF_I(table);
	struct udf_inode_info *iinfo = UDF_I(table);
@@ -743,9 +736,9 @@ static int udf_table_new_block(struct super_block *sb,
	*err = -ENOSPC;
	*err = -ENOSPC;


	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
		adsize = sizeof(short_ad);
		adsize = sizeof(struct short_ad);
	else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
	else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
		adsize = sizeof(long_ad);
		adsize = sizeof(struct long_ad);
	else
	else
		return newblock;
		return newblock;


@@ -814,46 +807,37 @@ static int udf_table_new_block(struct super_block *sb,
	}
	}


	if (goal_elen)
	if (goal_elen)
		udf_write_aext(table, &goal_epos, goal_eloc, goal_elen, 1);
		udf_write_aext(table, &goal_epos, &goal_eloc, goal_elen, 1);
	else
	else
		udf_delete_aext(table, goal_epos, goal_eloc, goal_elen);
		udf_delete_aext(table, goal_epos, goal_eloc, goal_elen);
	brelse(goal_epos.bh);
	brelse(goal_epos.bh);


	if (udf_add_free_space(sbi, partition, -1))
	udf_add_free_space(sb, partition, -1);
		mark_buffer_dirty(sbi->s_lvid_bh);


	sb->s_dirt = 1;
	mutex_unlock(&sbi->s_alloc_mutex);
	mutex_unlock(&sbi->s_alloc_mutex);
	*err = 0;
	*err = 0;
	return newblock;
	return newblock;
}
}


inline void udf_free_blocks(struct super_block *sb,
void udf_free_blocks(struct super_block *sb, struct inode *inode,
			    struct inode *inode,
		     struct kernel_lb_addr *bloc, uint32_t offset,
			    kernel_lb_addr bloc, uint32_t offset,
		     uint32_t count)
		     uint32_t count)
{
{
	uint16_t partition = bloc.partitionReferenceNum;
	uint16_t partition = bloc->partitionReferenceNum;
	struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition];
	struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition];


	if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) {
	if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) {
		return udf_bitmap_free_blocks(sb, inode,
		udf_bitmap_free_blocks(sb, inode, map->s_uspace.s_bitmap,
					      map->s_uspace.s_bitmap,
				       bloc, offset, count);
				       bloc, offset, count);
	} else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) {
	} else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) {
		return udf_table_free_blocks(sb, inode,
		udf_table_free_blocks(sb, inode, map->s_uspace.s_table,
					     map->s_uspace.s_table,
				      bloc, offset, count);
				      bloc, offset, count);
	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) {
	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) {
		return udf_bitmap_free_blocks(sb, inode,
		udf_bitmap_free_blocks(sb, inode, map->s_fspace.s_bitmap,
					      map->s_fspace.s_bitmap,
				       bloc, offset, count);
				       bloc, offset, count);
	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) {
	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) {
		return udf_table_free_blocks(sb, inode,
		udf_table_free_blocks(sb, inode, map->s_fspace.s_table,
					     map->s_fspace.s_table,
				      bloc, offset, count);
				      bloc, offset, count);
	} else {
		return;
	}
	}
}
}


+7 −7
Original line number Original line Diff line number Diff line
@@ -51,7 +51,7 @@ static int do_udf_readdir(struct inode *dir, struct file *filp,
	uint8_t lfi;
	uint8_t lfi;
	loff_t size = udf_ext0_offset(dir) + dir->i_size;
	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;
	struct kernel_lb_addr eloc;
	uint32_t elen;
	uint32_t elen;
	sector_t offset;
	sector_t offset;
	int i, num, ret = 0;
	int i, num, ret = 0;
@@ -80,13 +80,13 @@ static int do_udf_readdir(struct inode *dir, struct file *filp,
			ret = -ENOENT;
			ret = -ENOENT;
			goto out;
			goto out;
		}
		}
		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) {
			if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
			if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
				epos.offset -= sizeof(short_ad);
				epos.offset -= sizeof(struct short_ad);
			else if (iinfo->i_alloc_type ==
			else if (iinfo->i_alloc_type ==
					ICBTAG_FLAG_AD_LONG)
					ICBTAG_FLAG_AD_LONG)
				epos.offset -= sizeof(long_ad);
				epos.offset -= sizeof(struct long_ad);
		} else {
		} else {
			offset = 0;
			offset = 0;
		}
		}
@@ -101,7 +101,7 @@ static int do_udf_readdir(struct inode *dir, struct file *filp,
			if (i + offset > (elen >> dir->i_sb->s_blocksize_bits))
			if (i + offset > (elen >> dir->i_sb->s_blocksize_bits))
				i = (elen >> dir->i_sb->s_blocksize_bits) - offset;
				i = (elen >> dir->i_sb->s_blocksize_bits) - offset;
			for (num = 0; i > 0; i--) {
			for (num = 0; i > 0; i--) {
				block = udf_get_lb_pblock(dir->i_sb, eloc, offset + i);
				block = udf_get_lb_pblock(dir->i_sb, &eloc, offset + i);
				tmp = udf_tgetblk(dir->i_sb, block);
				tmp = udf_tgetblk(dir->i_sb, block);
				if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp))
				if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp))
					bha[num++] = tmp;
					bha[num++] = tmp;
@@ -161,9 +161,9 @@ static int do_udf_readdir(struct inode *dir, struct file *filp,
			memcpy(fname, "..", flen);
			memcpy(fname, "..", flen);
			dt_type = DT_DIR;
			dt_type = DT_DIR;
		} else {
		} else {
			kernel_lb_addr tloc = lelb_to_cpu(cfi.icb.extLocation);
			struct kernel_lb_addr tloc = lelb_to_cpu(cfi.icb.extLocation);


			iblock = udf_get_lb_pblock(dir->i_sb, tloc, 0);
			iblock = udf_get_lb_pblock(dir->i_sb, &tloc, 0);
			flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi);
			flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi);
			dt_type = DT_UNKNOWN;
			dt_type = DT_UNKNOWN;
		}
		}
+19 −19
Original line number Original line Diff line number Diff line
@@ -20,7 +20,7 @@


#if 0
#if 0
static uint8_t *udf_filead_read(struct inode *dir, uint8_t *tmpad,
static uint8_t *udf_filead_read(struct inode *dir, uint8_t *tmpad,
				uint8_t ad_size, kernel_lb_addr fe_loc,
				uint8_t ad_size, struct kernel_lb_addr fe_loc,
				int *pos, int *offset, struct buffer_head **bh,
				int *pos, int *offset, struct buffer_head **bh,
				int *error)
				int *error)
{
{
@@ -75,7 +75,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
					 struct udf_fileident_bh *fibh,
					 struct udf_fileident_bh *fibh,
					 struct fileIdentDesc *cfi,
					 struct fileIdentDesc *cfi,
					 struct extent_position *epos,
					 struct extent_position *epos,
					 kernel_lb_addr *eloc, uint32_t *elen,
					 struct kernel_lb_addr *eloc, uint32_t *elen,
					 sector_t *offset)
					 sector_t *offset)
{
{
	struct fileIdentDesc *fi;
	struct fileIdentDesc *fi;
@@ -111,7 +111,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
		    (EXT_RECORDED_ALLOCATED >> 30))
		    (EXT_RECORDED_ALLOCATED >> 30))
			return NULL;
			return NULL;


		block = udf_get_lb_pblock(dir->i_sb, *eloc, *offset);
		block = udf_get_lb_pblock(dir->i_sb, eloc, *offset);


		(*offset)++;
		(*offset)++;


@@ -131,7 +131,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
			if (i + *offset > (*elen >> blocksize_bits))
			if (i + *offset > (*elen >> blocksize_bits))
				i = (*elen >> blocksize_bits)-*offset;
				i = (*elen >> blocksize_bits)-*offset;
			for (num = 0; i > 0; i--) {
			for (num = 0; i > 0; i--) {
				block = udf_get_lb_pblock(dir->i_sb, *eloc,
				block = udf_get_lb_pblock(dir->i_sb, eloc,
							  *offset + i);
							  *offset + i);
				tmp = udf_tgetblk(dir->i_sb, block);
				tmp = udf_tgetblk(dir->i_sb, block);
				if (tmp && !buffer_uptodate(tmp) &&
				if (tmp && !buffer_uptodate(tmp) &&
@@ -169,7 +169,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
		    (EXT_RECORDED_ALLOCATED >> 30))
		    (EXT_RECORDED_ALLOCATED >> 30))
			return NULL;
			return NULL;


		block = udf_get_lb_pblock(dir->i_sb, *eloc, *offset);
		block = udf_get_lb_pblock(dir->i_sb, eloc, *offset);


		(*offset)++;
		(*offset)++;


@@ -249,9 +249,9 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
}
}


#if 0
#if 0
static extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset)
static struct extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset)
{
{
	extent_ad *ext;
	struct extent_ad *ext;
	struct fileEntry *fe;
	struct fileEntry *fe;
	uint8_t *ptr;
	uint8_t *ptr;


@@ -274,54 +274,54 @@ static extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset)
	if ((*offset > 0) && (*offset < le32_to_cpu(fe->lengthAllocDescs)))
	if ((*offset > 0) && (*offset < le32_to_cpu(fe->lengthAllocDescs)))
		ptr += *offset;
		ptr += *offset;


	ext = (extent_ad *)ptr;
	ext = (struct extent_ad *)ptr;


	*offset = *offset + sizeof(extent_ad);
	*offset = *offset + sizeof(struct extent_ad);
	return ext;
	return ext;
}
}
#endif
#endif


short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offset,
struct short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offset,
			      int inc)
			      int inc)
{
{
	short_ad *sa;
	struct short_ad *sa;


	if ((!ptr) || (!offset)) {
	if ((!ptr) || (!offset)) {
		printk(KERN_ERR "udf: udf_get_fileshortad() invalidparms\n");
		printk(KERN_ERR "udf: udf_get_fileshortad() invalidparms\n");
		return NULL;
		return NULL;
	}
	}


	if ((*offset + sizeof(short_ad)) > maxoffset)
	if ((*offset + sizeof(struct short_ad)) > maxoffset)
		return NULL;
		return NULL;
	else {
	else {
		sa = (short_ad *)ptr;
		sa = (struct short_ad *)ptr;
		if (sa->extLength == 0)
		if (sa->extLength == 0)
			return NULL;
			return NULL;
	}
	}


	if (inc)
	if (inc)
		*offset += sizeof(short_ad);
		*offset += sizeof(struct short_ad);
	return sa;
	return sa;
}
}


long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, uint32_t *offset, int inc)
struct long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, uint32_t *offset, int inc)
{
{
	long_ad *la;
	struct long_ad *la;


	if ((!ptr) || (!offset)) {
	if ((!ptr) || (!offset)) {
		printk(KERN_ERR "udf: udf_get_filelongad() invalidparms\n");
		printk(KERN_ERR "udf: udf_get_filelongad() invalidparms\n");
		return NULL;
		return NULL;
	}
	}


	if ((*offset + sizeof(long_ad)) > maxoffset)
	if ((*offset + sizeof(struct long_ad)) > maxoffset)
		return NULL;
		return NULL;
	else {
	else {
		la = (long_ad *)ptr;
		la = (struct long_ad *)ptr;
		if (la->extLength == 0)
		if (la->extLength == 0)
			return NULL;
			return NULL;
	}
	}


	if (inc)
	if (inc)
		*offset += sizeof(long_ad);
		*offset += sizeof(struct long_ad);
	return la;
	return la;
}
}
+208 −208

File changed.

Preview size limit exceeded, changes collapsed.

Loading