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

Commit 4b11111a authored by Marcin Slusarz's avatar Marcin Slusarz Committed by Linus Torvalds
Browse files

udf: fix coding style



fix coding style errors found by checkpatch:
- assignments in if conditions
- braces {} around single statement blocks
- no spaces after commas
- printks without KERN_*
- lines longer than 80 characters
- spaces between "type *" and variable name

before: 192 errors, 561 warnings, 8987 lines checked
after: 1 errors, 38 warnings, 9468 lines checked

Signed-off-by: default avatarMarcin Slusarz <marcin.slusarz@gmail.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent bd45a420
Loading
Loading
Loading
Loading
+139 −92
Original line number Original line Diff line number Diff line
@@ -32,7 +32,8 @@
#define udf_set_bit(nr, addr) ext2_set_bit(nr, addr)
#define udf_set_bit(nr, addr) ext2_set_bit(nr, addr)
#define udf_test_bit(nr, addr) ext2_test_bit(nr, addr)
#define udf_test_bit(nr, addr) ext2_test_bit(nr, addr)
#define udf_find_first_one_bit(addr, size) find_first_one_bit(addr, size)
#define udf_find_first_one_bit(addr, size) find_first_one_bit(addr, size)
#define udf_find_next_one_bit(addr, size, offset) find_next_one_bit(addr, size, offset)
#define udf_find_next_one_bit(addr, size, offset) \
		find_next_one_bit(addr, size, offset)


#define leBPL_to_cpup(x) leNUM_to_cpup(BITS_PER_LONG, x)
#define leBPL_to_cpup(x) leNUM_to_cpup(BITS_PER_LONG, x)
#define leNUM_to_cpup(x, y) xleNUM_to_cpup(x, y)
#define leNUM_to_cpup(x, y) xleNUM_to_cpup(x, y)
@@ -62,7 +63,8 @@ static inline int find_next_one_bit(void *addr, int size, int offset)
		result += BITS_PER_LONG;
		result += BITS_PER_LONG;
	}
	}
	while (size & ~(BITS_PER_LONG - 1)) {
	while (size & ~(BITS_PER_LONG - 1)) {
		if ((tmp = leBPL_to_cpup(p++)))
		tmp = leBPL_to_cpup(p++);
		if (tmp)
			goto found_middle;
			goto found_middle;
		result += BITS_PER_LONG;
		result += BITS_PER_LONG;
		size -= BITS_PER_LONG;
		size -= BITS_PER_LONG;
@@ -91,9 +93,9 @@ static int read_block_bitmap(struct super_block *sb,
	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;
	}

	bitmap->s_block_bitmap[bitmap_nr] = bh;
	bitmap->s_block_bitmap[bitmap_nr] = bh;
	return retval;
	return retval;
}
}
@@ -155,14 +157,17 @@ static void udf_bitmap_free_blocks(struct super_block *sb,


	mutex_lock(&sbi->s_alloc_mutex);
	mutex_lock(&sbi->s_alloc_mutex);
	if (bloc.logicalBlockNum < 0 ||
	if (bloc.logicalBlockNum < 0 ||
	    (bloc.logicalBlockNum + count) > sbi->s_partmaps[bloc.partitionReferenceNum].s_partition_len) {
	    (bloc.logicalBlockNum + count) >
		sbi->s_partmaps[bloc.partitionReferenceNum].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].s_partition_len);
			  sbi->s_partmaps[bloc.partitionReferenceNum].
							s_partition_len);
		goto error_return;
		goto error_return;
	}
	}


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


do_more:
do_more:
	overflow = 0;
	overflow = 0;
@@ -184,7 +189,8 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
	for (i = 0; i < count; i++) {
	for (i = 0; i < count; i++) {
		if (udf_set_bit(bit + i, bh->b_data)) {
		if (udf_set_bit(bit + i, bh->b_data)) {
			udf_debug("bit %ld already set\n", bit + i);
			udf_debug("bit %ld already set\n", bit + i);
			udf_debug("byte=%2x\n", ((char *)bh->b_data)[(bit + i) >> 3]);
			udf_debug("byte=%2x\n",
				  ((char *)bh->b_data)[(bit + i) >> 3]);
		} else {
		} else {
			if (inode)
			if (inode)
				DQUOT_FREE_BLOCK(inode, 1);
				DQUOT_FREE_BLOCK(inode, 1);
@@ -314,14 +320,16 @@ static int udf_bitmap_new_block(struct super_block *sb,
		if (bit < end_goal)
		if (bit < end_goal)
			goto got_block;
			goto got_block;


		ptr = memscan((char *)bh->b_data + (bit >> 3), 0xFF, sb->s_blocksize - ((bit + 7) >> 3));
		ptr = memscan((char *)bh->b_data + (bit >> 3), 0xFF,
			      sb->s_blocksize - ((bit + 7) >> 3));
		newbit = (ptr - ((char *)bh->b_data)) << 3;
		newbit = (ptr - ((char *)bh->b_data)) << 3;
		if (newbit < sb->s_blocksize << 3) {
		if (newbit < sb->s_blocksize << 3) {
			bit = newbit;
			bit = newbit;
			goto search_back;
			goto search_back;
		}
		}


		newbit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, bit);
		newbit = udf_find_next_one_bit(bh->b_data,
					       sb->s_blocksize << 3, bit);
		if (newbit < sb->s_blocksize << 3) {
		if (newbit < sb->s_blocksize << 3) {
			bit = newbit;
			bit = newbit;
			goto got_block;
			goto got_block;
@@ -360,15 +368,20 @@ static int udf_bitmap_new_block(struct super_block *sb,
	if (bit < sb->s_blocksize << 3)
	if (bit < sb->s_blocksize << 3)
		goto search_back;
		goto search_back;
	else
	else
		bit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, group_start << 3);
		bit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3,
					    group_start << 3);
	if (bit >= sb->s_blocksize << 3) {
	if (bit >= sb->s_blocksize << 3) {
		mutex_unlock(&sbi->s_alloc_mutex);
		mutex_unlock(&sbi->s_alloc_mutex);
		return 0;
		return 0;
	}
	}


search_back:
search_back:
	for (i = 0; i < 7 && bit > (group_start << 3) && udf_test_bit(bit - 1, bh->b_data); i++, bit--)
	i = 0;
		; /* empty loop */
	while (i < 7 && bit > (group_start << 3) &&
	       udf_test_bit(bit - 1, bh->b_data)) {
		++i;
		--bit;
	}


got_block:
got_block:


@@ -424,15 +437,17 @@ static void udf_table_free_blocks(struct super_block *sb,


	mutex_lock(&sbi->s_alloc_mutex);
	mutex_lock(&sbi->s_alloc_mutex);
	if (bloc.logicalBlockNum < 0 ||
	if (bloc.logicalBlockNum < 0 ||
	    (bloc.logicalBlockNum + count) > sbi->s_partmaps[bloc.partitionReferenceNum].s_partition_len) {
	    (bloc.logicalBlockNum + count) >
		sbi->s_partmaps[bloc.partitionReferenceNum].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]->s_partition_len);
			  sbi->s_partmaps[bloc.partitionReferenceNum].
							s_partition_len);
		goto error_return;
		goto error_return;
	}
	}


	/* We do this up front - There are some error conditions that could occure,
	/* We do this up front - There are some error conditions that
	   but.. oh well */
	   could occure, but.. oh well */
	if (inode)
	if (inode)
		DQUOT_FREE_BLOCK(inode, count);
		DQUOT_FREE_BLOCK(inode, count);
	if (sbi->s_lvid_bh) {
	if (sbi->s_lvid_bh) {
@@ -452,26 +467,39 @@ static void udf_table_free_blocks(struct super_block *sb,


	while (count &&
	while (count &&
	       (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) {
	       (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) {
		if (((eloc.logicalBlockNum + (elen >> sb->s_blocksize_bits)) == start)) {
		if (((eloc.logicalBlockNum +
			if ((0x3FFFFFFF - elen) < (count << sb->s_blocksize_bits)) {
			(elen >> sb->s_blocksize_bits)) == start)) {
				count -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits);
			if ((0x3FFFFFFF - elen) <
				start += ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits);
					(count << sb->s_blocksize_bits)) {
				elen = (etype << 30) | (0x40000000 - sb->s_blocksize);
				uint32_t tmp = ((0x3FFFFFFF - elen) >>
							sb->s_blocksize_bits);
				count -= tmp;
				start += tmp;
				elen = (etype << 30) |
					(0x40000000 - sb->s_blocksize);
			} else {
			} else {
				elen = (etype << 30) | (elen + (count << sb->s_blocksize_bits));
				elen = (etype << 30) |
					(elen +
					(count << sb->s_blocksize_bits));
				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) < (count << sb->s_blocksize_bits)) {
			if ((0x3FFFFFFF - elen) <
				count -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits);
					(count << sb->s_blocksize_bits)) {
				end -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits);
				uint32_t tmp = ((0x3FFFFFFF - elen) >>
				eloc.logicalBlockNum -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits);
						sb->s_blocksize_bits);
				elen = (etype << 30) | (0x40000000 - sb->s_blocksize);
				count -= tmp;
				end -= tmp;
				eloc.logicalBlockNum -= tmp;
				elen = (etype << 30) |
					(0x40000000 - sb->s_blocksize);
			} else {
			} else {
				eloc.logicalBlockNum = start;
				eloc.logicalBlockNum = start;
				elen = (etype << 30) | (elen + (count << sb->s_blocksize_bits));
				elen = (etype << 30) |
					(elen +
					(count << sb->s_blocksize_bits));
				end -= count;
				end -= count;
				count = 0;
				count = 0;
			}
			}
@@ -492,9 +520,9 @@ static void udf_table_free_blocks(struct super_block *sb,


	if (count) {
	if (count) {
		/*
		/*
		 * NOTE: we CANNOT use udf_add_aext here, as it can try to allocate
		 * NOTE: we CANNOT use udf_add_aext here, as it can try to
		 * a new block, and since we hold the super block lock already
		 * allocate a new block, and since we hold the super block
		 * very bad things would happen :)
		 * lock already very bad things would happen :)
		 *
		 *
		 * We copy the behavior of udf_add_aext, but instead of
		 * We copy the behavior of udf_add_aext, but instead of
		 * trying to allocate a new block close to the existing one,
		 * trying to allocate a new block close to the existing one,
@@ -535,27 +563,35 @@ static void udf_table_free_blocks(struct super_block *sb,
			eloc.logicalBlockNum++;
			eloc.logicalBlockNum++;
			elen -= sb->s_blocksize;
			elen -= sb->s_blocksize;


			if (!(epos.bh = udf_tread(sb, udf_get_lb_pblock(sb, epos.block, 0)))) {
			epos.bh = udf_tread(sb,
					udf_get_lb_pblock(sb, epos.block, 0));
			if (!epos.bh) {
				brelse(oepos.bh);
				brelse(oepos.bh);
				goto error_return;
				goto error_return;
			}
			}
			aed = (struct allocExtDesc *)(epos.bh->b_data);
			aed = (struct allocExtDesc *)(epos.bh->b_data);
			aed->previousAllocExtLocation = cpu_to_le32(oepos.block.logicalBlockNum);
			aed->previousAllocExtLocation =
				cpu_to_le32(oepos.block.logicalBlockNum);
			if (epos.offset + adsize > sb->s_blocksize) {
			if (epos.offset + adsize > sb->s_blocksize) {
				loffset = epos.offset;
				loffset = epos.offset;
				aed->lengthAllocDescs = cpu_to_le32(adsize);
				aed->lengthAllocDescs = cpu_to_le32(adsize);
				sptr = UDF_I_DATA(table) + epos.offset - adsize;
				sptr = UDF_I_DATA(table) + epos.offset - adsize;
				dptr = epos.bh->b_data + sizeof(struct allocExtDesc);
				dptr = epos.bh->b_data +
					sizeof(struct allocExtDesc);
				memcpy(dptr, sptr, adsize);
				memcpy(dptr, sptr, adsize);
				epos.offset = sizeof(struct allocExtDesc) + adsize;
				epos.offset = sizeof(struct allocExtDesc) +
						adsize;
			} else {
			} else {
				loffset = epos.offset + adsize;
				loffset = epos.offset + adsize;
				aed->lengthAllocDescs = cpu_to_le32(0);
				aed->lengthAllocDescs = cpu_to_le32(0);
				if (oepos.bh) {
				if (oepos.bh) {
					sptr = oepos.bh->b_data + epos.offset;
					sptr = oepos.bh->b_data + epos.offset;
					aed = (struct allocExtDesc *)oepos.bh->b_data;
					aed = (struct allocExtDesc *)
						oepos.bh->b_data;
					aed->lengthAllocDescs =
					aed->lengthAllocDescs =
						cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize);
						cpu_to_le32(le32_to_cpu(
							aed->lengthAllocDescs) +
								adsize);
				} else {
				} else {
					sptr = UDF_I_DATA(table) + epos.offset;
					sptr = UDF_I_DATA(table) + epos.offset;
					UDF_I_LENALLOC(table) += adsize;
					UDF_I_LENALLOC(table) += adsize;
@@ -564,11 +600,13 @@ static void udf_table_free_blocks(struct super_block *sb,
				epos.offset = sizeof(struct allocExtDesc);
				epos.offset = sizeof(struct allocExtDesc);
			}
			}
			if (sbi->s_udfrev >= 0x0200)
			if (sbi->s_udfrev >= 0x0200)
				udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 3, 1,
				udf_new_tag(epos.bh->b_data, TAG_IDENT_AED,
					    epos.block.logicalBlockNum, sizeof(tag));
					    3, 1, epos.block.logicalBlockNum,
					    sizeof(tag));
			else
			else
				udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 2, 1,
				udf_new_tag(epos.bh->b_data, TAG_IDENT_AED,
					    epos.block.logicalBlockNum, sizeof(tag));
					    2, 1, epos.block.logicalBlockNum,
					    sizeof(tag));


			switch (UDF_I_ALLOCTYPE(table)) {
			switch (UDF_I_ALLOCTYPE(table)) {
			case ICBTAG_FLAG_AD_SHORT:
			case ICBTAG_FLAG_AD_SHORT:
@@ -576,14 +614,16 @@ static void udf_table_free_blocks(struct super_block *sb,
				sad->extLength = cpu_to_le32(
				sad->extLength = cpu_to_le32(
					EXT_NEXT_EXTENT_ALLOCDECS |
					EXT_NEXT_EXTENT_ALLOCDECS |
					sb->s_blocksize);
					sb->s_blocksize);
					sad->extPosition = cpu_to_le32(epos.block.logicalBlockNum);
				sad->extPosition =
					cpu_to_le32(epos.block.logicalBlockNum);
				break;
				break;
			case ICBTAG_FLAG_AD_LONG:
			case ICBTAG_FLAG_AD_LONG:
				lad = (long_ad *)sptr;
				lad = (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);
					lad->extLocation = cpu_to_lelb(epos.block);
				lad->extLocation =
					cpu_to_lelb(epos.block);
				break;
				break;
			}
			}
			if (oepos.bh) {
			if (oepos.bh) {
@@ -594,7 +634,8 @@ static void udf_table_free_blocks(struct super_block *sb,
			}
			}
		}
		}


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


			if (!epos.bh) {
			if (!epos.bh) {
@@ -603,7 +644,8 @@ static void udf_table_free_blocks(struct super_block *sb,
			} else {
			} else {
				aed = (struct allocExtDesc *)epos.bh->b_data;
				aed = (struct allocExtDesc *)epos.bh->b_data;
				aed->lengthAllocDescs =
				aed->lengthAllocDescs =
					cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize);
					cpu_to_le32(le32_to_cpu(
					    aed->lengthAllocDescs) + adsize);
				udf_update_tag(epos.bh->b_data, epos.offset);
				udf_update_tag(epos.bh->b_data, epos.offset);
				mark_buffer_dirty(epos.bh);
				mark_buffer_dirty(epos.bh);
			}
			}
@@ -631,7 +673,8 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
	struct extent_position epos;
	struct extent_position epos;
	int8_t etype = -1;
	int8_t etype = -1;


	if (first_block < 0 || first_block >= sbi->s_partmaps[partition].s_partition_len)
	if (first_block < 0 ||
		first_block >= sbi->s_partmaps[partition].s_partition_len)
		return 0;
		return 0;


	if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT)
	if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT)
@@ -658,16 +701,18 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
		epos.offset -= adsize;
		epos.offset -= adsize;


		alloc_count = (elen >> sb->s_blocksize_bits);
		alloc_count = (elen >> sb->s_blocksize_bits);
		if (inode && DQUOT_PREALLOC_BLOCK(inode, alloc_count > block_count ? block_count : alloc_count)) {
		if (inode && DQUOT_PREALLOC_BLOCK(inode,
			alloc_count > block_count ? block_count : alloc_count))
			alloc_count = 0;
			alloc_count = 0;
		} else if (alloc_count > block_count) {
		else if (alloc_count > block_count) {
			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, (etype << 30) | elen, 1);
			udf_write_aext(table, &epos, eloc,
		} else {
					(etype << 30) | elen, 1);
			udf_delete_aext(table, epos, eloc, (etype << 30) | elen);
		} else
		}
			udf_delete_aext(table, epos, eloc,
					(etype << 30) | elen);
	} else {
	} else {
		alloc_count = 0;
		alloc_count = 0;
	}
	}
@@ -711,10 +756,10 @@ static int udf_table_new_block(struct super_block *sb,
	if (goal < 0 || goal >= sbi->s_partmaps[partition].s_partition_len)
	if (goal < 0 || goal >= sbi->s_partmaps[partition].s_partition_len)
		goal = 0;
		goal = 0;


	/* We search for the closest matching block to goal. If we find a exact hit,
	/* We search for the closest matching block to goal. If we find
	   we stop. Otherwise we keep going till we run out of extents.
	   a exact hit, we stop. Otherwise we keep going till we run out
	   We store the buffer_head, bloc, and extoffset of the current closest
	   of extents. We store the buffer_head, bloc, and extoffset
	   match and use that when we are done.
	   of the current closest match and use that when we are done.
	 */
	 */
	epos.offset = sizeof(struct unallocSpaceEntry);
	epos.offset = sizeof(struct unallocSpaceEntry);
	epos.block = UDF_I_LOCATION(table);
	epos.block = UDF_I_LOCATION(table);
@@ -723,7 +768,8 @@ static int udf_table_new_block(struct super_block *sb,
	while (spread &&
	while (spread &&
	       (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) {
	       (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) {
		if (goal >= eloc.logicalBlockNum) {
		if (goal >= eloc.logicalBlockNum) {
			if (goal < eloc.logicalBlockNum + (elen >> sb->s_blocksize_bits))
			if (goal < eloc.logicalBlockNum +
					(elen >> sb->s_blocksize_bits))
				nspread = 0;
				nspread = 0;
			else
			else
				nspread = goal - eloc.logicalBlockNum -
				nspread = goal - eloc.logicalBlockNum -
@@ -825,52 +871,53 @@ inline int udf_prealloc_blocks(struct super_block *sb,
{
{
	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_prealloc_blocks(sb, inode,
		return udf_bitmap_prealloc_blocks(sb, inode,
						  map->s_uspace.s_bitmap,
						  map->s_uspace.s_bitmap,
						  partition, first_block, block_count);
						  partition, first_block,
	} else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) {
						  block_count);
	else if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE)
		return udf_table_prealloc_blocks(sb, inode,
		return udf_table_prealloc_blocks(sb, inode,
						 map->s_uspace.s_table,
						 map->s_uspace.s_table,
						 partition, first_block, block_count);
						 partition, first_block,
	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP) {
						 block_count);
	else if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
		return udf_bitmap_prealloc_blocks(sb, inode,
		return udf_bitmap_prealloc_blocks(sb, inode,
						  map->s_fspace.s_bitmap,
						  map->s_fspace.s_bitmap,
						  partition, first_block, block_count);
						  partition, first_block,
	} else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE) {
						  block_count);
	else if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
		return udf_table_prealloc_blocks(sb, inode,
		return udf_table_prealloc_blocks(sb, inode,
						 map->s_fspace.s_table,
						 map->s_fspace.s_table,
						 partition, first_block, block_count);
						 partition, first_block,
	} else {
						 block_count);
	else
		return 0;
		return 0;
}
}
}


inline int udf_new_block(struct super_block *sb,
inline int udf_new_block(struct super_block *sb,
			 struct inode *inode,
			 struct inode *inode,
			 uint16_t partition, uint32_t goal, int *err)
			 uint16_t partition, uint32_t goal, int *err)
{
{
	int ret;
	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)
		ret = udf_bitmap_new_block(sb, inode,
		return udf_bitmap_new_block(sb, inode,
					   map->s_uspace.s_bitmap,
					   map->s_uspace.s_bitmap,
					   partition, goal, err);
					   partition, goal, err);
		return ret;
	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_new_block(sb, inode,
		return udf_table_new_block(sb, inode,
					   map->s_uspace.s_table,
					   map->s_uspace.s_table,
					   partition, goal, err);
					   partition, goal, err);
	} 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_new_block(sb, inode,
		return udf_bitmap_new_block(sb, inode,
					    map->s_fspace.s_bitmap,
					    map->s_fspace.s_bitmap,
					    partition, goal, err);
					    partition, goal, err);
	} 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_new_block(sb, inode,
		return udf_table_new_block(sb, inode,
					   map->s_fspace.s_table,
					   map->s_fspace.s_table,
					   partition, goal, err);
					   partition, goal, err);
	} else {
	else {
		*err = -EIO;
		*err = -EIO;
		return 0;
		return 0;
	}
	}
+48 −32
Original line number Original line Diff line number Diff line
@@ -45,7 +45,8 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad,
		block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos);
		block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos);
		if (!block)
		if (!block)
			return NULL;
			return NULL;
		if (!(*bh = udf_tread(dir->i_sb, block)))
		*bh = udf_tread(dir->i_sb, block);
		if (!*bh)
			return NULL;
			return NULL;
	} else if (*offset > dir->i_sb->s_blocksize) {
	} else if (*offset > dir->i_sb->s_blocksize) {
		ad = tmpad;
		ad = tmpad;
@@ -57,10 +58,12 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad,
		block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos);
		block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos);
		if (!block)
		if (!block)
			return NULL;
			return NULL;
		if (!((*bh) = udf_tread(dir->i_sb, block)))
		(*bh) = udf_tread(dir->i_sb, block);
		if (!*bh)
			return NULL;
			return NULL;


		memcpy((uint8_t *)ad + remainder, (*bh)->b_data, ad_size - remainder);
		memcpy((uint8_t *)ad + remainder, (*bh)->b_data,
			ad_size - remainder);
		*offset = ad_size - remainder;
		*offset = ad_size - remainder;
	}
	}


@@ -86,7 +89,8 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
				       (UDF_I_EFE(dir) ?
				       (UDF_I_EFE(dir) ?
					sizeof(struct extendedFileEntry) :
					sizeof(struct extendedFileEntry) :
					sizeof(struct fileEntry)),
					sizeof(struct fileEntry)),
				       dir->i_sb->s_blocksize, &(fibh->eoffset));
				       dir->i_sb->s_blocksize,
				       &(fibh->eoffset));
		if (!fi)
		if (!fi)
			return NULL;
			return NULL;


@@ -100,6 +104,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,


	if (fibh->eoffset == dir->i_sb->s_blocksize) {
	if (fibh->eoffset == dir->i_sb->s_blocksize) {
		int lextoffset = epos->offset;
		int lextoffset = epos->offset;
		unsigned char blocksize_bits = dir->i_sb->s_blocksize_bits;


		if (udf_next_aext(dir, epos, eloc, elen, 1) !=
		if (udf_next_aext(dir, epos, eloc, elen, 1) !=
		    (EXT_RECORDED_ALLOCATED >> 30))
		    (EXT_RECORDED_ALLOCATED >> 30))
@@ -109,24 +114,27 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,


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


		if ((*offset << dir->i_sb->s_blocksize_bits) >= *elen)
		if ((*offset << blocksize_bits) >= *elen)
			*offset = 0;
			*offset = 0;
		else
		else
			epos->offset = lextoffset;
			epos->offset = lextoffset;


		brelse(fibh->sbh);
		brelse(fibh->sbh);
		if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block)))
		fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block);
		if (!fibh->sbh)
			return NULL;
			return NULL;
		fibh->soffset = fibh->eoffset = 0;
		fibh->soffset = fibh->eoffset = 0;


		if (!(*offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1))) {
		if (!(*offset & ((16 >> (blocksize_bits - 9)) - 1))) {
			i = 16 >> (dir->i_sb->s_blocksize_bits - 9);
			i = 16 >> (blocksize_bits - 9);
			if (i + *offset > (*elen >> dir->i_sb->s_blocksize_bits))
			if (i + *offset > (*elen >> blocksize_bits))
				i = (*elen >> dir->i_sb->s_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, *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;
				else
				else
					brelse(tmp);
					brelse(tmp);
@@ -172,20 +180,24 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
		fibh->soffset -= dir->i_sb->s_blocksize;
		fibh->soffset -= dir->i_sb->s_blocksize;
		fibh->eoffset -= dir->i_sb->s_blocksize;
		fibh->eoffset -= dir->i_sb->s_blocksize;


		if (!(fibh->ebh = udf_tread(dir->i_sb, block)))
		fibh->ebh = udf_tread(dir->i_sb, block);
		if (!fibh->ebh)
			return NULL;
			return NULL;


		if (sizeof(struct fileIdentDesc) > -fibh->soffset) {
		if (sizeof(struct fileIdentDesc) > -fibh->soffset) {
			int fi_len;
			int fi_len;


			memcpy((uint8_t *)cfi, (uint8_t *)fi, -fibh->soffset);
			memcpy((uint8_t *)cfi, (uint8_t *)fi, -fibh->soffset);
			memcpy((uint8_t *)cfi - fibh->soffset, fibh->ebh->b_data,
			memcpy((uint8_t *)cfi - fibh->soffset,
			       fibh->ebh->b_data,
			       sizeof(struct fileIdentDesc) + fibh->soffset);
			       sizeof(struct fileIdentDesc) + fibh->soffset);


			fi_len = (sizeof(struct fileIdentDesc) + cfi->lengthFileIdent +
			fi_len = (sizeof(struct fileIdentDesc) +
				  cfi->lengthFileIdent +
				  le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3;
				  le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3;


			*nf_pos += ((fi_len - (fibh->eoffset - fibh->soffset)) >> 2);
			*nf_pos += (fi_len - (fibh->eoffset - fibh->soffset))
					>> 2;
			fibh->eoffset = fibh->soffset + fi_len;
			fibh->eoffset = fibh->soffset + fi_len;
		} else {
		} else {
			memcpy((uint8_t *)cfi, (uint8_t *)fi,
			memcpy((uint8_t *)cfi, (uint8_t *)fi,
@@ -210,9 +222,8 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)


	ptr = buffer;
	ptr = buffer;


	if ((*offset > 0) && (*offset < bufsize)) {
	if ((*offset > 0) && (*offset < bufsize))
		ptr += *offset;
		ptr += *offset;
	}
	fi = (struct fileIdentDesc *)ptr;
	fi = (struct fileIdentDesc *)ptr;
	if (le16_to_cpu(fi->descTag.tagIdent) != TAG_IDENT_FID) {
	if (le16_to_cpu(fi->descTag.tagIdent) != TAG_IDENT_FID) {
		udf_debug("0x%x != TAG_IDENT_FID\n",
		udf_debug("0x%x != TAG_IDENT_FID\n",
@@ -222,12 +233,11 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
			  bufsize);
			  bufsize);
		return NULL;
		return NULL;
	}
	}
	if ((*offset + sizeof(struct fileIdentDesc)) > bufsize) {
	if ((*offset + sizeof(struct fileIdentDesc)) > bufsize)
		lengthThisIdent = sizeof(struct fileIdentDesc);
		lengthThisIdent = sizeof(struct fileIdentDesc);
	} else {
	else
		lengthThisIdent = sizeof(struct fileIdentDesc) +
		lengthThisIdent = sizeof(struct fileIdentDesc) +
			fi->lengthFileIdent + le16_to_cpu(fi->lengthOfImpUse);
			fi->lengthFileIdent + le16_to_cpu(fi->lengthOfImpUse);
	}


	/* we need to figure padding, too! */
	/* we need to figure padding, too! */
	padlen = lengthThisIdent % UDF_NAME_PAD;
	padlen = lengthThisIdent % UDF_NAME_PAD;
@@ -258,11 +268,11 @@ static extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset)
		return NULL;
		return NULL;
	}
	}


	ptr = (uint8_t *)(fe->extendedAttr) + le32_to_cpu(fe->lengthExtendedAttr);
	ptr = (uint8_t *)(fe->extendedAttr) +
		le32_to_cpu(fe->lengthExtendedAttr);


	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 = (extent_ad *)ptr;


@@ -283,8 +293,11 @@ short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, int *offset,


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


	if (inc)
	if (inc)
		*offset += sizeof(short_ad);
		*offset += sizeof(short_ad);
@@ -302,8 +315,11 @@ long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, int *offset, int inc)


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


	if (inc)
	if (inc)
		*offset += sizeof(long_ad);
		*offset += sizeof(long_ad);
+12 −6
Original line number Original line Diff line number Diff line
@@ -59,7 +59,8 @@ static int udf_adinicb_readpage(struct file *file, struct page *page)
	return 0;
	return 0;
}
}


static int udf_adinicb_writepage(struct page *page, struct writeback_control *wbc)
static int udf_adinicb_writepage(struct page *page,
				 struct writeback_control *wbc)
{
{
	struct inode *inode = page->mapping->host;
	struct inode *inode = page->mapping->host;
	char *kaddr;
	char *kaddr;
@@ -116,7 +117,8 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
		else
		else
			pos = ppos;
			pos = ppos;


		if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) +
		if (inode->i_sb->s_blocksize <
				(udf_file_entry_alloc_offset(inode) +
						pos + count)) {
						pos + count)) {
			udf_expand_file_adinicb(inode, pos + count, &err);
			udf_expand_file_adinicb(inode, pos + count, &err);
			if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) {
			if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) {
@@ -191,15 +193,19 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,


	switch (cmd) {
	switch (cmd) {
	case UDF_GETVOLIDENT:
	case UDF_GETVOLIDENT:
		return copy_to_user((char __user *)arg,
		if (copy_to_user((char __user *)arg,
				    UDF_SB(inode->i_sb)->s_volume_ident, 32) ? -EFAULT : 0;
				 UDF_SB(inode->i_sb)->s_volume_ident, 32))
			return -EFAULT;
		else
			return 0;
	case UDF_RELOCATE_BLOCKS:
	case UDF_RELOCATE_BLOCKS:
		if (!capable(CAP_SYS_ADMIN))
		if (!capable(CAP_SYS_ADMIN))
			return -EACCES;
			return -EACCES;
		if (get_user(old_block, (long __user *)arg))
		if (get_user(old_block, (long __user *)arg))
			return -EFAULT;
			return -EFAULT;
		if ((result = udf_relocate_blocks(inode->i_sb,
		result = udf_relocate_blocks(inode->i_sb,
						  old_block, &new_block)) == 0)
						old_block, &new_block);
		if (result == 0)
			result = put_user(new_block, (long __user *)arg);
			result = put_user(new_block, (long __user *)arg);
		return result;
		return result;
	case UDF_GETEASIZE:
	case UDF_GETEASIZE:
+17 −7
Original line number Original line Diff line number Diff line
@@ -82,7 +82,8 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
	UDF_I_NEXT_ALLOC_GOAL(inode) = 0;
	UDF_I_NEXT_ALLOC_GOAL(inode) = 0;
	UDF_I_STRAT4096(inode) = 0;
	UDF_I_STRAT4096(inode) = 0;


	block = udf_new_block(dir->i_sb, NULL, UDF_I_LOCATION(dir).partitionReferenceNum,
	block = udf_new_block(dir->i_sb, NULL,
			      UDF_I_LOCATION(dir).partitionReferenceNum,
			      start, err);
			      start, err);
	if (*err) {
	if (*err) {
		iput(inode);
		iput(inode);
@@ -91,11 +92,15 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)


	mutex_lock(&sbi->s_alloc_mutex);
	mutex_lock(&sbi->s_alloc_mutex);
	if (sbi->s_lvid_bh) {
	if (sbi->s_lvid_bh) {
		struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)sbi->s_lvid_bh->b_data;
		struct logicalVolIntegrityDesc *lvid =
		struct logicalVolIntegrityDescImpUse *lvidiu = udf_sb_lvidiu(sbi);
			(struct logicalVolIntegrityDesc *)
			sbi->s_lvid_bh->b_data;
		struct logicalVolIntegrityDescImpUse *lvidiu =
							udf_sb_lvidiu(sbi);
		struct logicalVolHeaderDesc *lvhd;
		struct logicalVolHeaderDesc *lvhd;
		uint64_t uniqueID;
		uint64_t uniqueID;
		lvhd = (struct logicalVolHeaderDesc *)(lvid->logicalVolContentsUse);
		lvhd = (struct logicalVolHeaderDesc *)
				(lvid->logicalVolContentsUse);
		if (S_ISDIR(mode))
		if (S_ISDIR(mode))
			lvidiu->numDirs =
			lvidiu->numDirs =
				cpu_to_le32(le32_to_cpu(lvidiu->numDirs) + 1);
				cpu_to_le32(le32_to_cpu(lvidiu->numDirs) + 1);
@@ -119,7 +124,8 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
	}
	}


	UDF_I_LOCATION(inode).logicalBlockNum = block;
	UDF_I_LOCATION(inode).logicalBlockNum = block;
	UDF_I_LOCATION(inode).partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum;
	UDF_I_LOCATION(inode).partitionReferenceNum =
				UDF_I_LOCATION(dir).partitionReferenceNum;
	inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0);
	inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0);
	inode->i_blocks = 0;
	inode->i_blocks = 0;
	UDF_I_LENEATTR(inode) = 0;
	UDF_I_LENEATTR(inode) = 0;
@@ -129,10 +135,14 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
		UDF_I_EFE(inode) = 1;
		UDF_I_EFE(inode) = 1;
		if (UDF_VERS_USE_EXTENDED_FE > sbi->s_udfrev)
		if (UDF_VERS_USE_EXTENDED_FE > sbi->s_udfrev)
			sbi->s_udfrev = UDF_VERS_USE_EXTENDED_FE;
			sbi->s_udfrev = UDF_VERS_USE_EXTENDED_FE;
		UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL);
		UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize -
					    sizeof(struct extendedFileEntry),
					    GFP_KERNEL);
	} else {
	} else {
		UDF_I_EFE(inode) = 0;
		UDF_I_EFE(inode) = 0;
		UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL);
		UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize -
					    sizeof(struct fileEntry),
					    GFP_KERNEL);
	}
	}
	if (!UDF_I_DATA(inode)) {
	if (!UDF_I_DATA(inode)) {
		iput(inode);
		iput(inode);
+401 −264

File changed.

Preview size limit exceeded, changes collapsed.

Loading