UDF: coding style conversion - lindent fixups
This patch fixes up sources after conversion by Lindent. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> Cc: Jan Kara <jack@ucw.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
71133027fe
commit
28de7948a8
420
fs/udf/balloc.c
420
fs/udf/balloc.c
@ -70,9 +70,9 @@ static inline int find_next_one_bit(void *addr, int size, int offset)
|
|||||||
if (!size)
|
if (!size)
|
||||||
return result;
|
return result;
|
||||||
tmp = leBPL_to_cpup(p);
|
tmp = leBPL_to_cpup(p);
|
||||||
found_first:
|
found_first:
|
||||||
tmp &= ~0UL >> (BITS_PER_LONG - size);
|
tmp &= ~0UL >> (BITS_PER_LONG - size);
|
||||||
found_middle:
|
found_middle:
|
||||||
return result + ffz(~tmp);
|
return result + ffz(~tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,11 +110,11 @@ static int __load_block_bitmap(struct super_block *sb,
|
|||||||
nr_groups);
|
nr_groups);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bitmap->s_block_bitmap[block_group])
|
if (bitmap->s_block_bitmap[block_group]) {
|
||||||
return block_group;
|
return block_group;
|
||||||
else {
|
} else {
|
||||||
retval =
|
retval = read_block_bitmap(sb, bitmap, block_group,
|
||||||
read_block_bitmap(sb, bitmap, block_group, block_group);
|
block_group);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
return retval;
|
return retval;
|
||||||
return block_group;
|
return block_group;
|
||||||
@ -155,22 +155,16 @@ 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) > UDF_SB_PARTLEN(sb,
|
(bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)) {
|
||||||
bloc.
|
udf_debug("%d < %d || %d + %d > %d\n",
|
||||||
partitionReferenceNum))
|
bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count,
|
||||||
{
|
UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum));
|
||||||
udf_debug("%d < %d || %d + %d > %d\n", bloc.logicalBlockNum, 0,
|
|
||||||
bloc.logicalBlockNum, count, UDF_SB_PARTLEN(sb,
|
|
||||||
bloc.
|
|
||||||
partitionReferenceNum));
|
|
||||||
goto error_return;
|
goto error_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
block =
|
block = bloc.logicalBlockNum + offset + (sizeof(struct spaceBitmapDesc) << 3);
|
||||||
bloc.logicalBlockNum + offset +
|
|
||||||
(sizeof(struct spaceBitmapDesc) << 3);
|
|
||||||
|
|
||||||
do_more:
|
do_more:
|
||||||
overflow = 0;
|
overflow = 0;
|
||||||
block_group = block >> (sb->s_blocksize_bits + 3);
|
block_group = block >> (sb->s_blocksize_bits + 3);
|
||||||
bit = block % (sb->s_blocksize << 3);
|
bit = block % (sb->s_blocksize << 3);
|
||||||
@ -190,18 +184,13 @@ 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",
|
udf_debug("byte=%2x\n", ((char *)bh->b_data)[(bit + i) >> 3]);
|
||||||
((char *)bh->b_data)[(bit + i) >> 3]);
|
|
||||||
} else {
|
} else {
|
||||||
if (inode)
|
if (inode)
|
||||||
DQUOT_FREE_BLOCK(inode, 1);
|
DQUOT_FREE_BLOCK(inode, 1);
|
||||||
if (UDF_SB_LVIDBH(sb)) {
|
if (UDF_SB_LVIDBH(sb)) {
|
||||||
UDF_SB_LVID(sb)->
|
UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)] =
|
||||||
freeSpaceTable[UDF_SB_PARTITION(sb)] =
|
cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]) + 1);
|
||||||
cpu_to_le32(le32_to_cpu
|
|
||||||
(UDF_SB_LVID(sb)->
|
|
||||||
freeSpaceTable[UDF_SB_PARTITION
|
|
||||||
(sb)]) + 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,7 +200,7 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
|
|||||||
count = overflow;
|
count = overflow;
|
||||||
goto do_more;
|
goto do_more;
|
||||||
}
|
}
|
||||||
error_return:
|
error_return:
|
||||||
sb->s_dirt = 1;
|
sb->s_dirt = 1;
|
||||||
if (UDF_SB_LVIDBH(sb))
|
if (UDF_SB_LVIDBH(sb))
|
||||||
mark_buffer_dirty(UDF_SB_LVIDBH(sb));
|
mark_buffer_dirty(UDF_SB_LVIDBH(sb));
|
||||||
@ -238,7 +227,7 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb,
|
|||||||
if (first_block + block_count > UDF_SB_PARTLEN(sb, partition))
|
if (first_block + block_count > UDF_SB_PARTLEN(sb, partition))
|
||||||
block_count = UDF_SB_PARTLEN(sb, partition) - first_block;
|
block_count = UDF_SB_PARTLEN(sb, partition) - first_block;
|
||||||
|
|
||||||
repeat:
|
repeat:
|
||||||
nr_groups = (UDF_SB_PARTLEN(sb, partition) +
|
nr_groups = (UDF_SB_PARTLEN(sb, partition) +
|
||||||
(sizeof(struct spaceBitmapDesc) << 3) +
|
(sizeof(struct spaceBitmapDesc) << 3) +
|
||||||
(sb->s_blocksize * 8) - 1) / (sb->s_blocksize * 8);
|
(sb->s_blocksize * 8) - 1) / (sb->s_blocksize * 8);
|
||||||
@ -254,11 +243,11 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb,
|
|||||||
bit = block % (sb->s_blocksize << 3);
|
bit = block % (sb->s_blocksize << 3);
|
||||||
|
|
||||||
while (bit < (sb->s_blocksize << 3) && block_count > 0) {
|
while (bit < (sb->s_blocksize << 3) && block_count > 0) {
|
||||||
if (!udf_test_bit(bit, bh->b_data))
|
if (!udf_test_bit(bit, bh->b_data)) {
|
||||||
goto out;
|
goto out;
|
||||||
else if (DQUOT_PREALLOC_BLOCK(inode, 1))
|
} else if (DQUOT_PREALLOC_BLOCK(inode, 1)) {
|
||||||
goto out;
|
goto out;
|
||||||
else if (!udf_clear_bit(bit, bh->b_data)) {
|
} else if (!udf_clear_bit(bit, bh->b_data)) {
|
||||||
udf_debug("bit already cleared for block %d\n", bit);
|
udf_debug("bit already cleared for block %d\n", bit);
|
||||||
DQUOT_FREE_BLOCK(inode, 1);
|
DQUOT_FREE_BLOCK(inode, 1);
|
||||||
goto out;
|
goto out;
|
||||||
@ -271,12 +260,10 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb,
|
|||||||
mark_buffer_dirty(bh);
|
mark_buffer_dirty(bh);
|
||||||
if (block_count > 0)
|
if (block_count > 0)
|
||||||
goto repeat;
|
goto repeat;
|
||||||
out:
|
out:
|
||||||
if (UDF_SB_LVIDBH(sb)) {
|
if (UDF_SB_LVIDBH(sb)) {
|
||||||
UDF_SB_LVID(sb)->freeSpaceTable[partition] =
|
UDF_SB_LVID(sb)->freeSpaceTable[partition] =
|
||||||
cpu_to_le32(le32_to_cpu
|
cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - alloc_count);
|
||||||
(UDF_SB_LVID(sb)->freeSpaceTable[partition]) -
|
|
||||||
alloc_count);
|
|
||||||
mark_buffer_dirty(UDF_SB_LVIDBH(sb));
|
mark_buffer_dirty(UDF_SB_LVIDBH(sb));
|
||||||
}
|
}
|
||||||
sb->s_dirt = 1;
|
sb->s_dirt = 1;
|
||||||
@ -299,7 +286,7 @@ static int udf_bitmap_new_block(struct super_block *sb,
|
|||||||
*err = -ENOSPC;
|
*err = -ENOSPC;
|
||||||
mutex_lock(&sbi->s_alloc_mutex);
|
mutex_lock(&sbi->s_alloc_mutex);
|
||||||
|
|
||||||
repeat:
|
repeat:
|
||||||
if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition))
|
if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition))
|
||||||
goal = 0;
|
goal = 0;
|
||||||
|
|
||||||
@ -312,31 +299,27 @@ static int udf_bitmap_new_block(struct super_block *sb,
|
|||||||
if (bitmap_nr < 0)
|
if (bitmap_nr < 0)
|
||||||
goto error_return;
|
goto error_return;
|
||||||
bh = bitmap->s_block_bitmap[bitmap_nr];
|
bh = bitmap->s_block_bitmap[bitmap_nr];
|
||||||
ptr =
|
ptr = memscan((char *)bh->b_data + group_start, 0xFF,
|
||||||
memscan((char *)bh->b_data + group_start, 0xFF,
|
sb->s_blocksize - group_start);
|
||||||
sb->s_blocksize - group_start);
|
|
||||||
|
|
||||||
if ((ptr - ((char *)bh->b_data)) < sb->s_blocksize) {
|
if ((ptr - ((char *)bh->b_data)) < sb->s_blocksize) {
|
||||||
bit = block % (sb->s_blocksize << 3);
|
bit = block % (sb->s_blocksize << 3);
|
||||||
|
if (udf_test_bit(bit, bh->b_data))
|
||||||
if (udf_test_bit(bit, bh->b_data)) {
|
|
||||||
goto got_block;
|
goto got_block;
|
||||||
}
|
|
||||||
end_goal = (bit + 63) & ~63;
|
end_goal = (bit + 63) & ~63;
|
||||||
bit = udf_find_next_one_bit(bh->b_data, end_goal, bit);
|
bit = udf_find_next_one_bit(bh->b_data, end_goal, bit);
|
||||||
if (bit < end_goal)
|
if (bit < end_goal)
|
||||||
goto got_block;
|
goto got_block;
|
||||||
ptr =
|
|
||||||
memscan((char *)bh->b_data + (bit >> 3), 0xFF,
|
ptr = memscan((char *)bh->b_data + (bit >> 3), 0xFF, sb->s_blocksize - ((bit + 7) >> 3));
|
||||||
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,
|
newbit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, bit);
|
||||||
bit);
|
|
||||||
if (newbit < sb->s_blocksize << 3) {
|
if (newbit < sb->s_blocksize << 3) {
|
||||||
bit = newbit;
|
bit = newbit;
|
||||||
goto got_block;
|
goto got_block;
|
||||||
@ -354,18 +337,16 @@ static int udf_bitmap_new_block(struct super_block *sb,
|
|||||||
goto error_return;
|
goto error_return;
|
||||||
bh = bitmap->s_block_bitmap[bitmap_nr];
|
bh = bitmap->s_block_bitmap[bitmap_nr];
|
||||||
if (i < nr_groups) {
|
if (i < nr_groups) {
|
||||||
ptr =
|
ptr = memscan((char *)bh->b_data + group_start, 0xFF,
|
||||||
memscan((char *)bh->b_data + group_start, 0xFF,
|
sb->s_blocksize - group_start);
|
||||||
sb->s_blocksize - group_start);
|
|
||||||
if ((ptr - ((char *)bh->b_data)) < sb->s_blocksize) {
|
if ((ptr - ((char *)bh->b_data)) < sb->s_blocksize) {
|
||||||
bit = (ptr - ((char *)bh->b_data)) << 3;
|
bit = (ptr - ((char *)bh->b_data)) << 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bit =
|
bit = udf_find_next_one_bit((char *)bh->b_data,
|
||||||
udf_find_next_one_bit((char *)bh->b_data,
|
sb->s_blocksize << 3,
|
||||||
sb->s_blocksize << 3,
|
group_start << 3);
|
||||||
group_start << 3);
|
|
||||||
if (bit < sb->s_blocksize << 3)
|
if (bit < sb->s_blocksize << 3)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -377,20 +358,17 @@ 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 =
|
bit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, group_start << 3);
|
||||||
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;
|
for (i = 0; i < 7 && bit > (group_start << 3) && udf_test_bit(bit - 1, bh->b_data); i++, bit--)
|
||||||
i < 7 && bit > (group_start << 3)
|
; /* empty loop */
|
||||||
&& udf_test_bit(bit - 1, bh->b_data); i++, bit--) ;
|
|
||||||
|
|
||||||
got_block:
|
got_block:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check quota for allocation of this block.
|
* Check quota for allocation of this block.
|
||||||
@ -402,7 +380,7 @@ static int udf_bitmap_new_block(struct super_block *sb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
newblock = bit + (block_group << (sb->s_blocksize_bits + 3)) -
|
newblock = bit + (block_group << (sb->s_blocksize_bits + 3)) -
|
||||||
(sizeof(struct spaceBitmapDesc) << 3);
|
(sizeof(struct spaceBitmapDesc) << 3);
|
||||||
|
|
||||||
if (!udf_clear_bit(bit, bh->b_data)) {
|
if (!udf_clear_bit(bit, bh->b_data)) {
|
||||||
udf_debug("bit already cleared for block %d\n", bit);
|
udf_debug("bit already cleared for block %d\n", bit);
|
||||||
@ -413,9 +391,7 @@ static int udf_bitmap_new_block(struct super_block *sb,
|
|||||||
|
|
||||||
if (UDF_SB_LVIDBH(sb)) {
|
if (UDF_SB_LVIDBH(sb)) {
|
||||||
UDF_SB_LVID(sb)->freeSpaceTable[partition] =
|
UDF_SB_LVID(sb)->freeSpaceTable[partition] =
|
||||||
cpu_to_le32(le32_to_cpu
|
cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - 1);
|
||||||
(UDF_SB_LVID(sb)->freeSpaceTable[partition]) -
|
|
||||||
1);
|
|
||||||
mark_buffer_dirty(UDF_SB_LVIDBH(sb));
|
mark_buffer_dirty(UDF_SB_LVIDBH(sb));
|
||||||
}
|
}
|
||||||
sb->s_dirt = 1;
|
sb->s_dirt = 1;
|
||||||
@ -423,7 +399,7 @@ static int udf_bitmap_new_block(struct super_block *sb,
|
|||||||
*err = 0;
|
*err = 0;
|
||||||
return newblock;
|
return newblock;
|
||||||
|
|
||||||
error_return:
|
error_return:
|
||||||
*err = -EIO;
|
*err = -EIO;
|
||||||
mutex_unlock(&sbi->s_alloc_mutex);
|
mutex_unlock(&sbi->s_alloc_mutex);
|
||||||
return 0;
|
return 0;
|
||||||
@ -445,14 +421,10 @@ 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) > UDF_SB_PARTLEN(sb,
|
(bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)) {
|
||||||
bloc.
|
udf_debug("%d < %d || %d + %d > %d\n",
|
||||||
partitionReferenceNum))
|
bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count,
|
||||||
{
|
UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum));
|
||||||
udf_debug("%d < %d || %d + %d > %d\n", bloc.logicalBlockNum, 0,
|
|
||||||
bloc.logicalBlockNum, count, UDF_SB_PARTLEN(sb,
|
|
||||||
bloc.
|
|
||||||
partitionReferenceNum));
|
|
||||||
goto error_return;
|
goto error_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,9 +434,7 @@ static void udf_table_free_blocks(struct super_block *sb,
|
|||||||
DQUOT_FREE_BLOCK(inode, count);
|
DQUOT_FREE_BLOCK(inode, count);
|
||||||
if (UDF_SB_LVIDBH(sb)) {
|
if (UDF_SB_LVIDBH(sb)) {
|
||||||
UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)] =
|
UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)] =
|
||||||
cpu_to_le32(le32_to_cpu
|
cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]) + count);
|
||||||
(UDF_SB_LVID(sb)->
|
|
||||||
freeSpaceTable[UDF_SB_PARTITION(sb)]) + count);
|
|
||||||
mark_buffer_dirty(UDF_SB_LVIDBH(sb));
|
mark_buffer_dirty(UDF_SB_LVIDBH(sb));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,47 +446,28 @@ static void udf_table_free_blocks(struct super_block *sb,
|
|||||||
epos.block = oepos.block = UDF_I_LOCATION(table);
|
epos.block = oepos.block = UDF_I_LOCATION(table);
|
||||||
epos.bh = oepos.bh = NULL;
|
epos.bh = oepos.bh = NULL;
|
||||||
|
|
||||||
while (count && (etype =
|
while (count &&
|
||||||
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)) ==
|
if (((eloc.logicalBlockNum + (elen >> sb->s_blocksize_bits)) == start)) {
|
||||||
start)) {
|
if ((0x3FFFFFFF - elen) < (count << sb->s_blocksize_bits)) {
|
||||||
if ((0x3FFFFFFF - elen) <
|
count -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits);
|
||||||
(count << sb->s_blocksize_bits)) {
|
start += ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits);
|
||||||
count -=
|
elen = (etype << 30) | (0x40000000 - sb->s_blocksize);
|
||||||
((0x3FFFFFFF -
|
|
||||||
elen) >> sb->s_blocksize_bits);
|
|
||||||
start +=
|
|
||||||
((0x3FFFFFFF -
|
|
||||||
elen) >> sb->s_blocksize_bits);
|
|
||||||
elen =
|
|
||||||
(etype << 30) | (0x40000000 -
|
|
||||||
sb->s_blocksize);
|
|
||||||
} else {
|
} else {
|
||||||
elen = (etype << 30) |
|
elen = (etype << 30) | (elen + (count << sb->s_blocksize_bits));
|
||||||
(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) <
|
if ((0x3FFFFFFF - elen) < (count << sb->s_blocksize_bits)) {
|
||||||
(count << sb->s_blocksize_bits)) {
|
count -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits);
|
||||||
count -=
|
end -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits);
|
||||||
((0x3FFFFFFF -
|
eloc.logicalBlockNum -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits);
|
||||||
elen) >> sb->s_blocksize_bits);
|
elen = (etype << 30) | (0x40000000 - sb->s_blocksize);
|
||||||
end -=
|
|
||||||
((0x3FFFFFFF -
|
|
||||||
elen) >> sb->s_blocksize_bits);
|
|
||||||
eloc.logicalBlockNum -=
|
|
||||||
((0x3FFFFFFF -
|
|
||||||
elen) >> sb->s_blocksize_bits);
|
|
||||||
elen =
|
|
||||||
(etype << 30) | (0x40000000 -
|
|
||||||
sb->s_blocksize);
|
|
||||||
} else {
|
} else {
|
||||||
eloc.logicalBlockNum = start;
|
eloc.logicalBlockNum = start;
|
||||||
elen = (etype << 30) |
|
elen = (etype << 30) | (elen + (count << sb->s_blocksize_bits));
|
||||||
(elen + (count << sb->s_blocksize_bits));
|
|
||||||
end -= count;
|
end -= count;
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
@ -530,21 +481,23 @@ static void udf_table_free_blocks(struct super_block *sb,
|
|||||||
get_bh(epos.bh);
|
get_bh(epos.bh);
|
||||||
oepos.bh = epos.bh;
|
oepos.bh = epos.bh;
|
||||||
oepos.offset = 0;
|
oepos.offset = 0;
|
||||||
} else
|
} else {
|
||||||
oepos.offset = epos.offset;
|
oepos.offset = epos.offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
/* NOTE: we CANNOT use udf_add_aext here, as it can try to allocate
|
/*
|
||||||
a new block, and since we hold the super block lock already
|
* NOTE: we CANNOT use udf_add_aext here, as it can try to allocate
|
||||||
very bad things would happen :)
|
* a new block, and since we hold the super block lock already
|
||||||
|
* very bad things would happen :)
|
||||||
We copy the behavior of udf_add_aext, but instead of
|
*
|
||||||
trying to allocate a new block close to the existing one,
|
* We copy the behavior of udf_add_aext, but instead of
|
||||||
we just steal a block from the extent we are trying to add.
|
* trying to allocate a new block close to the existing one,
|
||||||
|
* we just steal a block from the extent we are trying to add.
|
||||||
It would be nice if the blocks were close together, but it
|
*
|
||||||
isn't required.
|
* It would be nice if the blocks were close together, but it
|
||||||
|
* isn't required.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int adsize;
|
int adsize;
|
||||||
@ -553,13 +506,14 @@ static void udf_table_free_blocks(struct super_block *sb,
|
|||||||
struct allocExtDesc *aed;
|
struct allocExtDesc *aed;
|
||||||
|
|
||||||
eloc.logicalBlockNum = start;
|
eloc.logicalBlockNum = start;
|
||||||
elen = EXT_RECORDED_ALLOCATED | (count << sb->s_blocksize_bits);
|
elen = EXT_RECORDED_ALLOCATED |
|
||||||
|
(count << sb->s_blocksize_bits);
|
||||||
|
|
||||||
if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT)
|
if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT) {
|
||||||
adsize = sizeof(short_ad);
|
adsize = sizeof(short_ad);
|
||||||
else if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_LONG)
|
} else if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_LONG) {
|
||||||
adsize = sizeof(long_ad);
|
adsize = sizeof(long_ad);
|
||||||
else {
|
} else {
|
||||||
brelse(oepos.bh);
|
brelse(oepos.bh);
|
||||||
brelse(epos.bh);
|
brelse(epos.bh);
|
||||||
goto error_return;
|
goto error_return;
|
||||||
@ -577,28 +531,21 @@ 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,
|
if (!(epos.bh = udf_tread(sb, udf_get_lb_pblock(sb, epos.block, 0)))) {
|
||||||
udf_get_lb_pblock(sb,
|
|
||||||
epos.block,
|
|
||||||
0)))) {
|
|
||||||
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 =
|
aed->previousAllocExtLocation = cpu_to_le32(oepos.block.logicalBlockNum);
|
||||||
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(inode) + epos.offset -
|
sptr = UDF_I_DATA(inode) + epos.offset -
|
||||||
udf_file_entry_alloc_offset(inode) +
|
udf_file_entry_alloc_offset(inode) +
|
||||||
UDF_I_LENEATTR(inode) - adsize;
|
UDF_I_LENEATTR(inode) - adsize;
|
||||||
dptr =
|
dptr = epos.bh->b_data + sizeof(struct allocExtDesc);
|
||||||
epos.bh->b_data +
|
|
||||||
sizeof(struct allocExtDesc);
|
|
||||||
memcpy(dptr, sptr, adsize);
|
memcpy(dptr, sptr, adsize);
|
||||||
epos.offset =
|
epos.offset = sizeof(struct allocExtDesc) + adsize;
|
||||||
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);
|
||||||
@ -606,60 +553,46 @@ static void udf_table_free_blocks(struct super_block *sb,
|
|||||||
epos.offset = sizeof(struct allocExtDesc);
|
epos.offset = sizeof(struct allocExtDesc);
|
||||||
|
|
||||||
if (oepos.bh) {
|
if (oepos.bh) {
|
||||||
aed =
|
aed = (struct allocExtDesc *)oepos.bh->b_data;
|
||||||
(struct allocExtDesc *)oepos.bh->
|
|
||||||
b_data;
|
|
||||||
aed->lengthAllocDescs =
|
aed->lengthAllocDescs =
|
||||||
cpu_to_le32(le32_to_cpu
|
cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize);
|
||||||
(aed->
|
|
||||||
lengthAllocDescs) +
|
|
||||||
adsize);
|
|
||||||
} else {
|
} else {
|
||||||
UDF_I_LENALLOC(table) += adsize;
|
UDF_I_LENALLOC(table) += adsize;
|
||||||
mark_inode_dirty(table);
|
mark_inode_dirty(table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (UDF_SB_UDFREV(sb) >= 0x0200)
|
if (UDF_SB_UDFREV(sb) >= 0x0200)
|
||||||
udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 3,
|
udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 3, 1,
|
||||||
1, epos.block.logicalBlockNum,
|
epos.block.logicalBlockNum, sizeof(tag));
|
||||||
sizeof(tag));
|
|
||||||
else
|
else
|
||||||
udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 2,
|
udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 2, 1,
|
||||||
1, epos.block.logicalBlockNum,
|
epos.block.logicalBlockNum, sizeof(tag));
|
||||||
sizeof(tag));
|
|
||||||
switch (UDF_I_ALLOCTYPE(table)) {
|
switch (UDF_I_ALLOCTYPE(table)) {
|
||||||
case ICBTAG_FLAG_AD_SHORT:
|
case ICBTAG_FLAG_AD_SHORT:
|
||||||
{
|
sad = (short_ad *)sptr;
|
||||||
sad = (short_ad *) sptr;
|
sad->extLength = cpu_to_le32(
|
||||||
sad->extLength =
|
EXT_NEXT_EXTENT_ALLOCDECS |
|
||||||
cpu_to_le32
|
sb->s_blocksize);
|
||||||
(EXT_NEXT_EXTENT_ALLOCDECS | sb->
|
sad->extPosition = cpu_to_le32(epos.block.logicalBlockNum);
|
||||||
s_blocksize);
|
|
||||||
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->extLength = cpu_to_le32(
|
||||||
lad = (long_ad *) sptr;
|
EXT_NEXT_EXTENT_ALLOCDECS |
|
||||||
lad->extLength =
|
sb->s_blocksize);
|
||||||
cpu_to_le32
|
lad->extLocation = cpu_to_lelb(epos.block);
|
||||||
(EXT_NEXT_EXTENT_ALLOCDECS | sb->
|
|
||||||
s_blocksize);
|
|
||||||
lad->extLocation =
|
|
||||||
cpu_to_lelb(epos.block);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (oepos.bh) {
|
if (oepos.bh) {
|
||||||
udf_update_tag(oepos.bh->b_data, loffset);
|
udf_update_tag(oepos.bh->b_data, loffset);
|
||||||
mark_buffer_dirty(oepos.bh);
|
mark_buffer_dirty(oepos.bh);
|
||||||
} else
|
} else {
|
||||||
mark_inode_dirty(table);
|
mark_inode_dirty(table);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elen) { /* It's possible that stealing the block emptied the extent */
|
if (elen) { /* It's possible that stealing the block emptied the extent */
|
||||||
udf_write_aext(table, &epos, eloc, elen, 1);
|
udf_write_aext(table, &epos, eloc, elen, 1);
|
||||||
|
|
||||||
if (!epos.bh) {
|
if (!epos.bh) {
|
||||||
@ -668,9 +601,7 @@ 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
|
cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize);
|
||||||
(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);
|
||||||
}
|
}
|
||||||
@ -680,7 +611,7 @@ static void udf_table_free_blocks(struct super_block *sb,
|
|||||||
brelse(epos.bh);
|
brelse(epos.bh);
|
||||||
brelse(oepos.bh);
|
brelse(oepos.bh);
|
||||||
|
|
||||||
error_return:
|
error_return:
|
||||||
sb->s_dirt = 1;
|
sb->s_dirt = 1;
|
||||||
mutex_unlock(&sbi->s_alloc_mutex);
|
mutex_unlock(&sbi->s_alloc_mutex);
|
||||||
return;
|
return;
|
||||||
@ -714,47 +645,36 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
|
|||||||
epos.bh = NULL;
|
epos.bh = NULL;
|
||||||
eloc.logicalBlockNum = 0xFFFFFFFF;
|
eloc.logicalBlockNum = 0xFFFFFFFF;
|
||||||
|
|
||||||
while (first_block != eloc.logicalBlockNum && (etype =
|
while (first_block != eloc.logicalBlockNum &&
|
||||||
udf_next_aext(table,
|
(etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) {
|
||||||
&epos,
|
|
||||||
&eloc,
|
|
||||||
&elen,
|
|
||||||
1)) !=
|
|
||||||
-1) {
|
|
||||||
udf_debug("eloc=%d, elen=%d, first_block=%d\n",
|
udf_debug("eloc=%d, elen=%d, first_block=%d\n",
|
||||||
eloc.logicalBlockNum, elen, first_block);
|
eloc.logicalBlockNum, elen, first_block);
|
||||||
; /* empty loop body */
|
; /* empty loop body */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first_block == eloc.logicalBlockNum) {
|
if (first_block == eloc.logicalBlockNum) {
|
||||||
epos.offset -= adsize;
|
epos.offset -= adsize;
|
||||||
|
|
||||||
alloc_count = (elen >> sb->s_blocksize_bits);
|
alloc_count = (elen >> sb->s_blocksize_bits);
|
||||||
if (inode
|
if (inode && DQUOT_PREALLOC_BLOCK(inode, alloc_count > block_count ? block_count : alloc_count)) {
|
||||||
&& 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,
|
udf_write_aext(table, &epos, eloc, (etype << 30) | elen, 1);
|
||||||
1);
|
} else {
|
||||||
} else
|
udf_delete_aext(table, epos, eloc, (etype << 30) | elen);
|
||||||
udf_delete_aext(table, epos, eloc,
|
}
|
||||||
(etype << 30) | elen);
|
} else {
|
||||||
} else
|
|
||||||
alloc_count = 0;
|
alloc_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
brelse(epos.bh);
|
brelse(epos.bh);
|
||||||
|
|
||||||
if (alloc_count && UDF_SB_LVIDBH(sb)) {
|
if (alloc_count && UDF_SB_LVIDBH(sb)) {
|
||||||
UDF_SB_LVID(sb)->freeSpaceTable[partition] =
|
UDF_SB_LVID(sb)->freeSpaceTable[partition] =
|
||||||
cpu_to_le32(le32_to_cpu
|
cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - alloc_count);
|
||||||
(UDF_SB_LVID(sb)->freeSpaceTable[partition]) -
|
|
||||||
alloc_count);
|
|
||||||
mark_buffer_dirty(UDF_SB_LVIDBH(sb));
|
mark_buffer_dirty(UDF_SB_LVIDBH(sb));
|
||||||
sb->s_dirt = 1;
|
sb->s_dirt = 1;
|
||||||
}
|
}
|
||||||
@ -797,18 +717,17 @@ static int udf_table_new_block(struct super_block *sb,
|
|||||||
epos.block = UDF_I_LOCATION(table);
|
epos.block = UDF_I_LOCATION(table);
|
||||||
epos.bh = goal_epos.bh = NULL;
|
epos.bh = goal_epos.bh = NULL;
|
||||||
|
|
||||||
while (spread && (etype =
|
while (spread &&
|
||||||
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 <
|
if (goal < eloc.logicalBlockNum + (elen >> sb->s_blocksize_bits))
|
||||||
eloc.logicalBlockNum +
|
|
||||||
(elen >> sb->s_blocksize_bits))
|
|
||||||
nspread = 0;
|
nspread = 0;
|
||||||
else
|
else
|
||||||
nspread = goal - eloc.logicalBlockNum -
|
nspread = goal - eloc.logicalBlockNum -
|
||||||
(elen >> sb->s_blocksize_bits);
|
(elen >> sb->s_blocksize_bits);
|
||||||
} else
|
} else {
|
||||||
nspread = eloc.logicalBlockNum - goal;
|
nspread = eloc.logicalBlockNum - goal;
|
||||||
|
}
|
||||||
|
|
||||||
if (nspread < spread) {
|
if (nspread < spread) {
|
||||||
spread = nspread;
|
spread = nspread;
|
||||||
@ -856,9 +775,7 @@ static int udf_table_new_block(struct super_block *sb,
|
|||||||
|
|
||||||
if (UDF_SB_LVIDBH(sb)) {
|
if (UDF_SB_LVIDBH(sb)) {
|
||||||
UDF_SB_LVID(sb)->freeSpaceTable[partition] =
|
UDF_SB_LVID(sb)->freeSpaceTable[partition] =
|
||||||
cpu_to_le32(le32_to_cpu
|
cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - 1);
|
||||||
(UDF_SB_LVID(sb)->freeSpaceTable[partition]) -
|
|
||||||
1);
|
|
||||||
mark_buffer_dirty(UDF_SB_LVIDBH(sb));
|
mark_buffer_dirty(UDF_SB_LVIDBH(sb));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -877,27 +794,23 @@ inline void udf_free_blocks(struct super_block *sb,
|
|||||||
|
|
||||||
if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
|
if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
|
||||||
return udf_bitmap_free_blocks(sb, inode,
|
return udf_bitmap_free_blocks(sb, inode,
|
||||||
UDF_SB_PARTMAPS(sb)[partition].
|
UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap,
|
||||||
s_uspace.s_bitmap, bloc, offset,
|
bloc, offset, count);
|
||||||
count);
|
} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) {
|
||||||
} else if (UDF_SB_PARTFLAGS(sb, partition) &
|
|
||||||
UDF_PART_FLAG_UNALLOC_TABLE) {
|
|
||||||
return udf_table_free_blocks(sb, inode,
|
return udf_table_free_blocks(sb, inode,
|
||||||
UDF_SB_PARTMAPS(sb)[partition].
|
UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table,
|
||||||
s_uspace.s_table, bloc, offset,
|
bloc, offset, count);
|
||||||
count);
|
|
||||||
} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
|
} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
|
||||||
return udf_bitmap_free_blocks(sb, inode,
|
return udf_bitmap_free_blocks(sb, inode,
|
||||||
UDF_SB_PARTMAPS(sb)[partition].
|
UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap,
|
||||||
s_fspace.s_bitmap, bloc, offset,
|
bloc, offset, count);
|
||||||
count);
|
|
||||||
} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
|
} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
|
||||||
return udf_table_free_blocks(sb, inode,
|
return udf_table_free_blocks(sb, inode,
|
||||||
UDF_SB_PARTMAPS(sb)[partition].
|
UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table,
|
||||||
s_fspace.s_table, bloc, offset,
|
bloc, offset, count);
|
||||||
count);
|
} else {
|
||||||
} else
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int udf_prealloc_blocks(struct super_block *sb,
|
inline int udf_prealloc_blocks(struct super_block *sb,
|
||||||
@ -907,29 +820,23 @@ inline int udf_prealloc_blocks(struct super_block *sb,
|
|||||||
{
|
{
|
||||||
if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
|
if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
|
||||||
return udf_bitmap_prealloc_blocks(sb, inode,
|
return udf_bitmap_prealloc_blocks(sb, inode,
|
||||||
UDF_SB_PARTMAPS(sb)
|
UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap,
|
||||||
[partition].s_uspace.s_bitmap,
|
partition, first_block, block_count);
|
||||||
partition, first_block,
|
} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) {
|
||||||
block_count);
|
|
||||||
} else if (UDF_SB_PARTFLAGS(sb, partition) &
|
|
||||||
UDF_PART_FLAG_UNALLOC_TABLE) {
|
|
||||||
return udf_table_prealloc_blocks(sb, inode,
|
return udf_table_prealloc_blocks(sb, inode,
|
||||||
UDF_SB_PARTMAPS(sb)[partition].
|
UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table,
|
||||||
s_uspace.s_table, partition,
|
partition, first_block, block_count);
|
||||||
first_block, block_count);
|
|
||||||
} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
|
} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
|
||||||
return udf_bitmap_prealloc_blocks(sb, inode,
|
return udf_bitmap_prealloc_blocks(sb, inode,
|
||||||
UDF_SB_PARTMAPS(sb)
|
UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap,
|
||||||
[partition].s_fspace.s_bitmap,
|
partition, first_block, block_count);
|
||||||
partition, first_block,
|
|
||||||
block_count);
|
|
||||||
} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
|
} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
|
||||||
return udf_table_prealloc_blocks(sb, inode,
|
return udf_table_prealloc_blocks(sb, inode,
|
||||||
UDF_SB_PARTMAPS(sb)[partition].
|
UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table,
|
||||||
s_fspace.s_table, partition,
|
partition, first_block, block_count);
|
||||||
first_block, block_count);
|
} else {
|
||||||
} else
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int udf_new_block(struct super_block *sb,
|
inline int udf_new_block(struct super_block *sb,
|
||||||
@ -940,26 +847,21 @@ inline int udf_new_block(struct super_block *sb,
|
|||||||
|
|
||||||
if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
|
if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
|
||||||
ret = udf_bitmap_new_block(sb, inode,
|
ret = udf_bitmap_new_block(sb, inode,
|
||||||
UDF_SB_PARTMAPS(sb)[partition].
|
UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap,
|
||||||
s_uspace.s_bitmap, partition, goal,
|
partition, goal, err);
|
||||||
err);
|
|
||||||
return ret;
|
return ret;
|
||||||
} else if (UDF_SB_PARTFLAGS(sb, partition) &
|
} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) {
|
||||||
UDF_PART_FLAG_UNALLOC_TABLE) {
|
|
||||||
return udf_table_new_block(sb, inode,
|
return udf_table_new_block(sb, inode,
|
||||||
UDF_SB_PARTMAPS(sb)[partition].
|
UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table,
|
||||||
s_uspace.s_table, partition, goal,
|
partition, goal, err);
|
||||||
err);
|
|
||||||
} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
|
} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
|
||||||
return udf_bitmap_new_block(sb, inode,
|
return udf_bitmap_new_block(sb, inode,
|
||||||
UDF_SB_PARTMAPS(sb)[partition].
|
UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap,
|
||||||
s_fspace.s_bitmap, partition, goal,
|
partition, goal, err);
|
||||||
err);
|
|
||||||
} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
|
} else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
|
||||||
return udf_table_new_block(sb, inode,
|
return udf_table_new_block(sb, inode,
|
||||||
UDF_SB_PARTMAPS(sb)[partition].
|
UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table,
|
||||||
s_fspace.s_table, partition, goal,
|
partition, goal, err);
|
||||||
err);
|
|
||||||
} else {
|
} else {
|
||||||
*err = -EIO;
|
*err = -EIO;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -111,7 +111,7 @@ int main(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* defined(TEST) */
|
#endif /* defined(TEST) */
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
#if defined(GENERATE)
|
#if defined(GENERATE)
|
||||||
@ -169,4 +169,4 @@ int main(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* defined(GENERATE) */
|
#endif /* defined(GENERATE) */
|
||||||
|
60
fs/udf/dir.c
60
fs/udf/dir.c
@ -43,10 +43,10 @@ static int do_udf_readdir(struct inode *, struct file *, filldir_t, void *);
|
|||||||
/* readdir and lookup functions */
|
/* readdir and lookup functions */
|
||||||
|
|
||||||
const struct file_operations udf_dir_operations = {
|
const struct file_operations udf_dir_operations = {
|
||||||
.read = generic_read_dir,
|
.read = generic_read_dir,
|
||||||
.readdir = udf_readdir,
|
.readdir = udf_readdir,
|
||||||
.ioctl = udf_ioctl,
|
.ioctl = udf_ioctl,
|
||||||
.fsync = udf_fsync_file,
|
.fsync = udf_fsync_file,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -83,8 +83,7 @@ int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
|
|||||||
lock_kernel();
|
lock_kernel();
|
||||||
|
|
||||||
if (filp->f_pos == 0) {
|
if (filp->f_pos == 0) {
|
||||||
if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) <
|
if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) < 0) {
|
||||||
0) {
|
|
||||||
unlock_kernel();
|
unlock_kernel();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -93,7 +92,7 @@ int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
|
|||||||
|
|
||||||
result = do_udf_readdir(dir, filp, filldir, dirent);
|
result = do_udf_readdir(dir, filp, filldir, dirent);
|
||||||
unlock_kernel();
|
unlock_kernel();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -125,21 +124,20 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
|
|||||||
if (nf_pos == 0)
|
if (nf_pos == 0)
|
||||||
nf_pos = (udf_ext0_offset(dir) >> 2);
|
nf_pos = (udf_ext0_offset(dir) >> 2);
|
||||||
|
|
||||||
fibh.soffset = fibh.eoffset =
|
fibh.soffset = fibh.eoffset = (nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
|
||||||
(nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
|
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
|
||||||
if (UDF_I_ALLOCTYPE(dir) == 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 - 2),
|
||||||
&epos, &eloc, &elen,
|
&epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
|
||||||
&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) {
|
||||||
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
|
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
|
||||||
epos.offset -= sizeof(short_ad);
|
epos.offset -= sizeof(short_ad);
|
||||||
else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
|
else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
|
||||||
epos.offset -= sizeof(long_ad);
|
epos.offset -= sizeof(long_ad);
|
||||||
} else
|
} else {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) {
|
if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) {
|
||||||
brelse(epos.bh);
|
brelse(epos.bh);
|
||||||
@ -149,15 +147,11 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
|
|||||||
if (!(offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1))) {
|
if (!(offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1))) {
|
||||||
i = 16 >> (dir->i_sb->s_blocksize_bits - 9);
|
i = 16 >> (dir->i_sb->s_blocksize_bits - 9);
|
||||||
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) -
|
i = (elen >> dir->i_sb->s_blocksize_bits) - offset;
|
||||||
offset;
|
|
||||||
for (num = 0; i > 0; i--) {
|
for (num = 0; i > 0; i--) {
|
||||||
block =
|
block = udf_get_lb_pblock(dir->i_sb, eloc, offset + i);
|
||||||
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)
|
if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp))
|
||||||
&& !buffer_locked(tmp))
|
|
||||||
bha[num++] = tmp;
|
bha[num++] = tmp;
|
||||||
else
|
else
|
||||||
brelse(tmp);
|
brelse(tmp);
|
||||||
@ -178,7 +172,6 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
|
|||||||
|
|
||||||
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);
|
||||||
|
|
||||||
if (!fi) {
|
if (!fi) {
|
||||||
if (fibh.sbh != fibh.ebh)
|
if (fibh.sbh != fibh.ebh)
|
||||||
brelse(fibh.ebh);
|
brelse(fibh.ebh);
|
||||||
@ -190,19 +183,16 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
|
|||||||
liu = le16_to_cpu(cfi.lengthOfImpUse);
|
liu = le16_to_cpu(cfi.lengthOfImpUse);
|
||||||
lfi = cfi.lengthFileIdent;
|
lfi = cfi.lengthFileIdent;
|
||||||
|
|
||||||
if (fibh.sbh == fibh.ebh)
|
if (fibh.sbh == fibh.ebh) {
|
||||||
nameptr = fi->fileIdent + liu;
|
nameptr = fi->fileIdent + liu;
|
||||||
else {
|
} else {
|
||||||
int poffset; /* Unpaded ending offset */
|
int poffset; /* Unpaded ending offset */
|
||||||
|
|
||||||
poffset =
|
poffset = fibh.soffset + sizeof(struct fileIdentDesc) + liu + lfi;
|
||||||
fibh.soffset + sizeof(struct fileIdentDesc) + liu +
|
|
||||||
lfi;
|
|
||||||
|
|
||||||
if (poffset >= lfi)
|
if (poffset >= lfi) {
|
||||||
nameptr =
|
nameptr = (char *)(fibh.ebh->b_data + poffset - lfi);
|
||||||
(char *)(fibh.ebh->b_data + poffset - lfi);
|
} else {
|
||||||
else {
|
|
||||||
nameptr = fname;
|
nameptr = fname;
|
||||||
memcpy(nameptr, fi->fileIdent + liu,
|
memcpy(nameptr, fi->fileIdent + liu,
|
||||||
lfi - poffset);
|
lfi - poffset);
|
||||||
@ -235,17 +225,15 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flen) {
|
if (flen) {
|
||||||
if (filldir
|
if (filldir(dirent, fname, flen, filp->f_pos, iblock, dt_type) < 0) {
|
||||||
(dirent, fname, flen, filp->f_pos, iblock,
|
|
||||||
dt_type) < 0) {
|
|
||||||
if (fibh.sbh != fibh.ebh)
|
if (fibh.sbh != fibh.ebh)
|
||||||
brelse(fibh.ebh);
|
brelse(fibh.ebh);
|
||||||
brelse(fibh.sbh);
|
brelse(fibh.sbh);
|
||||||
brelse(epos.bh);
|
brelse(epos.bh);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* end while */
|
} /* end while */
|
||||||
|
|
||||||
filp->f_pos = nf_pos + 1;
|
filp->f_pos = nf_pos + 1;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad,
|
|||||||
|
|
||||||
*error = 0;
|
*error = 0;
|
||||||
|
|
||||||
ad = (uint8_t *) (*bh)->b_data + *offset;
|
ad = (uint8_t *)(*bh)->b_data + *offset;
|
||||||
*offset += ad_size;
|
*offset += ad_size;
|
||||||
|
|
||||||
if (!ad) {
|
if (!ad) {
|
||||||
@ -51,7 +51,7 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad,
|
|||||||
ad = tmpad;
|
ad = tmpad;
|
||||||
|
|
||||||
remainder = dir->i_sb->s_blocksize - loffset;
|
remainder = dir->i_sb->s_blocksize - loffset;
|
||||||
memcpy((uint8_t *) ad, (*bh)->b_data + loffset, remainder);
|
memcpy((uint8_t *)ad, (*bh)->b_data + loffset, remainder);
|
||||||
|
|
||||||
brelse(*bh);
|
brelse(*bh);
|
||||||
block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos);
|
block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos);
|
||||||
@ -60,10 +60,10 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad,
|
|||||||
if (!((*bh) = udf_tread(dir->i_sb, block)))
|
if (!((*bh) = udf_tread(dir->i_sb, block)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
memcpy((uint8_t *) ad + remainder, (*bh)->b_data,
|
memcpy((uint8_t *)ad + remainder, (*bh)->b_data, ad_size - remainder);
|
||||||
ad_size - remainder);
|
|
||||||
*offset = ad_size - remainder;
|
*offset = ad_size - remainder;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ad;
|
return ad;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -86,15 +86,13 @@ 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,
|
dir->i_sb->s_blocksize, &(fibh->eoffset));
|
||||||
&(fibh->eoffset));
|
|
||||||
|
|
||||||
if (!fi)
|
if (!fi)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
*nf_pos += ((fibh->eoffset - fibh->soffset) >> 2);
|
*nf_pos += ((fibh->eoffset - fibh->soffset) >> 2);
|
||||||
|
|
||||||
memcpy((uint8_t *) cfi, (uint8_t *) fi,
|
memcpy((uint8_t *)cfi, (uint8_t *)fi,
|
||||||
sizeof(struct fileIdentDesc));
|
sizeof(struct fileIdentDesc));
|
||||||
|
|
||||||
return fi;
|
return fi;
|
||||||
@ -121,21 +119,14 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
|
|||||||
return NULL;
|
return NULL;
|
||||||
fibh->soffset = fibh->eoffset = 0;
|
fibh->soffset = fibh->eoffset = 0;
|
||||||
|
|
||||||
if (!
|
if (!(*offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1))) {
|
||||||
(*offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1)))
|
|
||||||
{
|
|
||||||
i = 16 >> (dir->i_sb->s_blocksize_bits - 9);
|
i = 16 >> (dir->i_sb->s_blocksize_bits - 9);
|
||||||
if (i + *offset >
|
if (i + *offset > (*elen >> dir->i_sb->s_blocksize_bits))
|
||||||
(*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 =
|
block = udf_get_lb_pblock(dir->i_sb, *eloc, *offset + i);
|
||||||
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)
|
if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp))
|
||||||
&& !buffer_locked(tmp))
|
|
||||||
bha[num++] = tmp;
|
bha[num++] = tmp;
|
||||||
else
|
else
|
||||||
brelse(tmp);
|
brelse(tmp);
|
||||||
@ -160,7 +151,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
|
|||||||
*nf_pos += ((fibh->eoffset - fibh->soffset) >> 2);
|
*nf_pos += ((fibh->eoffset - fibh->soffset) >> 2);
|
||||||
|
|
||||||
if (fibh->eoffset <= dir->i_sb->s_blocksize) {
|
if (fibh->eoffset <= dir->i_sb->s_blocksize) {
|
||||||
memcpy((uint8_t *) cfi, (uint8_t *) fi,
|
memcpy((uint8_t *)cfi, (uint8_t *)fi,
|
||||||
sizeof(struct fileIdentDesc));
|
sizeof(struct fileIdentDesc));
|
||||||
} else if (fibh->eoffset > dir->i_sb->s_blocksize) {
|
} else if (fibh->eoffset > dir->i_sb->s_blocksize) {
|
||||||
int lextoffset = epos->offset;
|
int lextoffset = epos->offset;
|
||||||
@ -187,21 +178,17 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
|
|||||||
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,
|
memcpy((uint8_t *)cfi - fibh->soffset, fibh->ebh->b_data,
|
||||||
fibh->ebh->b_data,
|
|
||||||
sizeof(struct fileIdentDesc) + fibh->soffset);
|
sizeof(struct fileIdentDesc) + fibh->soffset);
|
||||||
|
|
||||||
fi_len =
|
fi_len = (sizeof(struct fileIdentDesc) + cfi->lengthFileIdent +
|
||||||
(sizeof(struct fileIdentDesc) +
|
le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3;
|
||||||
cfi->lengthFileIdent +
|
|
||||||
le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3;
|
|
||||||
|
|
||||||
*nf_pos +=
|
*nf_pos += ((fi_len - (fibh->eoffset - fibh->soffset)) >> 2);
|
||||||
((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,
|
||||||
sizeof(struct fileIdentDesc));
|
sizeof(struct fileIdentDesc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,9 +224,10 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
|
|||||||
}
|
}
|
||||||
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;
|
||||||
@ -270,22 +258,20 @@ static extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr =
|
ptr = (uint8_t *)(fe->extendedAttr) + le32_to_cpu(fe->lengthExtendedAttr);
|
||||||
(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;
|
||||||
|
|
||||||
*offset = *offset + sizeof(extent_ad);
|
*offset = *offset + sizeof(extent_ad);
|
||||||
return ext;
|
return ext;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
short_ad *udf_get_fileshortad(uint8_t * ptr, int maxoffset, int *offset,
|
short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, int *offset,
|
||||||
int inc)
|
int inc)
|
||||||
{
|
{
|
||||||
short_ad *sa;
|
short_ad *sa;
|
||||||
@ -297,7 +283,7 @@ 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 if ((sa = (short_ad *)ptr)->extLength == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (inc)
|
if (inc)
|
||||||
@ -305,7 +291,7 @@ short_ad *udf_get_fileshortad(uint8_t * ptr, int maxoffset, int *offset,
|
|||||||
return sa;
|
return sa;
|
||||||
}
|
}
|
||||||
|
|
||||||
long_ad *udf_get_filelongad(uint8_t * ptr, int maxoffset, int *offset, int inc)
|
long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, int *offset, int inc)
|
||||||
{
|
{
|
||||||
long_ad *la;
|
long_ad *la;
|
||||||
|
|
||||||
@ -316,7 +302,7 @@ 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 if ((la = (long_ad *)ptr)->extLength == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (inc)
|
if (inc)
|
||||||
|
@ -39,8 +39,8 @@
|
|||||||
|
|
||||||
/* Character set specification (ECMA 167r3 1/7.2.1) */
|
/* Character set specification (ECMA 167r3 1/7.2.1) */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t charSetType;
|
uint8_t charSetType;
|
||||||
uint8_t charSetInfo[63];
|
uint8_t charSetInfo[63];
|
||||||
} __attribute__ ((packed)) charspec;
|
} __attribute__ ((packed)) charspec;
|
||||||
|
|
||||||
/* Character Set Type (ECMA 167r3 1/7.2.1.1) */
|
/* Character Set Type (ECMA 167r3 1/7.2.1.1) */
|
||||||
@ -54,33 +54,33 @@ typedef struct {
|
|||||||
#define CHARSPEC_TYPE_CS7 0x07 /* (1/7.2.9) */
|
#define CHARSPEC_TYPE_CS7 0x07 /* (1/7.2.9) */
|
||||||
#define CHARSPEC_TYPE_CS8 0x08 /* (1/7.2.10) */
|
#define CHARSPEC_TYPE_CS8 0x08 /* (1/7.2.10) */
|
||||||
|
|
||||||
typedef uint8_t dstring;
|
typedef uint8_t dstring;
|
||||||
|
|
||||||
/* Timestamp (ECMA 167r3 1/7.3) */
|
/* Timestamp (ECMA 167r3 1/7.3) */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
__le16 typeAndTimezone;
|
__le16 typeAndTimezone;
|
||||||
__le16 year;
|
__le16 year;
|
||||||
uint8_t month;
|
uint8_t month;
|
||||||
uint8_t day;
|
uint8_t day;
|
||||||
uint8_t hour;
|
uint8_t hour;
|
||||||
uint8_t minute;
|
uint8_t minute;
|
||||||
uint8_t second;
|
uint8_t second;
|
||||||
uint8_t centiseconds;
|
uint8_t centiseconds;
|
||||||
uint8_t hundredsOfMicroseconds;
|
uint8_t hundredsOfMicroseconds;
|
||||||
uint8_t microseconds;
|
uint8_t microseconds;
|
||||||
} __attribute__ ((packed)) timestamp;
|
} __attribute__ ((packed)) timestamp;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t typeAndTimezone;
|
uint16_t typeAndTimezone;
|
||||||
int16_t year;
|
int16_t year;
|
||||||
uint8_t month;
|
uint8_t month;
|
||||||
uint8_t day;
|
uint8_t day;
|
||||||
uint8_t hour;
|
uint8_t hour;
|
||||||
uint8_t minute;
|
uint8_t minute;
|
||||||
uint8_t second;
|
uint8_t second;
|
||||||
uint8_t centiseconds;
|
uint8_t centiseconds;
|
||||||
uint8_t hundredsOfMicroseconds;
|
uint8_t hundredsOfMicroseconds;
|
||||||
uint8_t microseconds;
|
uint8_t microseconds;
|
||||||
} __attribute__ ((packed)) kernel_timestamp;
|
} __attribute__ ((packed)) kernel_timestamp;
|
||||||
|
|
||||||
/* Type and Time Zone (ECMA 167r3 1/7.3.1) */
|
/* Type and Time Zone (ECMA 167r3 1/7.3.1) */
|
||||||
@ -92,9 +92,9 @@ typedef struct {
|
|||||||
|
|
||||||
/* Entity identifier (ECMA 167r3 1/7.4) */
|
/* Entity identifier (ECMA 167r3 1/7.4) */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
uint8_t ident[23];
|
uint8_t ident[23];
|
||||||
uint8_t identSuffix[8];
|
uint8_t identSuffix[8];
|
||||||
} __attribute__ ((packed)) regid;
|
} __attribute__ ((packed)) regid;
|
||||||
|
|
||||||
/* Flags (ECMA 167r3 1/7.4.1) */
|
/* Flags (ECMA 167r3 1/7.4.1) */
|
||||||
@ -104,10 +104,10 @@ typedef struct {
|
|||||||
/* Volume Structure Descriptor (ECMA 167r3 2/9.1) */
|
/* Volume Structure Descriptor (ECMA 167r3 2/9.1) */
|
||||||
#define VSD_STD_ID_LEN 5
|
#define VSD_STD_ID_LEN 5
|
||||||
struct volStructDesc {
|
struct volStructDesc {
|
||||||
uint8_t structType;
|
uint8_t structType;
|
||||||
uint8_t stdIdent[VSD_STD_ID_LEN];
|
uint8_t stdIdent[VSD_STD_ID_LEN];
|
||||||
uint8_t structVersion;
|
uint8_t structVersion;
|
||||||
uint8_t structData[2041];
|
uint8_t structData[2041];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Standard Identifier (EMCA 167r2 2/9.1.2) */
|
/* Standard Identifier (EMCA 167r2 2/9.1.2) */
|
||||||
@ -123,36 +123,36 @@ struct volStructDesc {
|
|||||||
|
|
||||||
/* Beginning Extended Area Descriptor (ECMA 167r3 2/9.2) */
|
/* Beginning Extended Area Descriptor (ECMA 167r3 2/9.2) */
|
||||||
struct beginningExtendedAreaDesc {
|
struct beginningExtendedAreaDesc {
|
||||||
uint8_t structType;
|
uint8_t structType;
|
||||||
uint8_t stdIdent[VSD_STD_ID_LEN];
|
uint8_t stdIdent[VSD_STD_ID_LEN];
|
||||||
uint8_t structVersion;
|
uint8_t structVersion;
|
||||||
uint8_t structData[2041];
|
uint8_t structData[2041];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Terminating Extended Area Descriptor (ECMA 167r3 2/9.3) */
|
/* Terminating Extended Area Descriptor (ECMA 167r3 2/9.3) */
|
||||||
struct terminatingExtendedAreaDesc {
|
struct terminatingExtendedAreaDesc {
|
||||||
uint8_t structType;
|
uint8_t structType;
|
||||||
uint8_t stdIdent[VSD_STD_ID_LEN];
|
uint8_t stdIdent[VSD_STD_ID_LEN];
|
||||||
uint8_t structVersion;
|
uint8_t structVersion;
|
||||||
uint8_t structData[2041];
|
uint8_t structData[2041];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Boot Descriptor (ECMA 167r3 2/9.4) */
|
/* Boot Descriptor (ECMA 167r3 2/9.4) */
|
||||||
struct bootDesc {
|
struct bootDesc {
|
||||||
uint8_t structType;
|
uint8_t structType;
|
||||||
uint8_t stdIdent[VSD_STD_ID_LEN];
|
uint8_t stdIdent[VSD_STD_ID_LEN];
|
||||||
uint8_t structVersion;
|
uint8_t structVersion;
|
||||||
uint8_t reserved1;
|
uint8_t reserved1;
|
||||||
regid archType;
|
regid archType;
|
||||||
regid bootIdent;
|
regid bootIdent;
|
||||||
__le32 bootExtLocation;
|
__le32 bootExtLocation;
|
||||||
__le32 bootExtLength;
|
__le32 bootExtLength;
|
||||||
__le64 loadAddress;
|
__le64 loadAddress;
|
||||||
__le64 startAddress;
|
__le64 startAddress;
|
||||||
timestamp descCreationDateAndTime;
|
timestamp descCreationDateAndTime;
|
||||||
__le16 flags;
|
__le16 flags;
|
||||||
uint8_t reserved2[32];
|
uint8_t reserved2[32];
|
||||||
uint8_t bootUse[1906];
|
uint8_t bootUse[1906];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Flags (ECMA 167r3 2/9.4.12) */
|
/* Flags (ECMA 167r3 2/9.4.12) */
|
||||||
@ -160,25 +160,25 @@ struct bootDesc {
|
|||||||
|
|
||||||
/* Extent Descriptor (ECMA 167r3 3/7.1) */
|
/* Extent Descriptor (ECMA 167r3 3/7.1) */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
__le32 extLength;
|
__le32 extLength;
|
||||||
__le32 extLocation;
|
__le32 extLocation;
|
||||||
} __attribute__ ((packed)) extent_ad;
|
} __attribute__ ((packed)) extent_ad;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t extLength;
|
uint32_t extLength;
|
||||||
uint32_t extLocation;
|
uint32_t extLocation;
|
||||||
} kernel_extent_ad;
|
} kernel_extent_ad;
|
||||||
|
|
||||||
/* Descriptor Tag (ECMA 167r3 3/7.2) */
|
/* Descriptor Tag (ECMA 167r3 3/7.2) */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
__le16 tagIdent;
|
__le16 tagIdent;
|
||||||
__le16 descVersion;
|
__le16 descVersion;
|
||||||
uint8_t tagChecksum;
|
uint8_t tagChecksum;
|
||||||
uint8_t reserved;
|
uint8_t reserved;
|
||||||
__le16 tagSerialNum;
|
__le16 tagSerialNum;
|
||||||
__le16 descCRC;
|
__le16 descCRC;
|
||||||
__le16 descCRCLength;
|
__le16 descCRCLength;
|
||||||
__le32 tagLocation;
|
__le32 tagLocation;
|
||||||
} __attribute__ ((packed)) tag;
|
} __attribute__ ((packed)) tag;
|
||||||
|
|
||||||
/* Tag Identifier (ECMA 167r3 3/7.2.1) */
|
/* Tag Identifier (ECMA 167r3 3/7.2.1) */
|
||||||
@ -194,37 +194,37 @@ typedef struct {
|
|||||||
|
|
||||||
/* NSR Descriptor (ECMA 167r3 3/9.1) */
|
/* NSR Descriptor (ECMA 167r3 3/9.1) */
|
||||||
struct NSRDesc {
|
struct NSRDesc {
|
||||||
uint8_t structType;
|
uint8_t structType;
|
||||||
uint8_t stdIdent[VSD_STD_ID_LEN];
|
uint8_t stdIdent[VSD_STD_ID_LEN];
|
||||||
uint8_t structVersion;
|
uint8_t structVersion;
|
||||||
uint8_t reserved;
|
uint8_t reserved;
|
||||||
uint8_t structData[2040];
|
uint8_t structData[2040];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Primary Volume Descriptor (ECMA 167r3 3/10.1) */
|
/* Primary Volume Descriptor (ECMA 167r3 3/10.1) */
|
||||||
struct primaryVolDesc {
|
struct primaryVolDesc {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
__le32 volDescSeqNum;
|
__le32 volDescSeqNum;
|
||||||
__le32 primaryVolDescNum;
|
__le32 primaryVolDescNum;
|
||||||
dstring volIdent[32];
|
dstring volIdent[32];
|
||||||
__le16 volSeqNum;
|
__le16 volSeqNum;
|
||||||
__le16 maxVolSeqNum;
|
__le16 maxVolSeqNum;
|
||||||
__le16 interchangeLvl;
|
__le16 interchangeLvl;
|
||||||
__le16 maxInterchangeLvl;
|
__le16 maxInterchangeLvl;
|
||||||
__le32 charSetList;
|
__le32 charSetList;
|
||||||
__le32 maxCharSetList;
|
__le32 maxCharSetList;
|
||||||
dstring volSetIdent[128];
|
dstring volSetIdent[128];
|
||||||
charspec descCharSet;
|
charspec descCharSet;
|
||||||
charspec explanatoryCharSet;
|
charspec explanatoryCharSet;
|
||||||
extent_ad volAbstract;
|
extent_ad volAbstract;
|
||||||
extent_ad volCopyright;
|
extent_ad volCopyright;
|
||||||
regid appIdent;
|
regid appIdent;
|
||||||
timestamp recordingDateAndTime;
|
timestamp recordingDateAndTime;
|
||||||
regid impIdent;
|
regid impIdent;
|
||||||
uint8_t impUse[64];
|
uint8_t impUse[64];
|
||||||
__le32 predecessorVolDescSeqLocation;
|
__le32 predecessorVolDescSeqLocation;
|
||||||
__le16 flags;
|
__le16 flags;
|
||||||
uint8_t reserved[22];
|
uint8_t reserved[22];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Flags (ECMA 167r3 3/10.1.21) */
|
/* Flags (ECMA 167r3 3/10.1.21) */
|
||||||
@ -232,26 +232,26 @@ struct primaryVolDesc {
|
|||||||
|
|
||||||
/* Anchor Volume Descriptor Pointer (ECMA 167r3 3/10.2) */
|
/* Anchor Volume Descriptor Pointer (ECMA 167r3 3/10.2) */
|
||||||
struct anchorVolDescPtr {
|
struct anchorVolDescPtr {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
extent_ad mainVolDescSeqExt;
|
extent_ad mainVolDescSeqExt;
|
||||||
extent_ad reserveVolDescSeqExt;
|
extent_ad reserveVolDescSeqExt;
|
||||||
uint8_t reserved[480];
|
uint8_t reserved[480];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Volume Descriptor Pointer (ECMA 167r3 3/10.3) */
|
/* Volume Descriptor Pointer (ECMA 167r3 3/10.3) */
|
||||||
struct volDescPtr {
|
struct volDescPtr {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
__le32 volDescSeqNum;
|
__le32 volDescSeqNum;
|
||||||
extent_ad nextVolDescSeqExt;
|
extent_ad nextVolDescSeqExt;
|
||||||
uint8_t reserved[484];
|
uint8_t reserved[484];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Implementation Use Volume Descriptor (ECMA 167r3 3/10.4) */
|
/* Implementation Use Volume Descriptor (ECMA 167r3 3/10.4) */
|
||||||
struct impUseVolDesc {
|
struct impUseVolDesc {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
__le32 volDescSeqNum;
|
__le32 volDescSeqNum;
|
||||||
regid impIdent;
|
regid impIdent;
|
||||||
uint8_t impUse[460];
|
uint8_t impUse[460];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Partition Descriptor (ECMA 167r3 3/10.5) */
|
/* Partition Descriptor (ECMA 167r3 3/10.5) */
|
||||||
@ -291,26 +291,26 @@ struct partitionDesc {
|
|||||||
|
|
||||||
/* Logical Volume Descriptor (ECMA 167r3 3/10.6) */
|
/* Logical Volume Descriptor (ECMA 167r3 3/10.6) */
|
||||||
struct logicalVolDesc {
|
struct logicalVolDesc {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
__le32 volDescSeqNum;
|
__le32 volDescSeqNum;
|
||||||
charspec descCharSet;
|
charspec descCharSet;
|
||||||
dstring logicalVolIdent[128];
|
dstring logicalVolIdent[128];
|
||||||
__le32 logicalBlockSize;
|
__le32 logicalBlockSize;
|
||||||
regid domainIdent;
|
regid domainIdent;
|
||||||
uint8_t logicalVolContentsUse[16];
|
uint8_t logicalVolContentsUse[16];
|
||||||
__le32 mapTableLength;
|
__le32 mapTableLength;
|
||||||
__le32 numPartitionMaps;
|
__le32 numPartitionMaps;
|
||||||
regid impIdent;
|
regid impIdent;
|
||||||
uint8_t impUse[128];
|
uint8_t impUse[128];
|
||||||
extent_ad integritySeqExt;
|
extent_ad integritySeqExt;
|
||||||
uint8_t partitionMaps[0];
|
uint8_t partitionMaps[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Generic Partition Map (ECMA 167r3 3/10.7.1) */
|
/* Generic Partition Map (ECMA 167r3 3/10.7.1) */
|
||||||
struct genericPartitionMap {
|
struct genericPartitionMap {
|
||||||
uint8_t partitionMapType;
|
uint8_t partitionMapType;
|
||||||
uint8_t partitionMapLength;
|
uint8_t partitionMapLength;
|
||||||
uint8_t partitionMapping[0];
|
uint8_t partitionMapping[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Partition Map Type (ECMA 167r3 3/10.7.1.1) */
|
/* Partition Map Type (ECMA 167r3 3/10.7.1.1) */
|
||||||
@ -320,45 +320,45 @@ struct genericPartitionMap {
|
|||||||
|
|
||||||
/* Type 1 Partition Map (ECMA 167r3 3/10.7.2) */
|
/* Type 1 Partition Map (ECMA 167r3 3/10.7.2) */
|
||||||
struct genericPartitionMap1 {
|
struct genericPartitionMap1 {
|
||||||
uint8_t partitionMapType;
|
uint8_t partitionMapType;
|
||||||
uint8_t partitionMapLength;
|
uint8_t partitionMapLength;
|
||||||
__le16 volSeqNum;
|
__le16 volSeqNum;
|
||||||
__le16 partitionNum;
|
__le16 partitionNum;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Type 2 Partition Map (ECMA 167r3 3/10.7.3) */
|
/* Type 2 Partition Map (ECMA 167r3 3/10.7.3) */
|
||||||
struct genericPartitionMap2 {
|
struct genericPartitionMap2 {
|
||||||
uint8_t partitionMapType;
|
uint8_t partitionMapType;
|
||||||
uint8_t partitionMapLength;
|
uint8_t partitionMapLength;
|
||||||
uint8_t partitionIdent[62];
|
uint8_t partitionIdent[62];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Unallocated Space Descriptor (ECMA 167r3 3/10.8) */
|
/* Unallocated Space Descriptor (ECMA 167r3 3/10.8) */
|
||||||
struct unallocSpaceDesc {
|
struct unallocSpaceDesc {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
__le32 volDescSeqNum;
|
__le32 volDescSeqNum;
|
||||||
__le32 numAllocDescs;
|
__le32 numAllocDescs;
|
||||||
extent_ad allocDescs[0];
|
extent_ad allocDescs[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Terminating Descriptor (ECMA 167r3 3/10.9) */
|
/* Terminating Descriptor (ECMA 167r3 3/10.9) */
|
||||||
struct terminatingDesc {
|
struct terminatingDesc {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
uint8_t reserved[496];
|
uint8_t reserved[496];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Logical Volume Integrity Descriptor (ECMA 167r3 3/10.10) */
|
/* Logical Volume Integrity Descriptor (ECMA 167r3 3/10.10) */
|
||||||
struct logicalVolIntegrityDesc {
|
struct logicalVolIntegrityDesc {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
timestamp recordingDateAndTime;
|
timestamp recordingDateAndTime;
|
||||||
__le32 integrityType;
|
__le32 integrityType;
|
||||||
extent_ad nextIntegrityExt;
|
extent_ad nextIntegrityExt;
|
||||||
uint8_t logicalVolContentsUse[32];
|
uint8_t logicalVolContentsUse[32];
|
||||||
__le32 numOfPartitions;
|
__le32 numOfPartitions;
|
||||||
__le32 lengthOfImpUse;
|
__le32 lengthOfImpUse;
|
||||||
__le32 freeSpaceTable[0];
|
__le32 freeSpaceTable[0];
|
||||||
__le32 sizeTable[0];
|
__le32 sizeTable[0];
|
||||||
uint8_t impUse[0];
|
uint8_t impUse[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Integrity Type (ECMA 167r3 3/10.10.3) */
|
/* Integrity Type (ECMA 167r3 3/10.10.3) */
|
||||||
@ -367,48 +367,48 @@ struct logicalVolIntegrityDesc {
|
|||||||
|
|
||||||
/* Recorded Address (ECMA 167r3 4/7.1) */
|
/* Recorded Address (ECMA 167r3 4/7.1) */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
__le32 logicalBlockNum;
|
__le32 logicalBlockNum;
|
||||||
__le16 partitionReferenceNum;
|
__le16 partitionReferenceNum;
|
||||||
} __attribute__ ((packed)) lb_addr;
|
} __attribute__ ((packed)) lb_addr;
|
||||||
|
|
||||||
/* ... and its in-core analog */
|
/* ... and its in-core analog */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t logicalBlockNum;
|
uint32_t logicalBlockNum;
|
||||||
uint16_t partitionReferenceNum;
|
uint16_t partitionReferenceNum;
|
||||||
} kernel_lb_addr;
|
} kernel_lb_addr;
|
||||||
|
|
||||||
/* Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */
|
/* Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
__le32 extLength;
|
__le32 extLength;
|
||||||
__le32 extPosition;
|
__le32 extPosition;
|
||||||
} __attribute__ ((packed)) short_ad;
|
} __attribute__ ((packed)) short_ad;
|
||||||
|
|
||||||
/* Long Allocation Descriptor (ECMA 167r3 4/14.14.2) */
|
/* Long Allocation Descriptor (ECMA 167r3 4/14.14.2) */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
__le32 extLength;
|
__le32 extLength;
|
||||||
lb_addr extLocation;
|
lb_addr extLocation;
|
||||||
uint8_t impUse[6];
|
uint8_t impUse[6];
|
||||||
} __attribute__ ((packed)) long_ad;
|
} __attribute__ ((packed)) long_ad;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t extLength;
|
uint32_t extLength;
|
||||||
kernel_lb_addr extLocation;
|
kernel_lb_addr extLocation;
|
||||||
uint8_t impUse[6];
|
uint8_t impUse[6];
|
||||||
} kernel_long_ad;
|
} kernel_long_ad;
|
||||||
|
|
||||||
/* Extended Allocation Descriptor (ECMA 167r3 4/14.14.3) */
|
/* Extended Allocation Descriptor (ECMA 167r3 4/14.14.3) */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
__le32 extLength;
|
__le32 extLength;
|
||||||
__le32 recordedLength;
|
__le32 recordedLength;
|
||||||
__le32 informationLength;
|
__le32 informationLength;
|
||||||
lb_addr extLocation;
|
lb_addr extLocation;
|
||||||
} __attribute__ ((packed)) ext_ad;
|
} __attribute__ ((packed)) ext_ad;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t extLength;
|
uint32_t extLength;
|
||||||
uint32_t recordedLength;
|
uint32_t recordedLength;
|
||||||
uint32_t informationLength;
|
uint32_t informationLength;
|
||||||
kernel_lb_addr extLocation;
|
kernel_lb_addr extLocation;
|
||||||
} kernel_ext_ad;
|
} kernel_ext_ad;
|
||||||
|
|
||||||
/* Descriptor Tag (ECMA 167r3 4/7.2 - See 3/7.2) */
|
/* Descriptor Tag (ECMA 167r3 4/7.2 - See 3/7.2) */
|
||||||
@ -428,48 +428,48 @@ typedef struct {
|
|||||||
|
|
||||||
/* File Set Descriptor (ECMA 167r3 4/14.1) */
|
/* File Set Descriptor (ECMA 167r3 4/14.1) */
|
||||||
struct fileSetDesc {
|
struct fileSetDesc {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
timestamp recordingDateAndTime;
|
timestamp recordingDateAndTime;
|
||||||
__le16 interchangeLvl;
|
__le16 interchangeLvl;
|
||||||
__le16 maxInterchangeLvl;
|
__le16 maxInterchangeLvl;
|
||||||
__le32 charSetList;
|
__le32 charSetList;
|
||||||
__le32 maxCharSetList;
|
__le32 maxCharSetList;
|
||||||
__le32 fileSetNum;
|
__le32 fileSetNum;
|
||||||
__le32 fileSetDescNum;
|
__le32 fileSetDescNum;
|
||||||
charspec logicalVolIdentCharSet;
|
charspec logicalVolIdentCharSet;
|
||||||
dstring logicalVolIdent[128];
|
dstring logicalVolIdent[128];
|
||||||
charspec fileSetCharSet;
|
charspec fileSetCharSet;
|
||||||
dstring fileSetIdent[32];
|
dstring fileSetIdent[32];
|
||||||
dstring copyrightFileIdent[32];
|
dstring copyrightFileIdent[32];
|
||||||
dstring abstractFileIdent[32];
|
dstring abstractFileIdent[32];
|
||||||
long_ad rootDirectoryICB;
|
long_ad rootDirectoryICB;
|
||||||
regid domainIdent;
|
regid domainIdent;
|
||||||
long_ad nextExt;
|
long_ad nextExt;
|
||||||
long_ad streamDirectoryICB;
|
long_ad streamDirectoryICB;
|
||||||
uint8_t reserved[32];
|
uint8_t reserved[32];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Partition Header Descriptor (ECMA 167r3 4/14.3) */
|
/* Partition Header Descriptor (ECMA 167r3 4/14.3) */
|
||||||
struct partitionHeaderDesc {
|
struct partitionHeaderDesc {
|
||||||
short_ad unallocSpaceTable;
|
short_ad unallocSpaceTable;
|
||||||
short_ad unallocSpaceBitmap;
|
short_ad unallocSpaceBitmap;
|
||||||
short_ad partitionIntegrityTable;
|
short_ad partitionIntegrityTable;
|
||||||
short_ad freedSpaceTable;
|
short_ad freedSpaceTable;
|
||||||
short_ad freedSpaceBitmap;
|
short_ad freedSpaceBitmap;
|
||||||
uint8_t reserved[88];
|
uint8_t reserved[88];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* File Identifier Descriptor (ECMA 167r3 4/14.4) */
|
/* File Identifier Descriptor (ECMA 167r3 4/14.4) */
|
||||||
struct fileIdentDesc {
|
struct fileIdentDesc {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
__le16 fileVersionNum;
|
__le16 fileVersionNum;
|
||||||
uint8_t fileCharacteristics;
|
uint8_t fileCharacteristics;
|
||||||
uint8_t lengthFileIdent;
|
uint8_t lengthFileIdent;
|
||||||
long_ad icb;
|
long_ad icb;
|
||||||
__le16 lengthOfImpUse;
|
__le16 lengthOfImpUse;
|
||||||
uint8_t impUse[0];
|
uint8_t impUse[0];
|
||||||
uint8_t fileIdent[0];
|
uint8_t fileIdent[0];
|
||||||
uint8_t padding[0];
|
uint8_t padding[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* File Characteristics (ECMA 167r3 4/14.4.3) */
|
/* File Characteristics (ECMA 167r3 4/14.4.3) */
|
||||||
@ -481,21 +481,21 @@ struct fileIdentDesc {
|
|||||||
|
|
||||||
/* Allocation Ext Descriptor (ECMA 167r3 4/14.5) */
|
/* Allocation Ext Descriptor (ECMA 167r3 4/14.5) */
|
||||||
struct allocExtDesc {
|
struct allocExtDesc {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
__le32 previousAllocExtLocation;
|
__le32 previousAllocExtLocation;
|
||||||
__le32 lengthAllocDescs;
|
__le32 lengthAllocDescs;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* ICB Tag (ECMA 167r3 4/14.6) */
|
/* ICB Tag (ECMA 167r3 4/14.6) */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
__le32 priorRecordedNumDirectEntries;
|
__le32 priorRecordedNumDirectEntries;
|
||||||
__le16 strategyType;
|
__le16 strategyType;
|
||||||
__le16 strategyParameter;
|
__le16 strategyParameter;
|
||||||
__le16 numEntries;
|
__le16 numEntries;
|
||||||
uint8_t reserved;
|
uint8_t reserved;
|
||||||
uint8_t fileType;
|
uint8_t fileType;
|
||||||
lb_addr parentICBLocation;
|
lb_addr parentICBLocation;
|
||||||
__le16 flags;
|
__le16 flags;
|
||||||
} __attribute__ ((packed)) icbtag;
|
} __attribute__ ((packed)) icbtag;
|
||||||
|
|
||||||
/* Strategy Type (ECMA 167r3 4/14.6.2) */
|
/* Strategy Type (ECMA 167r3 4/14.6.2) */
|
||||||
@ -541,41 +541,41 @@ typedef struct {
|
|||||||
|
|
||||||
/* Indirect Entry (ECMA 167r3 4/14.7) */
|
/* Indirect Entry (ECMA 167r3 4/14.7) */
|
||||||
struct indirectEntry {
|
struct indirectEntry {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
icbtag icbTag;
|
icbtag icbTag;
|
||||||
long_ad indirectICB;
|
long_ad indirectICB;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Terminal Entry (ECMA 167r3 4/14.8) */
|
/* Terminal Entry (ECMA 167r3 4/14.8) */
|
||||||
struct terminalEntry {
|
struct terminalEntry {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
icbtag icbTag;
|
icbtag icbTag;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* File Entry (ECMA 167r3 4/14.9) */
|
/* File Entry (ECMA 167r3 4/14.9) */
|
||||||
struct fileEntry {
|
struct fileEntry {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
icbtag icbTag;
|
icbtag icbTag;
|
||||||
__le32 uid;
|
__le32 uid;
|
||||||
__le32 gid;
|
__le32 gid;
|
||||||
__le32 permissions;
|
__le32 permissions;
|
||||||
__le16 fileLinkCount;
|
__le16 fileLinkCount;
|
||||||
uint8_t recordFormat;
|
uint8_t recordFormat;
|
||||||
uint8_t recordDisplayAttr;
|
uint8_t recordDisplayAttr;
|
||||||
__le32 recordLength;
|
__le32 recordLength;
|
||||||
__le64 informationLength;
|
__le64 informationLength;
|
||||||
__le64 logicalBlocksRecorded;
|
__le64 logicalBlocksRecorded;
|
||||||
timestamp accessTime;
|
timestamp accessTime;
|
||||||
timestamp modificationTime;
|
timestamp modificationTime;
|
||||||
timestamp attrTime;
|
timestamp attrTime;
|
||||||
__le32 checkpoint;
|
__le32 checkpoint;
|
||||||
long_ad extendedAttrICB;
|
long_ad extendedAttrICB;
|
||||||
regid impIdent;
|
regid impIdent;
|
||||||
__le64 uniqueID;
|
__le64 uniqueID;
|
||||||
__le32 lengthExtendedAttr;
|
__le32 lengthExtendedAttr;
|
||||||
__le32 lengthAllocDescs;
|
__le32 lengthAllocDescs;
|
||||||
uint8_t extendedAttr[0];
|
uint8_t extendedAttr[0];
|
||||||
uint8_t allocDescs[0];
|
uint8_t allocDescs[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Permissions (ECMA 167r3 4/14.9.5) */
|
/* Permissions (ECMA 167r3 4/14.9.5) */
|
||||||
@ -617,51 +617,51 @@ struct fileEntry {
|
|||||||
|
|
||||||
/* Extended Attribute Header Descriptor (ECMA 167r3 4/14.10.1) */
|
/* Extended Attribute Header Descriptor (ECMA 167r3 4/14.10.1) */
|
||||||
struct extendedAttrHeaderDesc {
|
struct extendedAttrHeaderDesc {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
__le32 impAttrLocation;
|
__le32 impAttrLocation;
|
||||||
__le32 appAttrLocation;
|
__le32 appAttrLocation;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Generic Format (ECMA 167r3 4/14.10.2) */
|
/* Generic Format (ECMA 167r3 4/14.10.2) */
|
||||||
struct genericFormat {
|
struct genericFormat {
|
||||||
__le32 attrType;
|
__le32 attrType;
|
||||||
uint8_t attrSubtype;
|
uint8_t attrSubtype;
|
||||||
uint8_t reserved[3];
|
uint8_t reserved[3];
|
||||||
__le32 attrLength;
|
__le32 attrLength;
|
||||||
uint8_t attrData[0];
|
uint8_t attrData[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Character Set Information (ECMA 167r3 4/14.10.3) */
|
/* Character Set Information (ECMA 167r3 4/14.10.3) */
|
||||||
struct charSetInfo {
|
struct charSetInfo {
|
||||||
__le32 attrType;
|
__le32 attrType;
|
||||||
uint8_t attrSubtype;
|
uint8_t attrSubtype;
|
||||||
uint8_t reserved[3];
|
uint8_t reserved[3];
|
||||||
__le32 attrLength;
|
__le32 attrLength;
|
||||||
__le32 escapeSeqLength;
|
__le32 escapeSeqLength;
|
||||||
uint8_t charSetType;
|
uint8_t charSetType;
|
||||||
uint8_t escapeSeq[0];
|
uint8_t escapeSeq[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Alternate Permissions (ECMA 167r3 4/14.10.4) */
|
/* Alternate Permissions (ECMA 167r3 4/14.10.4) */
|
||||||
struct altPerms {
|
struct altPerms {
|
||||||
__le32 attrType;
|
__le32 attrType;
|
||||||
uint8_t attrSubtype;
|
uint8_t attrSubtype;
|
||||||
uint8_t reserved[3];
|
uint8_t reserved[3];
|
||||||
__le32 attrLength;
|
__le32 attrLength;
|
||||||
__le16 ownerIdent;
|
__le16 ownerIdent;
|
||||||
__le16 groupIdent;
|
__le16 groupIdent;
|
||||||
__le16 permission;
|
__le16 permission;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* File Times Extended Attribute (ECMA 167r3 4/14.10.5) */
|
/* File Times Extended Attribute (ECMA 167r3 4/14.10.5) */
|
||||||
struct fileTimesExtAttr {
|
struct fileTimesExtAttr {
|
||||||
__le32 attrType;
|
__le32 attrType;
|
||||||
uint8_t attrSubtype;
|
uint8_t attrSubtype;
|
||||||
uint8_t reserved[3];
|
uint8_t reserved[3];
|
||||||
__le32 attrLength;
|
__le32 attrLength;
|
||||||
__le32 dataLength;
|
__le32 dataLength;
|
||||||
__le32 fileTimeExistence;
|
__le32 fileTimeExistence;
|
||||||
uint8_t fileTimes;
|
uint8_t fileTimes;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* FileTimeExistence (ECMA 167r3 4/14.10.5.6) */
|
/* FileTimeExistence (ECMA 167r3 4/14.10.5.6) */
|
||||||
@ -672,47 +672,47 @@ struct fileTimesExtAttr {
|
|||||||
|
|
||||||
/* Information Times Extended Attribute (ECMA 167r3 4/14.10.6) */
|
/* Information Times Extended Attribute (ECMA 167r3 4/14.10.6) */
|
||||||
struct infoTimesExtAttr {
|
struct infoTimesExtAttr {
|
||||||
__le32 attrType;
|
__le32 attrType;
|
||||||
uint8_t attrSubtype;
|
uint8_t attrSubtype;
|
||||||
uint8_t reserved[3];
|
uint8_t reserved[3];
|
||||||
__le32 attrLength;
|
__le32 attrLength;
|
||||||
__le32 dataLength;
|
__le32 dataLength;
|
||||||
__le32 infoTimeExistence;
|
__le32 infoTimeExistence;
|
||||||
uint8_t infoTimes[0];
|
uint8_t infoTimes[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Device Specification (ECMA 167r3 4/14.10.7) */
|
/* Device Specification (ECMA 167r3 4/14.10.7) */
|
||||||
struct deviceSpec {
|
struct deviceSpec {
|
||||||
__le32 attrType;
|
__le32 attrType;
|
||||||
uint8_t attrSubtype;
|
uint8_t attrSubtype;
|
||||||
uint8_t reserved[3];
|
uint8_t reserved[3];
|
||||||
__le32 attrLength;
|
__le32 attrLength;
|
||||||
__le32 impUseLength;
|
__le32 impUseLength;
|
||||||
__le32 majorDeviceIdent;
|
__le32 majorDeviceIdent;
|
||||||
__le32 minorDeviceIdent;
|
__le32 minorDeviceIdent;
|
||||||
uint8_t impUse[0];
|
uint8_t impUse[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Implementation Use Extended Attr (ECMA 167r3 4/14.10.8) */
|
/* Implementation Use Extended Attr (ECMA 167r3 4/14.10.8) */
|
||||||
struct impUseExtAttr {
|
struct impUseExtAttr {
|
||||||
__le32 attrType;
|
__le32 attrType;
|
||||||
uint8_t attrSubtype;
|
uint8_t attrSubtype;
|
||||||
uint8_t reserved[3];
|
uint8_t reserved[3];
|
||||||
__le32 attrLength;
|
__le32 attrLength;
|
||||||
__le32 impUseLength;
|
__le32 impUseLength;
|
||||||
regid impIdent;
|
regid impIdent;
|
||||||
uint8_t impUse[0];
|
uint8_t impUse[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Application Use Extended Attribute (ECMA 167r3 4/14.10.9) */
|
/* Application Use Extended Attribute (ECMA 167r3 4/14.10.9) */
|
||||||
struct appUseExtAttr {
|
struct appUseExtAttr {
|
||||||
__le32 attrType;
|
__le32 attrType;
|
||||||
uint8_t attrSubtype;
|
uint8_t attrSubtype;
|
||||||
uint8_t reserved[3];
|
uint8_t reserved[3];
|
||||||
__le32 attrLength;
|
__le32 attrLength;
|
||||||
__le32 appUseLength;
|
__le32 appUseLength;
|
||||||
regid appIdent;
|
regid appIdent;
|
||||||
uint8_t appUse[0];
|
uint8_t appUse[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#define EXTATTR_CHAR_SET 1
|
#define EXTATTR_CHAR_SET 1
|
||||||
@ -725,29 +725,29 @@ struct appUseExtAttr {
|
|||||||
|
|
||||||
/* Unallocated Space Entry (ECMA 167r3 4/14.11) */
|
/* Unallocated Space Entry (ECMA 167r3 4/14.11) */
|
||||||
struct unallocSpaceEntry {
|
struct unallocSpaceEntry {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
icbtag icbTag;
|
icbtag icbTag;
|
||||||
__le32 lengthAllocDescs;
|
__le32 lengthAllocDescs;
|
||||||
uint8_t allocDescs[0];
|
uint8_t allocDescs[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Space Bitmap Descriptor (ECMA 167r3 4/14.12) */
|
/* Space Bitmap Descriptor (ECMA 167r3 4/14.12) */
|
||||||
struct spaceBitmapDesc {
|
struct spaceBitmapDesc {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
__le32 numOfBits;
|
__le32 numOfBits;
|
||||||
__le32 numOfBytes;
|
__le32 numOfBytes;
|
||||||
uint8_t bitmap[0];
|
uint8_t bitmap[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Partition Integrity Entry (ECMA 167r3 4/14.13) */
|
/* Partition Integrity Entry (ECMA 167r3 4/14.13) */
|
||||||
struct partitionIntegrityEntry {
|
struct partitionIntegrityEntry {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
icbtag icbTag;
|
icbtag icbTag;
|
||||||
timestamp recordingDateAndTime;
|
timestamp recordingDateAndTime;
|
||||||
uint8_t integrityType;
|
uint8_t integrityType;
|
||||||
uint8_t reserved[175];
|
uint8_t reserved[175];
|
||||||
regid impIdent;
|
regid impIdent;
|
||||||
uint8_t impUse[256];
|
uint8_t impUse[256];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */
|
/* Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */
|
||||||
@ -764,46 +764,46 @@ struct partitionIntegrityEntry {
|
|||||||
|
|
||||||
/* Logical Volume Header Descriptor (ECMA 167r3 4/14.15) */
|
/* Logical Volume Header Descriptor (ECMA 167r3 4/14.15) */
|
||||||
struct logicalVolHeaderDesc {
|
struct logicalVolHeaderDesc {
|
||||||
__le64 uniqueID;
|
__le64 uniqueID;
|
||||||
uint8_t reserved[24];
|
uint8_t reserved[24];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Path Component (ECMA 167r3 4/14.16.1) */
|
/* Path Component (ECMA 167r3 4/14.16.1) */
|
||||||
struct pathComponent {
|
struct pathComponent {
|
||||||
uint8_t componentType;
|
uint8_t componentType;
|
||||||
uint8_t lengthComponentIdent;
|
uint8_t lengthComponentIdent;
|
||||||
__le16 componentFileVersionNum;
|
__le16 componentFileVersionNum;
|
||||||
dstring componentIdent[0];
|
dstring componentIdent[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* File Entry (ECMA 167r3 4/14.17) */
|
/* File Entry (ECMA 167r3 4/14.17) */
|
||||||
struct extendedFileEntry {
|
struct extendedFileEntry {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
icbtag icbTag;
|
icbtag icbTag;
|
||||||
__le32 uid;
|
__le32 uid;
|
||||||
__le32 gid;
|
__le32 gid;
|
||||||
__le32 permissions;
|
__le32 permissions;
|
||||||
__le16 fileLinkCount;
|
__le16 fileLinkCount;
|
||||||
uint8_t recordFormat;
|
uint8_t recordFormat;
|
||||||
uint8_t recordDisplayAttr;
|
uint8_t recordDisplayAttr;
|
||||||
__le32 recordLength;
|
__le32 recordLength;
|
||||||
__le64 informationLength;
|
__le64 informationLength;
|
||||||
__le64 objectSize;
|
__le64 objectSize;
|
||||||
__le64 logicalBlocksRecorded;
|
__le64 logicalBlocksRecorded;
|
||||||
timestamp accessTime;
|
timestamp accessTime;
|
||||||
timestamp modificationTime;
|
timestamp modificationTime;
|
||||||
timestamp createTime;
|
timestamp createTime;
|
||||||
timestamp attrTime;
|
timestamp attrTime;
|
||||||
__le32 checkpoint;
|
__le32 checkpoint;
|
||||||
__le32 reserved;
|
__le32 reserved;
|
||||||
long_ad extendedAttrICB;
|
long_ad extendedAttrICB;
|
||||||
long_ad streamDirectoryICB;
|
long_ad streamDirectoryICB;
|
||||||
regid impIdent;
|
regid impIdent;
|
||||||
__le64 uniqueID;
|
__le64 uniqueID;
|
||||||
__le32 lengthExtendedAttr;
|
__le32 lengthExtendedAttr;
|
||||||
__le32 lengthAllocDescs;
|
__le32 lengthAllocDescs;
|
||||||
uint8_t extendedAttr[0];
|
uint8_t extendedAttr[0];
|
||||||
uint8_t allocDescs[0];
|
uint8_t allocDescs[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#endif /* _ECMA_167_H */
|
#endif /* _ECMA_167_H */
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include <linux/udf_fs.h>
|
#include <linux/udf_fs.h>
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/string.h> /* memset */
|
#include <linux/string.h> /* memset */
|
||||||
#include <linux/capability.h>
|
#include <linux/capability.h>
|
||||||
#include <linux/errno.h>
|
#include <linux/errno.h>
|
||||||
#include <linux/smp_lock.h>
|
#include <linux/smp_lock.h>
|
||||||
@ -55,11 +55,11 @@ static int udf_adinicb_readpage(struct file *file, struct page *page)
|
|||||||
SetPageUptodate(page);
|
SetPageUptodate(page);
|
||||||
kunmap(page);
|
kunmap(page);
|
||||||
unlock_page(page);
|
unlock_page(page);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int udf_adinicb_writepage(struct page *page,
|
static int udf_adinicb_writepage(struct page *page, struct writeback_control *wbc)
|
||||||
struct writeback_control *wbc)
|
|
||||||
{
|
{
|
||||||
struct inode *inode = page->mapping->host;
|
struct inode *inode = page->mapping->host;
|
||||||
char *kaddr;
|
char *kaddr;
|
||||||
@ -72,6 +72,7 @@ static int udf_adinicb_writepage(struct page *page,
|
|||||||
SetPageUptodate(page);
|
SetPageUptodate(page);
|
||||||
kunmap(page);
|
kunmap(page);
|
||||||
unlock_page(page);
|
unlock_page(page);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,11 +101,11 @@ static int udf_adinicb_commit_write(struct file *file, struct page *page,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const struct address_space_operations udf_adinicb_aops = {
|
const struct address_space_operations udf_adinicb_aops = {
|
||||||
.readpage = udf_adinicb_readpage,
|
.readpage = udf_adinicb_readpage,
|
||||||
.writepage = udf_adinicb_writepage,
|
.writepage = udf_adinicb_writepage,
|
||||||
.sync_page = block_sync_page,
|
.sync_page = block_sync_page,
|
||||||
.prepare_write = udf_adinicb_prepare_write,
|
.prepare_write = udf_adinicb_prepare_write,
|
||||||
.commit_write = udf_adinicb_commit_write,
|
.commit_write = udf_adinicb_commit_write,
|
||||||
};
|
};
|
||||||
|
|
||||||
static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
|
static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
|
||||||
@ -122,8 +123,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 <
|
if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) +
|
||||||
(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) {
|
||||||
udf_debug("udf_expand_adinicb: err=%d\n", err);
|
udf_debug("udf_expand_adinicb: err=%d\n", err);
|
||||||
@ -138,9 +139,9 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
|
|||||||
}
|
}
|
||||||
|
|
||||||
retval = generic_file_aio_write(iocb, iov, nr_segs, ppos);
|
retval = generic_file_aio_write(iocb, iov, nr_segs, ppos);
|
||||||
|
|
||||||
if (retval > 0)
|
if (retval > 0)
|
||||||
mark_inode_dirty(inode);
|
mark_inode_dirty(inode);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,10 +182,12 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
|
|||||||
int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
|
int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
|
||||||
unsigned long arg)
|
unsigned long arg)
|
||||||
{
|
{
|
||||||
|
long old_block, new_block;
|
||||||
int result = -EINVAL;
|
int result = -EINVAL;
|
||||||
|
|
||||||
if (file_permission(filp, MAY_READ) != 0) {
|
if (file_permission(filp, MAY_READ) != 0) {
|
||||||
udf_debug("no permission to access inode %lu\n", inode->i_ino);
|
udf_debug("no permission to access inode %lu\n",
|
||||||
|
inode->i_ino);
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,26 +199,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,
|
return copy_to_user((char __user *)arg,
|
||||||
UDF_SB_VOLIDENT(inode->i_sb),
|
UDF_SB_VOLIDENT(inode->i_sb), 32) ? -EFAULT : 0;
|
||||||
32) ? -EFAULT : 0;
|
|
||||||
case UDF_RELOCATE_BLOCKS:
|
case UDF_RELOCATE_BLOCKS:
|
||||||
{
|
if (!capable(CAP_SYS_ADMIN))
|
||||||
long old, new;
|
return -EACCES;
|
||||||
|
if (get_user(old_block, (long __user *)arg))
|
||||||
if (!capable(CAP_SYS_ADMIN))
|
return -EFAULT;
|
||||||
return -EACCES;
|
if ((result = udf_relocate_blocks(inode->i_sb,
|
||||||
if (get_user(old, (long __user *)arg))
|
old_block, &new_block)) == 0)
|
||||||
return -EFAULT;
|
result = put_user(new_block, (long __user *)arg);
|
||||||
if ((result = udf_relocate_blocks(inode->i_sb,
|
return result;
|
||||||
old, &new)) == 0)
|
|
||||||
result = put_user(new, (long __user *)arg);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
case UDF_GETEASIZE:
|
case UDF_GETEASIZE:
|
||||||
result = put_user(UDF_I_LENEATTR(inode), (int __user *)arg);
|
result = put_user(UDF_I_LENEATTR(inode), (int __user *)arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UDF_GETEABLOCK:
|
case UDF_GETEABLOCK:
|
||||||
result = copy_to_user((char __user *)arg, UDF_I_DATA(inode),
|
result = copy_to_user((char __user *)arg, UDF_I_DATA(inode),
|
||||||
UDF_I_LENEATTR(inode)) ? -EFAULT : 0;
|
UDF_I_LENEATTR(inode)) ? -EFAULT : 0;
|
||||||
@ -248,16 +244,16 @@ static int udf_release_file(struct inode *inode, struct file *filp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const struct file_operations udf_file_operations = {
|
const struct file_operations udf_file_operations = {
|
||||||
.read = do_sync_read,
|
.read = do_sync_read,
|
||||||
.aio_read = generic_file_aio_read,
|
.aio_read = generic_file_aio_read,
|
||||||
.ioctl = udf_ioctl,
|
.ioctl = udf_ioctl,
|
||||||
.open = generic_file_open,
|
.open = generic_file_open,
|
||||||
.mmap = generic_file_mmap,
|
.mmap = generic_file_mmap,
|
||||||
.write = do_sync_write,
|
.write = do_sync_write,
|
||||||
.aio_write = udf_file_aio_write,
|
.aio_write = udf_file_aio_write,
|
||||||
.release = udf_release_file,
|
.release = udf_release_file,
|
||||||
.fsync = udf_fsync_file,
|
.fsync = udf_fsync_file,
|
||||||
.splice_read = generic_file_splice_read,
|
.splice_read = generic_file_splice_read,
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct inode_operations udf_file_inode_operations = {
|
const struct inode_operations udf_file_inode_operations = {
|
||||||
|
@ -32,6 +32,7 @@ static int udf_fsync_inode(struct inode *, int);
|
|||||||
int udf_fsync_file(struct file *file, struct dentry *dentry, int datasync)
|
int udf_fsync_file(struct file *file, struct dentry *dentry, int datasync)
|
||||||
{
|
{
|
||||||
struct inode *inode = dentry->d_inode;
|
struct inode *inode = dentry->d_inode;
|
||||||
|
|
||||||
return udf_fsync_inode(inode, datasync);
|
return udf_fsync_inode(inode, datasync);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,5 +47,6 @@ static int udf_fsync_inode(struct inode *inode, int datasync)
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
err |= udf_sync_inode(inode);
|
err |= udf_sync_inode(inode);
|
||||||
|
|
||||||
return err ? -EIO : 0;
|
return err ? -EIO : 0;
|
||||||
}
|
}
|
||||||
|
@ -46,12 +46,10 @@ void udf_free_inode(struct inode *inode)
|
|||||||
if (sbi->s_lvidbh) {
|
if (sbi->s_lvidbh) {
|
||||||
if (S_ISDIR(inode->i_mode))
|
if (S_ISDIR(inode->i_mode))
|
||||||
UDF_SB_LVIDIU(sb)->numDirs =
|
UDF_SB_LVIDIU(sb)->numDirs =
|
||||||
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)
|
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) - 1);
|
||||||
- 1);
|
|
||||||
else
|
else
|
||||||
UDF_SB_LVIDIU(sb)->numFiles =
|
UDF_SB_LVIDIU(sb)->numFiles =
|
||||||
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles)
|
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) - 1);
|
||||||
- 1);
|
|
||||||
|
|
||||||
mark_buffer_dirty(sbi->s_lvidbh);
|
mark_buffer_dirty(sbi->s_lvidbh);
|
||||||
}
|
}
|
||||||
@ -82,10 +80,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 =
|
block = udf_new_block(dir->i_sb, NULL, UDF_I_LOCATION(dir).partitionReferenceNum,
|
||||||
udf_new_block(dir->i_sb, NULL,
|
start, err);
|
||||||
UDF_I_LOCATION(dir).partitionReferenceNum, start,
|
|
||||||
err);
|
|
||||||
if (*err) {
|
if (*err) {
|
||||||
iput(inode);
|
iput(inode);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -95,17 +91,13 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
|
|||||||
if (UDF_SB_LVIDBH(sb)) {
|
if (UDF_SB_LVIDBH(sb)) {
|
||||||
struct logicalVolHeaderDesc *lvhd;
|
struct logicalVolHeaderDesc *lvhd;
|
||||||
uint64_t uniqueID;
|
uint64_t uniqueID;
|
||||||
lvhd =
|
lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->logicalVolContentsUse);
|
||||||
(struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->
|
|
||||||
logicalVolContentsUse);
|
|
||||||
if (S_ISDIR(mode))
|
if (S_ISDIR(mode))
|
||||||
UDF_SB_LVIDIU(sb)->numDirs =
|
UDF_SB_LVIDIU(sb)->numDirs =
|
||||||
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)
|
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) + 1);
|
||||||
+ 1);
|
|
||||||
else
|
else
|
||||||
UDF_SB_LVIDIU(sb)->numFiles =
|
UDF_SB_LVIDIU(sb)->numFiles =
|
||||||
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles)
|
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + 1);
|
||||||
+ 1);
|
|
||||||
UDF_I_UNIQUE(inode) = uniqueID = le64_to_cpu(lvhd->uniqueID);
|
UDF_I_UNIQUE(inode) = uniqueID = le64_to_cpu(lvhd->uniqueID);
|
||||||
if (!(++uniqueID & 0x00000000FFFFFFFFUL))
|
if (!(++uniqueID & 0x00000000FFFFFFFFUL))
|
||||||
uniqueID += 16;
|
uniqueID += 16;
|
||||||
@ -118,12 +110,12 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
|
|||||||
inode->i_gid = dir->i_gid;
|
inode->i_gid = dir->i_gid;
|
||||||
if (S_ISDIR(mode))
|
if (S_ISDIR(mode))
|
||||||
mode |= S_ISGID;
|
mode |= S_ISGID;
|
||||||
} else
|
} else {
|
||||||
inode->i_gid = current->fsgid;
|
inode->i_gid = current->fsgid;
|
||||||
|
}
|
||||||
|
|
||||||
UDF_I_LOCATION(inode).logicalBlockNum = block;
|
UDF_I_LOCATION(inode).logicalBlockNum = block;
|
||||||
UDF_I_LOCATION(inode).partitionReferenceNum =
|
UDF_I_LOCATION(inode).partitionReferenceNum = UDF_I_LOCATION(dir).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;
|
||||||
@ -132,14 +124,10 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
|
|||||||
if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) {
|
if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) {
|
||||||
UDF_I_EFE(inode) = 1;
|
UDF_I_EFE(inode) = 1;
|
||||||
UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE);
|
UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE);
|
||||||
UDF_I_DATA(inode) =
|
UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL);
|
||||||
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) =
|
UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL);
|
||||||
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);
|
||||||
@ -154,7 +142,7 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
|
|||||||
else
|
else
|
||||||
UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_LONG;
|
UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_LONG;
|
||||||
inode->i_mtime = inode->i_atime = inode->i_ctime =
|
inode->i_mtime = inode->i_atime = inode->i_ctime =
|
||||||
UDF_I_CRTIME(inode) = current_fs_time(inode->i_sb);
|
UDF_I_CRTIME(inode) = current_fs_time(inode->i_sb);
|
||||||
insert_inode_hash(inode);
|
insert_inode_hash(inode);
|
||||||
mark_inode_dirty(inode);
|
mark_inode_dirty(inode);
|
||||||
mutex_unlock(&sbi->s_alloc_mutex);
|
mutex_unlock(&sbi->s_alloc_mutex);
|
||||||
|
950
fs/udf/inode.c
950
fs/udf/inode.c
File diff suppressed because it is too large
Load Diff
@ -43,7 +43,7 @@ unsigned int udf_get_last_session(struct super_block *sb)
|
|||||||
udf_debug("XA disk: %s, vol_desc_start=%d\n",
|
udf_debug("XA disk: %s, vol_desc_start=%d\n",
|
||||||
(ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba);
|
(ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba);
|
||||||
#if WE_OBEY_THE_WRITTEN_STANDARDS
|
#if WE_OBEY_THE_WRITTEN_STANDARDS
|
||||||
if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
|
if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
|
||||||
#endif
|
#endif
|
||||||
vol_desc_start = ms_info.addr.lba;
|
vol_desc_start = ms_info.addr.lba;
|
||||||
} else {
|
} else {
|
||||||
@ -57,7 +57,7 @@ unsigned long udf_get_last_block(struct super_block *sb)
|
|||||||
struct block_device *bdev = sb->s_bdev;
|
struct block_device *bdev = sb->s_bdev;
|
||||||
unsigned long lblock = 0;
|
unsigned long lblock = 0;
|
||||||
|
|
||||||
if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long)&lblock))
|
if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long) &lblock))
|
||||||
lblock = bdev->bd_inode->i_size >> sb->s_blocksize_bits;
|
lblock = bdev->bd_inode->i_size >> sb->s_blocksize_bits;
|
||||||
|
|
||||||
if (lblock)
|
if (lblock)
|
||||||
|
@ -54,15 +54,15 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
ea = UDF_I_DATA(inode);
|
ea = UDF_I_DATA(inode);
|
||||||
if (UDF_I_LENEATTR(inode))
|
if (UDF_I_LENEATTR(inode)) {
|
||||||
ad = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode);
|
ad = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode);
|
||||||
else {
|
} else {
|
||||||
ad = ea;
|
ad = ea;
|
||||||
size += sizeof(struct extendedAttrHeaderDesc);
|
size += sizeof(struct extendedAttrHeaderDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = inode->i_sb->s_blocksize - udf_file_entry_alloc_offset(inode) -
|
offset = inode->i_sb->s_blocksize - udf_file_entry_alloc_offset(inode) -
|
||||||
UDF_I_LENALLOC(inode);
|
UDF_I_LENALLOC(inode);
|
||||||
|
|
||||||
/* TODO - Check for FreeEASpace */
|
/* TODO - Check for FreeEASpace */
|
||||||
|
|
||||||
@ -76,56 +76,45 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
|
|||||||
|
|
||||||
if (UDF_I_LENEATTR(inode)) {
|
if (UDF_I_LENEATTR(inode)) {
|
||||||
/* check checksum/crc */
|
/* check checksum/crc */
|
||||||
if (le16_to_cpu(eahd->descTag.tagIdent) !=
|
if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD ||
|
||||||
TAG_IDENT_EAHD
|
le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum) {
|
||||||
|| le32_to_cpu(eahd->descTag.tagLocation) !=
|
|
||||||
UDF_I_LOCATION(inode).logicalBlockNum) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size -= sizeof(struct extendedAttrHeaderDesc);
|
size -= sizeof(struct extendedAttrHeaderDesc);
|
||||||
UDF_I_LENEATTR(inode) +=
|
UDF_I_LENEATTR(inode) += sizeof(struct extendedAttrHeaderDesc);
|
||||||
sizeof(struct extendedAttrHeaderDesc);
|
|
||||||
eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD);
|
eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD);
|
||||||
if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200)
|
if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200)
|
||||||
eahd->descTag.descVersion = cpu_to_le16(3);
|
eahd->descTag.descVersion = cpu_to_le16(3);
|
||||||
else
|
else
|
||||||
eahd->descTag.descVersion = cpu_to_le16(2);
|
eahd->descTag.descVersion = cpu_to_le16(2);
|
||||||
eahd->descTag.tagSerialNum =
|
eahd->descTag.tagSerialNum = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb));
|
||||||
cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb));
|
eahd->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
|
||||||
eahd->descTag.tagLocation =
|
|
||||||
cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
|
|
||||||
eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF);
|
eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF);
|
||||||
eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF);
|
eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = UDF_I_LENEATTR(inode);
|
offset = UDF_I_LENEATTR(inode);
|
||||||
if (type < 2048) {
|
if (type < 2048) {
|
||||||
if (le32_to_cpu(eahd->appAttrLocation) <
|
if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode)) {
|
||||||
UDF_I_LENEATTR(inode)) {
|
uint32_t aal = le32_to_cpu(eahd->appAttrLocation);
|
||||||
uint32_t aal =
|
memmove(&ea[offset - aal + size],
|
||||||
le32_to_cpu(eahd->appAttrLocation);
|
&ea[aal], offset - aal);
|
||||||
memmove(&ea[offset - aal + size], &ea[aal],
|
|
||||||
offset - aal);
|
|
||||||
offset -= aal;
|
offset -= aal;
|
||||||
eahd->appAttrLocation = cpu_to_le32(aal + size);
|
eahd->appAttrLocation = cpu_to_le32(aal + size);
|
||||||
}
|
}
|
||||||
if (le32_to_cpu(eahd->impAttrLocation) <
|
if (le32_to_cpu(eahd->impAttrLocation) < UDF_I_LENEATTR(inode)) {
|
||||||
UDF_I_LENEATTR(inode)) {
|
uint32_t ial = le32_to_cpu(eahd->impAttrLocation);
|
||||||
uint32_t ial =
|
memmove(&ea[offset - ial + size],
|
||||||
le32_to_cpu(eahd->impAttrLocation);
|
&ea[ial], offset - ial);
|
||||||
memmove(&ea[offset - ial + size], &ea[ial],
|
|
||||||
offset - ial);
|
|
||||||
offset -= ial;
|
offset -= ial;
|
||||||
eahd->impAttrLocation = cpu_to_le32(ial + size);
|
eahd->impAttrLocation = cpu_to_le32(ial + size);
|
||||||
}
|
}
|
||||||
} else if (type < 65536) {
|
} else if (type < 65536) {
|
||||||
if (le32_to_cpu(eahd->appAttrLocation) <
|
if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode)) {
|
||||||
UDF_I_LENEATTR(inode)) {
|
uint32_t aal = le32_to_cpu(eahd->appAttrLocation);
|
||||||
uint32_t aal =
|
memmove(&ea[offset - aal + size],
|
||||||
le32_to_cpu(eahd->appAttrLocation);
|
&ea[aal], offset - aal);
|
||||||
memmove(&ea[offset - aal + size], &ea[aal],
|
|
||||||
offset - aal);
|
|
||||||
offset -= aal;
|
offset -= aal;
|
||||||
eahd->appAttrLocation = cpu_to_le32(aal + size);
|
eahd->appAttrLocation = cpu_to_le32(aal + size);
|
||||||
}
|
}
|
||||||
@ -133,18 +122,18 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
|
|||||||
/* rewrite CRC + checksum of eahd */
|
/* rewrite CRC + checksum of eahd */
|
||||||
crclen = sizeof(struct extendedAttrHeaderDesc) - sizeof(tag);
|
crclen = sizeof(struct extendedAttrHeaderDesc) - sizeof(tag);
|
||||||
eahd->descTag.descCRCLength = cpu_to_le16(crclen);
|
eahd->descTag.descCRCLength = cpu_to_le16(crclen);
|
||||||
eahd->descTag.descCRC =
|
eahd->descTag.descCRC = cpu_to_le16(udf_crc((char *)eahd +
|
||||||
cpu_to_le16(udf_crc((char *)eahd + sizeof(tag), crclen, 0));
|
sizeof(tag), crclen, 0));
|
||||||
eahd->descTag.tagChecksum = 0;
|
eahd->descTag.tagChecksum = 0;
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
if (i != 4)
|
if (i != 4)
|
||||||
eahd->descTag.tagChecksum +=
|
eahd->descTag.tagChecksum += ((uint8_t *)&(eahd->descTag))[i];
|
||||||
((uint8_t *) & (eahd->descTag))[i];
|
|
||||||
UDF_I_LENEATTR(inode) += size;
|
UDF_I_LENEATTR(inode) += size;
|
||||||
return (struct genericFormat *)&ea[offset];
|
return (struct genericFormat *)&ea[offset];
|
||||||
}
|
}
|
||||||
if (loc & 0x02) {
|
if (loc & 0x02) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,8 +152,7 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
|
|||||||
|
|
||||||
/* check checksum/crc */
|
/* check checksum/crc */
|
||||||
if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD ||
|
if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD ||
|
||||||
le32_to_cpu(eahd->descTag.tagLocation) !=
|
le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum) {
|
||||||
UDF_I_LOCATION(inode).logicalBlockNum) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,13 +165,13 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
|
|||||||
|
|
||||||
while (offset < UDF_I_LENEATTR(inode)) {
|
while (offset < UDF_I_LENEATTR(inode)) {
|
||||||
gaf = (struct genericFormat *)&ea[offset];
|
gaf = (struct genericFormat *)&ea[offset];
|
||||||
if (le32_to_cpu(gaf->attrType) == type
|
if (le32_to_cpu(gaf->attrType) == type && gaf->attrSubtype == subtype)
|
||||||
&& gaf->attrSubtype == subtype)
|
|
||||||
return gaf;
|
return gaf;
|
||||||
else
|
else
|
||||||
offset += le32_to_cpu(gaf->attrLength);
|
offset += le32_to_cpu(gaf->attrLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,23 +204,22 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tag_p = (tag *) (bh->b_data);
|
tag_p = (tag *)(bh->b_data);
|
||||||
|
|
||||||
*ident = le16_to_cpu(tag_p->tagIdent);
|
*ident = le16_to_cpu(tag_p->tagIdent);
|
||||||
|
|
||||||
if (location != le32_to_cpu(tag_p->tagLocation)) {
|
if (location != le32_to_cpu(tag_p->tagLocation)) {
|
||||||
udf_debug("location mismatch block %u, tag %u != %u\n",
|
udf_debug("location mismatch block %u, tag %u != %u\n",
|
||||||
block + UDF_SB_SESSION(sb),
|
block + UDF_SB_SESSION(sb), le32_to_cpu(tag_p->tagLocation), location);
|
||||||
le32_to_cpu(tag_p->tagLocation), location);
|
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Verify the tag checksum */
|
/* Verify the tag checksum */
|
||||||
checksum = 0U;
|
checksum = 0U;
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
checksum += (uint8_t) (bh->b_data[i]);
|
checksum += (uint8_t)(bh->b_data[i]);
|
||||||
for (i = 5; i < 16; i++)
|
for (i = 5; i < 16; i++)
|
||||||
checksum += (uint8_t) (bh->b_data[i]);
|
checksum += (uint8_t)(bh->b_data[i]);
|
||||||
if (checksum != tag_p->tagChecksum) {
|
if (checksum != tag_p->tagChecksum) {
|
||||||
printk(KERN_ERR "udf: tag checksum failed block %d\n", block);
|
printk(KERN_ERR "udf: tag checksum failed block %d\n", block);
|
||||||
goto error_out;
|
goto error_out;
|
||||||
@ -249,16 +236,14 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
|
|||||||
/* Verify the descriptor CRC */
|
/* Verify the descriptor CRC */
|
||||||
if (le16_to_cpu(tag_p->descCRCLength) + sizeof(tag) > sb->s_blocksize ||
|
if (le16_to_cpu(tag_p->descCRCLength) + sizeof(tag) > sb->s_blocksize ||
|
||||||
le16_to_cpu(tag_p->descCRC) == udf_crc(bh->b_data + sizeof(tag),
|
le16_to_cpu(tag_p->descCRC) == udf_crc(bh->b_data + sizeof(tag),
|
||||||
le16_to_cpu(tag_p->
|
le16_to_cpu(tag_p->descCRCLength), 0)) {
|
||||||
descCRCLength),
|
|
||||||
0)) {
|
|
||||||
return bh;
|
return bh;
|
||||||
}
|
}
|
||||||
udf_debug("Crc failure block %d: crc = %d, crclen = %d\n",
|
udf_debug("Crc failure block %d: crc = %d, crclen = %d\n",
|
||||||
block + UDF_SB_SESSION(sb), le16_to_cpu(tag_p->descCRC),
|
block + UDF_SB_SESSION(sb), le16_to_cpu(tag_p->descCRC),
|
||||||
le16_to_cpu(tag_p->descCRCLength));
|
le16_to_cpu(tag_p->descCRCLength));
|
||||||
|
|
||||||
error_out:
|
error_out:
|
||||||
brelse(bh);
|
brelse(bh);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -272,7 +257,7 @@ struct buffer_head *udf_read_ptagged(struct super_block *sb, kernel_lb_addr loc,
|
|||||||
|
|
||||||
void udf_update_tag(char *data, int length)
|
void udf_update_tag(char *data, int length)
|
||||||
{
|
{
|
||||||
tag *tptr = (tag *) data;
|
tag *tptr = (tag *)data;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
length -= sizeof(tag);
|
length -= sizeof(tag);
|
||||||
@ -283,13 +268,13 @@ void udf_update_tag(char *data, int length)
|
|||||||
|
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
if (i != 4)
|
if (i != 4)
|
||||||
tptr->tagChecksum += (uint8_t) (data[i]);
|
tptr->tagChecksum += (uint8_t)(data[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
|
void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
|
||||||
uint32_t loc, int length)
|
uint32_t loc, int length)
|
||||||
{
|
{
|
||||||
tag *tptr = (tag *) data;
|
tag *tptr = (tag *)data;
|
||||||
tptr->tagIdent = cpu_to_le16(ident);
|
tptr->tagIdent = cpu_to_le16(ident);
|
||||||
tptr->descVersion = cpu_to_le16(version);
|
tptr->descVersion = cpu_to_le16(version);
|
||||||
tptr->tagSerialNum = cpu_to_le16(snum);
|
tptr->tagSerialNum = cpu_to_le16(snum);
|
||||||
|
408
fs/udf/namei.c
408
fs/udf/namei.c
@ -37,6 +37,7 @@ static inline int udf_match(int len1, const char *name1, int len2,
|
|||||||
{
|
{
|
||||||
if (len1 != len2)
|
if (len1 != len2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return !memcmp(name1, name2, len1);
|
return !memcmp(name1, name2, len1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi,
|
|||||||
uint16_t liu = le16_to_cpu(cfi->lengthOfImpUse);
|
uint16_t liu = le16_to_cpu(cfi->lengthOfImpUse);
|
||||||
uint8_t lfi = cfi->lengthFileIdent;
|
uint8_t lfi = cfi->lengthFileIdent;
|
||||||
int padlen = fibh->eoffset - fibh->soffset - liu - lfi -
|
int padlen = fibh->eoffset - fibh->soffset - liu - lfi -
|
||||||
sizeof(struct fileIdentDesc);
|
sizeof(struct fileIdentDesc);
|
||||||
int adinicb = 0;
|
int adinicb = 0;
|
||||||
|
|
||||||
if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB)
|
if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB)
|
||||||
@ -61,85 +62,75 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi,
|
|||||||
offset = fibh->soffset + sizeof(struct fileIdentDesc);
|
offset = fibh->soffset + sizeof(struct fileIdentDesc);
|
||||||
|
|
||||||
if (impuse) {
|
if (impuse) {
|
||||||
if (adinicb || (offset + liu < 0))
|
if (adinicb || (offset + liu < 0)) {
|
||||||
memcpy((uint8_t *) sfi->impUse, impuse, liu);
|
memcpy((uint8_t *)sfi->impUse, impuse, liu);
|
||||||
else if (offset >= 0)
|
} else if (offset >= 0) {
|
||||||
memcpy(fibh->ebh->b_data + offset, impuse, liu);
|
memcpy(fibh->ebh->b_data + offset, impuse, liu);
|
||||||
else {
|
} else {
|
||||||
memcpy((uint8_t *) sfi->impUse, impuse, -offset);
|
memcpy((uint8_t *)sfi->impUse, impuse, -offset);
|
||||||
memcpy(fibh->ebh->b_data, impuse - offset,
|
memcpy(fibh->ebh->b_data, impuse - offset, liu + offset);
|
||||||
liu + offset);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += liu;
|
offset += liu;
|
||||||
|
|
||||||
if (fileident) {
|
if (fileident) {
|
||||||
if (adinicb || (offset + lfi < 0))
|
if (adinicb || (offset + lfi < 0)) {
|
||||||
memcpy((uint8_t *) sfi->fileIdent + liu, fileident,
|
memcpy((uint8_t *)sfi->fileIdent + liu, fileident, lfi);
|
||||||
lfi);
|
} else if (offset >= 0) {
|
||||||
else if (offset >= 0)
|
|
||||||
memcpy(fibh->ebh->b_data + offset, fileident, lfi);
|
memcpy(fibh->ebh->b_data + offset, fileident, lfi);
|
||||||
else {
|
} else {
|
||||||
memcpy((uint8_t *) sfi->fileIdent + liu, fileident,
|
memcpy((uint8_t *)sfi->fileIdent + liu, fileident, -offset);
|
||||||
-offset);
|
memcpy(fibh->ebh->b_data, fileident - offset, lfi + offset);
|
||||||
memcpy(fibh->ebh->b_data, fileident - offset,
|
|
||||||
lfi + offset);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += lfi;
|
offset += lfi;
|
||||||
|
|
||||||
if (adinicb || (offset + padlen < 0))
|
if (adinicb || (offset + padlen < 0)) {
|
||||||
memset((uint8_t *) sfi->padding + liu + lfi, 0x00, padlen);
|
memset((uint8_t *)sfi->padding + liu + lfi, 0x00, padlen);
|
||||||
else if (offset >= 0)
|
} else if (offset >= 0) {
|
||||||
memset(fibh->ebh->b_data + offset, 0x00, padlen);
|
memset(fibh->ebh->b_data + offset, 0x00, padlen);
|
||||||
else {
|
} else {
|
||||||
memset((uint8_t *) sfi->padding + liu + lfi, 0x00, -offset);
|
memset((uint8_t *)sfi->padding + liu + lfi, 0x00, -offset);
|
||||||
memset(fibh->ebh->b_data, 0x00, padlen + offset);
|
memset(fibh->ebh->b_data, 0x00, padlen + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
crc =
|
crc = udf_crc((uint8_t *)cfi + sizeof(tag),
|
||||||
udf_crc((uint8_t *) cfi + sizeof(tag),
|
sizeof(struct fileIdentDesc) - sizeof(tag), 0);
|
||||||
sizeof(struct fileIdentDesc) - sizeof(tag), 0);
|
|
||||||
|
|
||||||
if (fibh->sbh == fibh->ebh)
|
if (fibh->sbh == fibh->ebh) {
|
||||||
crc = udf_crc((uint8_t *) sfi->impUse,
|
crc = udf_crc((uint8_t *)sfi->impUse,
|
||||||
crclen + sizeof(tag) -
|
crclen + sizeof(tag) - sizeof(struct fileIdentDesc), crc);
|
||||||
sizeof(struct fileIdentDesc), crc);
|
} else if (sizeof(struct fileIdentDesc) >= -fibh->soffset) {
|
||||||
else if (sizeof(struct fileIdentDesc) >= -fibh->soffset)
|
crc = udf_crc(fibh->ebh->b_data + sizeof(struct fileIdentDesc) + fibh->soffset,
|
||||||
crc =
|
crclen + sizeof(tag) - sizeof(struct fileIdentDesc), crc);
|
||||||
udf_crc(fibh->ebh->b_data + sizeof(struct fileIdentDesc) +
|
} else {
|
||||||
fibh->soffset,
|
crc = udf_crc((uint8_t *)sfi->impUse,
|
||||||
crclen + sizeof(tag) - sizeof(struct fileIdentDesc),
|
-fibh->soffset - sizeof(struct fileIdentDesc), crc);
|
||||||
crc);
|
|
||||||
else {
|
|
||||||
crc = udf_crc((uint8_t *) sfi->impUse,
|
|
||||||
-fibh->soffset - sizeof(struct fileIdentDesc),
|
|
||||||
crc);
|
|
||||||
crc = udf_crc(fibh->ebh->b_data, fibh->eoffset, crc);
|
crc = udf_crc(fibh->ebh->b_data, fibh->eoffset, crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
cfi->descTag.descCRC = cpu_to_le16(crc);
|
cfi->descTag.descCRC = cpu_to_le16(crc);
|
||||||
cfi->descTag.descCRCLength = cpu_to_le16(crclen);
|
cfi->descTag.descCRCLength = cpu_to_le16(crclen);
|
||||||
|
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++) {
|
||||||
if (i != 4)
|
if (i != 4)
|
||||||
checksum += ((uint8_t *) & cfi->descTag)[i];
|
checksum += ((uint8_t *)&cfi->descTag)[i];
|
||||||
|
}
|
||||||
|
|
||||||
cfi->descTag.tagChecksum = checksum;
|
cfi->descTag.tagChecksum = checksum;
|
||||||
if (adinicb || (sizeof(struct fileIdentDesc) <= -fibh->soffset))
|
if (adinicb || (sizeof(struct fileIdentDesc) <= -fibh->soffset)) {
|
||||||
memcpy((uint8_t *) sfi, (uint8_t *) cfi,
|
memcpy((uint8_t *)sfi, (uint8_t *)cfi, sizeof(struct fileIdentDesc));
|
||||||
sizeof(struct fileIdentDesc));
|
} else {
|
||||||
else {
|
memcpy((uint8_t *)sfi, (uint8_t *)cfi, -fibh->soffset);
|
||||||
memcpy((uint8_t *) sfi, (uint8_t *) cfi, -fibh->soffset);
|
memcpy(fibh->ebh->b_data, (uint8_t *)cfi - fibh->soffset,
|
||||||
memcpy(fibh->ebh->b_data, (uint8_t *) cfi - fibh->soffset,
|
|
||||||
sizeof(struct fileIdentDesc) + fibh->soffset);
|
sizeof(struct fileIdentDesc) + fibh->soffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (adinicb)
|
if (adinicb) {
|
||||||
mark_inode_dirty(inode);
|
mark_inode_dirty(inode);
|
||||||
else {
|
} else {
|
||||||
if (fibh->sbh != fibh->ebh)
|
if (fibh->sbh != fibh->ebh)
|
||||||
mark_buffer_dirty_inode(fibh->ebh, inode);
|
mark_buffer_dirty_inode(fibh->ebh, inode);
|
||||||
mark_buffer_dirty_inode(fibh->sbh, inode);
|
mark_buffer_dirty_inode(fibh->sbh, inode);
|
||||||
@ -163,26 +154,25 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
|
|||||||
kernel_lb_addr eloc;
|
kernel_lb_addr eloc;
|
||||||
uint32_t elen;
|
uint32_t elen;
|
||||||
sector_t offset;
|
sector_t offset;
|
||||||
struct extent_position epos = { NULL, 0, {0, 0} };
|
struct extent_position epos = {};
|
||||||
|
|
||||||
size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
|
size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
|
||||||
f_pos = (udf_ext0_offset(dir) >> 2);
|
f_pos = (udf_ext0_offset(dir) >> 2);
|
||||||
|
|
||||||
fibh->soffset = fibh->eoffset =
|
fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
|
||||||
(f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
|
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
|
||||||
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
|
|
||||||
fibh->sbh = fibh->ebh = NULL;
|
fibh->sbh = fibh->ebh = NULL;
|
||||||
else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2),
|
} else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2),
|
||||||
&epos, &eloc, &elen,
|
&epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
|
||||||
&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) {
|
||||||
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
|
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
|
||||||
epos.offset -= sizeof(short_ad);
|
epos.offset -= sizeof(short_ad);
|
||||||
else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
|
else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
|
||||||
epos.offset -= sizeof(long_ad);
|
epos.offset -= sizeof(long_ad);
|
||||||
} else
|
} else {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) {
|
if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) {
|
||||||
brelse(epos.bh);
|
brelse(epos.bh);
|
||||||
@ -196,7 +186,6 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
|
|||||||
while ((f_pos < size)) {
|
while ((f_pos < size)) {
|
||||||
fi = udf_fileident_read(dir, &f_pos, fibh, cfi, &epos, &eloc,
|
fi = udf_fileident_read(dir, &f_pos, fibh, cfi, &epos, &eloc,
|
||||||
&elen, &offset);
|
&elen, &offset);
|
||||||
|
|
||||||
if (!fi) {
|
if (!fi) {
|
||||||
if (fibh->sbh != fibh->ebh)
|
if (fibh->sbh != fibh->ebh)
|
||||||
brelse(fibh->ebh);
|
brelse(fibh->ebh);
|
||||||
@ -213,20 +202,14 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
|
|||||||
} else {
|
} else {
|
||||||
int poffset; /* Unpaded ending offset */
|
int poffset; /* Unpaded ending offset */
|
||||||
|
|
||||||
poffset =
|
poffset = fibh->soffset + sizeof(struct fileIdentDesc) + liu + lfi;
|
||||||
fibh->soffset + sizeof(struct fileIdentDesc) + liu +
|
|
||||||
lfi;
|
|
||||||
|
|
||||||
if (poffset >= lfi)
|
if (poffset >= lfi) {
|
||||||
nameptr =
|
nameptr = (uint8_t *)(fibh->ebh->b_data + poffset - lfi);
|
||||||
(uint8_t *) (fibh->ebh->b_data + poffset -
|
} else {
|
||||||
lfi);
|
|
||||||
else {
|
|
||||||
nameptr = fname;
|
nameptr = fname;
|
||||||
memcpy(nameptr, fi->fileIdent + liu,
|
memcpy(nameptr, fi->fileIdent + liu, lfi - poffset);
|
||||||
lfi - poffset);
|
memcpy(nameptr + lfi - poffset, fibh->ebh->b_data, poffset);
|
||||||
memcpy(nameptr + lfi - poffset,
|
|
||||||
fibh->ebh->b_data, poffset);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,18 +227,18 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi))) {
|
if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi))) {
|
||||||
if (udf_match
|
if (udf_match(flen, fname, dentry->d_name.len, dentry->d_name.name)) {
|
||||||
(flen, fname, dentry->d_name.len,
|
|
||||||
dentry->d_name.name)) {
|
|
||||||
brelse(epos.bh);
|
brelse(epos.bh);
|
||||||
return fi;
|
return fi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fibh->sbh != fibh->ebh)
|
if (fibh->sbh != fibh->ebh)
|
||||||
brelse(fibh->ebh);
|
brelse(fibh->ebh);
|
||||||
brelse(fibh->sbh);
|
brelse(fibh->sbh);
|
||||||
brelse(epos.bh);
|
brelse(epos.bh);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,15 +289,19 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
|
|||||||
#ifdef UDF_RECOVERY
|
#ifdef UDF_RECOVERY
|
||||||
/* temporary shorthand for specifying files by inode number */
|
/* temporary shorthand for specifying files by inode number */
|
||||||
if (!strncmp(dentry->d_name.name, ".B=", 3)) {
|
if (!strncmp(dentry->d_name.name, ".B=", 3)) {
|
||||||
kernel_lb_addr lb =
|
kernel_lb_addr lb = {
|
||||||
{ 0, simple_strtoul(dentry->d_name.name + 3, NULL, 0) };
|
.logicalBlockNum = 0,
|
||||||
|
.partitionReferenceNum = simple_strtoul(dentry->d_name.name + 3,
|
||||||
|
NULL, 0),
|
||||||
|
};
|
||||||
inode = udf_iget(dir->i_sb, lb);
|
inode = udf_iget(dir->i_sb, lb);
|
||||||
if (!inode) {
|
if (!inode) {
|
||||||
unlock_kernel();
|
unlock_kernel();
|
||||||
return ERR_PTR(-EACCES);
|
return ERR_PTR(-EACCES);
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
#endif /* UDF_RECOVERY */
|
else
|
||||||
|
#endif /* UDF_RECOVERY */
|
||||||
|
|
||||||
if (udf_find_entry(dir, dentry, &fibh, &cfi)) {
|
if (udf_find_entry(dir, dentry, &fibh, &cfi)) {
|
||||||
if (fibh.sbh != fibh.ebh)
|
if (fibh.sbh != fibh.ebh)
|
||||||
@ -329,6 +316,7 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
|
|||||||
}
|
}
|
||||||
unlock_kernel();
|
unlock_kernel();
|
||||||
d_add(dentry, inode);
|
d_add(dentry, inode);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,7 +340,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
|
|||||||
kernel_lb_addr eloc;
|
kernel_lb_addr eloc;
|
||||||
uint32_t elen;
|
uint32_t elen;
|
||||||
sector_t offset;
|
sector_t offset;
|
||||||
struct extent_position epos = { NULL, 0, {0, 0} };
|
struct extent_position epos = {};
|
||||||
|
|
||||||
sb = dir->i_sb;
|
sb = dir->i_sb;
|
||||||
|
|
||||||
@ -361,36 +349,33 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
|
|||||||
*err = -EINVAL;
|
*err = -EINVAL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if (!(namelen = udf_put_filename(sb, dentry->d_name.name, name,
|
||||||
if (!
|
dentry->d_name.len))) {
|
||||||
(namelen =
|
|
||||||
udf_put_filename(sb, dentry->d_name.name, name,
|
|
||||||
dentry->d_name.len))) {
|
|
||||||
*err = -ENAMETOOLONG;
|
*err = -ENAMETOOLONG;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
namelen = 0;
|
namelen = 0;
|
||||||
|
}
|
||||||
|
|
||||||
nfidlen = (sizeof(struct fileIdentDesc) + namelen + 3) & ~3;
|
nfidlen = (sizeof(struct fileIdentDesc) + namelen + 3) & ~3;
|
||||||
|
|
||||||
f_pos = (udf_ext0_offset(dir) >> 2);
|
f_pos = (udf_ext0_offset(dir) >> 2);
|
||||||
|
|
||||||
fibh->soffset = fibh->eoffset =
|
fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
|
||||||
(f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
|
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
|
||||||
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
|
|
||||||
fibh->sbh = fibh->ebh = NULL;
|
fibh->sbh = fibh->ebh = NULL;
|
||||||
else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2),
|
} else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2),
|
||||||
&epos, &eloc, &elen,
|
&epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
|
||||||
&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) {
|
||||||
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
|
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
|
||||||
epos.offset -= sizeof(short_ad);
|
epos.offset -= sizeof(short_ad);
|
||||||
else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
|
else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
|
||||||
epos.offset -= sizeof(long_ad);
|
epos.offset -= sizeof(long_ad);
|
||||||
} else
|
} else {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) {
|
if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) {
|
||||||
brelse(epos.bh);
|
brelse(epos.bh);
|
||||||
@ -423,40 +408,33 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
|
|||||||
liu = le16_to_cpu(cfi->lengthOfImpUse);
|
liu = le16_to_cpu(cfi->lengthOfImpUse);
|
||||||
lfi = cfi->lengthFileIdent;
|
lfi = cfi->lengthFileIdent;
|
||||||
|
|
||||||
if (fibh->sbh == fibh->ebh)
|
if (fibh->sbh == fibh->ebh) {
|
||||||
nameptr = fi->fileIdent + liu;
|
nameptr = fi->fileIdent + liu;
|
||||||
else {
|
} else {
|
||||||
int poffset; /* Unpaded ending offset */
|
int poffset; /* Unpaded ending offset */
|
||||||
|
|
||||||
poffset =
|
poffset = fibh->soffset + sizeof(struct fileIdentDesc) + liu + lfi;
|
||||||
fibh->soffset + sizeof(struct fileIdentDesc) + liu +
|
|
||||||
lfi;
|
|
||||||
|
|
||||||
if (poffset >= lfi)
|
if (poffset >= lfi) {
|
||||||
nameptr =
|
nameptr = (char *)(fibh->ebh->b_data + poffset - lfi);
|
||||||
(char *)(fibh->ebh->b_data + poffset - lfi);
|
} else {
|
||||||
else {
|
|
||||||
nameptr = fname;
|
nameptr = fname;
|
||||||
memcpy(nameptr, fi->fileIdent + liu,
|
memcpy(nameptr, fi->fileIdent + liu, lfi - poffset);
|
||||||
lfi - poffset);
|
memcpy(nameptr + lfi - poffset, fibh->ebh->b_data, poffset);
|
||||||
memcpy(nameptr + lfi - poffset,
|
|
||||||
fibh->ebh->b_data, poffset);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) {
|
if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) {
|
||||||
if (((sizeof(struct fileIdentDesc) + liu + lfi +
|
if (((sizeof(struct fileIdentDesc) + liu + lfi + 3) & ~3) == nfidlen) {
|
||||||
3) & ~3) == nfidlen) {
|
|
||||||
brelse(epos.bh);
|
brelse(epos.bh);
|
||||||
cfi->descTag.tagSerialNum = cpu_to_le16(1);
|
cfi->descTag.tagSerialNum = cpu_to_le16(1);
|
||||||
cfi->fileVersionNum = cpu_to_le16(1);
|
cfi->fileVersionNum = cpu_to_le16(1);
|
||||||
cfi->fileCharacteristics = 0;
|
cfi->fileCharacteristics = 0;
|
||||||
cfi->lengthFileIdent = namelen;
|
cfi->lengthFileIdent = namelen;
|
||||||
cfi->lengthOfImpUse = cpu_to_le16(0);
|
cfi->lengthOfImpUse = cpu_to_le16(0);
|
||||||
if (!udf_write_fi
|
if (!udf_write_fi(dir, cfi, fi, fibh, NULL, name)) {
|
||||||
(dir, cfi, fi, fibh, NULL, name))
|
|
||||||
return fi;
|
return fi;
|
||||||
else {
|
} else {
|
||||||
*err = -EIO;
|
*err = -EIO;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -467,8 +445,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi)) &&
|
if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi)) &&
|
||||||
udf_match(flen, fname, dentry->d_name.len,
|
udf_match(flen, fname, dentry->d_name.len, dentry->d_name.name)) {
|
||||||
dentry->d_name.name)) {
|
|
||||||
if (fibh->sbh != fibh->ebh)
|
if (fibh->sbh != fibh->ebh)
|
||||||
brelse(fibh->ebh);
|
brelse(fibh->ebh);
|
||||||
brelse(fibh->sbh);
|
brelse(fibh->sbh);
|
||||||
@ -478,7 +455,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add:
|
add:
|
||||||
f_pos += nfidlen;
|
f_pos += nfidlen;
|
||||||
|
|
||||||
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB &&
|
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB &&
|
||||||
@ -491,14 +468,11 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
|
|||||||
if (fibh->sbh != fibh->ebh)
|
if (fibh->sbh != fibh->ebh)
|
||||||
brelse(fibh->ebh);
|
brelse(fibh->ebh);
|
||||||
brelse(fibh->sbh);
|
brelse(fibh->sbh);
|
||||||
if (!
|
if (!(fibh->sbh = fibh->ebh = udf_expand_dir_adinicb(dir, &block, err)))
|
||||||
(fibh->sbh = fibh->ebh =
|
|
||||||
udf_expand_dir_adinicb(dir, &block, err)))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
epos.block = UDF_I_LOCATION(dir);
|
epos.block = UDF_I_LOCATION(dir);
|
||||||
eloc.logicalBlockNum = block;
|
eloc.logicalBlockNum = block;
|
||||||
eloc.partitionReferenceNum =
|
eloc.partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum;
|
||||||
UDF_I_LOCATION(dir).partitionReferenceNum;
|
|
||||||
elen = dir->i_sb->s_blocksize;
|
elen = dir->i_sb->s_blocksize;
|
||||||
epos.offset = udf_file_entry_alloc_offset(dir);
|
epos.offset = udf_file_entry_alloc_offset(dir);
|
||||||
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
|
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
|
||||||
@ -517,16 +491,13 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
|
|||||||
|
|
||||||
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
|
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
|
||||||
block = UDF_I_LOCATION(dir).logicalBlockNum;
|
block = UDF_I_LOCATION(dir).logicalBlockNum;
|
||||||
fi = (struct fileIdentDesc *)(UDF_I_DATA(dir) +
|
fi = (struct fileIdentDesc *)(UDF_I_DATA(dir) + fibh->soffset -
|
||||||
fibh->soffset -
|
|
||||||
udf_ext0_offset(dir) +
|
udf_ext0_offset(dir) +
|
||||||
UDF_I_LENEATTR(dir));
|
UDF_I_LENEATTR(dir));
|
||||||
} else {
|
} else {
|
||||||
block = eloc.logicalBlockNum + ((elen - 1) >>
|
block = eloc.logicalBlockNum + ((elen - 1) >>
|
||||||
dir->i_sb->
|
dir->i_sb->s_blocksize_bits);
|
||||||
s_blocksize_bits);
|
fi = (struct fileIdentDesc *)(fibh->sbh->b_data + fibh->soffset);
|
||||||
fi = (struct fileIdentDesc *)(fibh->sbh->b_data +
|
|
||||||
fibh->soffset);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fibh->soffset = fibh->eoffset - sb->s_blocksize;
|
fibh->soffset = fibh->eoffset - sb->s_blocksize;
|
||||||
@ -538,42 +509,36 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
|
|||||||
|
|
||||||
block = eloc.logicalBlockNum + ((elen - 1) >>
|
block = eloc.logicalBlockNum + ((elen - 1) >>
|
||||||
dir->i_sb->s_blocksize_bits);
|
dir->i_sb->s_blocksize_bits);
|
||||||
|
fibh->ebh = udf_bread(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), 1, err);
|
||||||
if (!
|
if (!fibh->ebh) {
|
||||||
(fibh->ebh =
|
|
||||||
udf_bread(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2),
|
|
||||||
1, err))) {
|
|
||||||
brelse(epos.bh);
|
brelse(epos.bh);
|
||||||
brelse(fibh->sbh);
|
brelse(fibh->sbh);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(fibh->soffset)) {
|
if (!fibh->soffset) {
|
||||||
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)) {
|
||||||
block = eloc.logicalBlockNum + ((elen - 1) >>
|
block = eloc.logicalBlockNum + ((elen - 1) >>
|
||||||
dir->i_sb->
|
dir->i_sb->s_blocksize_bits);
|
||||||
s_blocksize_bits);
|
} else {
|
||||||
} else
|
|
||||||
block++;
|
block++;
|
||||||
|
}
|
||||||
|
|
||||||
brelse(fibh->sbh);
|
brelse(fibh->sbh);
|
||||||
fibh->sbh = fibh->ebh;
|
fibh->sbh = fibh->ebh;
|
||||||
fi = (struct fileIdentDesc *)(fibh->sbh->b_data);
|
fi = (struct fileIdentDesc *)(fibh->sbh->b_data);
|
||||||
} else {
|
} else {
|
||||||
fi = (struct fileIdentDesc *)
|
fi = (struct fileIdentDesc *)
|
||||||
(fibh->sbh->b_data + sb->s_blocksize +
|
(fibh->sbh->b_data + sb->s_blocksize + fibh->soffset);
|
||||||
fibh->soffset);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(cfi, 0, sizeof(struct fileIdentDesc));
|
memset(cfi, 0, sizeof(struct fileIdentDesc));
|
||||||
if (UDF_SB_UDFREV(sb) >= 0x0200)
|
if (UDF_SB_UDFREV(sb) >= 0x0200)
|
||||||
udf_new_tag((char *)cfi, TAG_IDENT_FID, 3, 1, block,
|
udf_new_tag((char *)cfi, TAG_IDENT_FID, 3, 1, block, sizeof(tag));
|
||||||
sizeof(tag));
|
|
||||||
else
|
else
|
||||||
udf_new_tag((char *)cfi, TAG_IDENT_FID, 2, 1, block,
|
udf_new_tag((char *)cfi, TAG_IDENT_FID, 2, 1, block, sizeof(tag));
|
||||||
sizeof(tag));
|
|
||||||
cfi->fileVersionNum = cpu_to_le16(1);
|
cfi->fileVersionNum = cpu_to_le16(1);
|
||||||
cfi->lengthFileIdent = namelen;
|
cfi->lengthFileIdent = namelen;
|
||||||
cfi->lengthOfImpUse = cpu_to_le16(0);
|
cfi->lengthOfImpUse = cpu_to_le16(0);
|
||||||
@ -599,8 +564,10 @@ static int udf_delete_entry(struct inode *inode, struct fileIdentDesc *fi,
|
|||||||
struct fileIdentDesc *cfi)
|
struct fileIdentDesc *cfi)
|
||||||
{
|
{
|
||||||
cfi->fileCharacteristics |= FID_FILE_CHAR_DELETED;
|
cfi->fileCharacteristics |= FID_FILE_CHAR_DELETED;
|
||||||
|
|
||||||
if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT))
|
if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT))
|
||||||
memset(&(cfi->icb), 0x00, sizeof(long_ad));
|
memset(&(cfi->icb), 0x00, sizeof(long_ad));
|
||||||
|
|
||||||
return udf_write_fi(inode, cfi, fi, fibh, NULL, NULL);
|
return udf_write_fi(inode, cfi, fi, fibh, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -637,8 +604,8 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
|
|||||||
}
|
}
|
||||||
cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
|
cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
|
||||||
cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode));
|
cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode));
|
||||||
*(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
|
*(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
|
||||||
cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL);
|
cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL);
|
||||||
udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
|
udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
|
||||||
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
|
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
|
||||||
mark_inode_dirty(dir);
|
mark_inode_dirty(dir);
|
||||||
@ -648,6 +615,7 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
|
|||||||
brelse(fibh.sbh);
|
brelse(fibh.sbh);
|
||||||
unlock_kernel();
|
unlock_kernel();
|
||||||
d_instantiate(dentry, inode);
|
d_instantiate(dentry, inode);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -679,8 +647,8 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,
|
|||||||
}
|
}
|
||||||
cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
|
cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
|
||||||
cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode));
|
cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode));
|
||||||
*(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
|
*(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
|
||||||
cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL);
|
cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL);
|
||||||
udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
|
udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
|
||||||
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
|
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
|
||||||
mark_inode_dirty(dir);
|
mark_inode_dirty(dir);
|
||||||
@ -692,7 +660,8 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,
|
|||||||
brelse(fibh.sbh);
|
brelse(fibh.sbh);
|
||||||
d_instantiate(dentry, inode);
|
d_instantiate(dentry, inode);
|
||||||
err = 0;
|
err = 0;
|
||||||
out:
|
|
||||||
|
out:
|
||||||
unlock_kernel();
|
unlock_kernel();
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -725,10 +694,9 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
|
|||||||
inode->i_nlink = 2;
|
inode->i_nlink = 2;
|
||||||
cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
|
cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
|
||||||
cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(dir));
|
cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(dir));
|
||||||
*(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
|
*(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
|
||||||
cpu_to_le32(UDF_I_UNIQUE(dir) & 0x00000000FFFFFFFFUL);
|
cpu_to_le32(UDF_I_UNIQUE(dir) & 0x00000000FFFFFFFFUL);
|
||||||
cfi.fileCharacteristics =
|
cfi.fileCharacteristics = FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT;
|
||||||
FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT;
|
|
||||||
udf_write_fi(inode, &cfi, fi, &fibh, NULL, NULL);
|
udf_write_fi(inode, &cfi, fi, &fibh, NULL, NULL);
|
||||||
brelse(fibh.sbh);
|
brelse(fibh.sbh);
|
||||||
inode->i_mode = S_IFDIR | mode;
|
inode->i_mode = S_IFDIR | mode;
|
||||||
@ -744,8 +712,8 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
|
|||||||
}
|
}
|
||||||
cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
|
cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
|
||||||
cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode));
|
cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode));
|
||||||
*(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
|
*(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
|
||||||
cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL);
|
cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL);
|
||||||
cfi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY;
|
cfi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY;
|
||||||
udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
|
udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
|
||||||
inc_nlink(dir);
|
inc_nlink(dir);
|
||||||
@ -755,7 +723,8 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
|
|||||||
brelse(fibh.ebh);
|
brelse(fibh.ebh);
|
||||||
brelse(fibh.sbh);
|
brelse(fibh.sbh);
|
||||||
err = 0;
|
err = 0;
|
||||||
out:
|
|
||||||
|
out:
|
||||||
unlock_kernel();
|
unlock_kernel();
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -770,26 +739,25 @@ static int empty_dir(struct inode *dir)
|
|||||||
kernel_lb_addr eloc;
|
kernel_lb_addr eloc;
|
||||||
uint32_t elen;
|
uint32_t elen;
|
||||||
sector_t offset;
|
sector_t offset;
|
||||||
struct extent_position epos = { NULL, 0, {0, 0} };
|
struct extent_position epos = {};
|
||||||
|
|
||||||
f_pos = (udf_ext0_offset(dir) >> 2);
|
f_pos = (udf_ext0_offset(dir) >> 2);
|
||||||
|
|
||||||
fibh.soffset = fibh.eoffset =
|
fibh.soffset = fibh.eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
|
||||||
(f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
|
|
||||||
|
|
||||||
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
|
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
|
||||||
fibh.sbh = fibh.ebh = NULL;
|
fibh.sbh = fibh.ebh = NULL;
|
||||||
else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2),
|
} else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2),
|
||||||
&epos, &eloc, &elen,
|
&epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
|
||||||
&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) {
|
||||||
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
|
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
|
||||||
epos.offset -= sizeof(short_ad);
|
epos.offset -= sizeof(short_ad);
|
||||||
else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
|
else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
|
||||||
epos.offset -= sizeof(long_ad);
|
epos.offset -= sizeof(long_ad);
|
||||||
} else
|
} else {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) {
|
if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) {
|
||||||
brelse(epos.bh);
|
brelse(epos.bh);
|
||||||
@ -803,7 +771,6 @@ static int empty_dir(struct inode *dir)
|
|||||||
while ((f_pos < size)) {
|
while ((f_pos < size)) {
|
||||||
fi = udf_fileident_read(dir, &f_pos, &fibh, &cfi, &epos, &eloc,
|
fi = udf_fileident_read(dir, &f_pos, &fibh, &cfi, &epos, &eloc,
|
||||||
&elen, &offset);
|
&elen, &offset);
|
||||||
|
|
||||||
if (!fi) {
|
if (!fi) {
|
||||||
if (fibh.sbh != fibh.ebh)
|
if (fibh.sbh != fibh.ebh)
|
||||||
brelse(fibh.ebh);
|
brelse(fibh.ebh);
|
||||||
@ -812,8 +779,8 @@ static int empty_dir(struct inode *dir)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfi.lengthFileIdent
|
if (cfi.lengthFileIdent &&
|
||||||
&& (cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) == 0) {
|
(cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) == 0) {
|
||||||
if (fibh.sbh != fibh.ebh)
|
if (fibh.sbh != fibh.ebh)
|
||||||
brelse(fibh.ebh);
|
brelse(fibh.ebh);
|
||||||
brelse(fibh.sbh);
|
brelse(fibh.sbh);
|
||||||
@ -821,10 +788,12 @@ static int empty_dir(struct inode *dir)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fibh.sbh != fibh.ebh)
|
if (fibh.sbh != fibh.ebh)
|
||||||
brelse(fibh.ebh);
|
brelse(fibh.ebh);
|
||||||
brelse(fibh.sbh);
|
brelse(fibh.sbh);
|
||||||
brelse(epos.bh);
|
brelse(epos.bh);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -859,15 +828,15 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
|
|||||||
clear_nlink(inode);
|
clear_nlink(inode);
|
||||||
inode->i_size = 0;
|
inode->i_size = 0;
|
||||||
inode_dec_link_count(dir);
|
inode_dec_link_count(dir);
|
||||||
inode->i_ctime = dir->i_ctime = dir->i_mtime =
|
inode->i_ctime = dir->i_ctime = dir->i_mtime = current_fs_time(dir->i_sb);
|
||||||
current_fs_time(dir->i_sb);
|
|
||||||
mark_inode_dirty(dir);
|
mark_inode_dirty(dir);
|
||||||
|
|
||||||
end_rmdir:
|
end_rmdir:
|
||||||
if (fibh.sbh != fibh.ebh)
|
if (fibh.sbh != fibh.ebh)
|
||||||
brelse(fibh.ebh);
|
brelse(fibh.ebh);
|
||||||
brelse(fibh.sbh);
|
brelse(fibh.sbh);
|
||||||
out:
|
|
||||||
|
out:
|
||||||
unlock_kernel();
|
unlock_kernel();
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -906,11 +875,12 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry)
|
|||||||
inode->i_ctime = dir->i_ctime;
|
inode->i_ctime = dir->i_ctime;
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
||||||
end_unlink:
|
end_unlink:
|
||||||
if (fibh.sbh != fibh.ebh)
|
if (fibh.sbh != fibh.ebh)
|
||||||
brelse(fibh.ebh);
|
brelse(fibh.ebh);
|
||||||
brelse(fibh.sbh);
|
brelse(fibh.sbh);
|
||||||
out:
|
|
||||||
|
out:
|
||||||
unlock_kernel();
|
unlock_kernel();
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -922,7 +892,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
|
|||||||
struct pathComponent *pc;
|
struct pathComponent *pc;
|
||||||
char *compstart;
|
char *compstart;
|
||||||
struct udf_fileident_bh fibh;
|
struct udf_fileident_bh fibh;
|
||||||
struct extent_position epos = { NULL, 0, {0, 0} };
|
struct extent_position epos = {};
|
||||||
int eoffset, elen = 0;
|
int eoffset, elen = 0;
|
||||||
struct fileIdentDesc *fi;
|
struct fileIdentDesc *fi;
|
||||||
struct fileIdentDesc cfi;
|
struct fileIdentDesc cfi;
|
||||||
@ -945,26 +915,22 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
|
|||||||
uint32_t elen;
|
uint32_t elen;
|
||||||
|
|
||||||
block = udf_new_block(inode->i_sb, inode,
|
block = udf_new_block(inode->i_sb, inode,
|
||||||
UDF_I_LOCATION(inode).
|
UDF_I_LOCATION(inode).partitionReferenceNum,
|
||||||
partitionReferenceNum,
|
UDF_I_LOCATION(inode).logicalBlockNum, &err);
|
||||||
UDF_I_LOCATION(inode).logicalBlockNum,
|
|
||||||
&err);
|
|
||||||
if (!block)
|
if (!block)
|
||||||
goto out_no_entry;
|
goto out_no_entry;
|
||||||
epos.block = UDF_I_LOCATION(inode);
|
epos.block = UDF_I_LOCATION(inode);
|
||||||
epos.offset = udf_file_entry_alloc_offset(inode);
|
epos.offset = udf_file_entry_alloc_offset(inode);
|
||||||
epos.bh = NULL;
|
epos.bh = NULL;
|
||||||
eloc.logicalBlockNum = block;
|
eloc.logicalBlockNum = block;
|
||||||
eloc.partitionReferenceNum =
|
eloc.partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum;
|
||||||
UDF_I_LOCATION(inode).partitionReferenceNum;
|
|
||||||
elen = inode->i_sb->s_blocksize;
|
elen = inode->i_sb->s_blocksize;
|
||||||
UDF_I_LENEXTENTS(inode) = elen;
|
UDF_I_LENEXTENTS(inode) = elen;
|
||||||
udf_add_aext(inode, &epos, eloc, elen, 0);
|
udf_add_aext(inode, &epos, eloc, elen, 0);
|
||||||
brelse(epos.bh);
|
brelse(epos.bh);
|
||||||
|
|
||||||
block = udf_get_pblock(inode->i_sb, block,
|
block = udf_get_pblock(inode->i_sb, block,
|
||||||
UDF_I_LOCATION(inode).
|
UDF_I_LOCATION(inode).partitionReferenceNum, 0);
|
||||||
partitionReferenceNum, 0);
|
|
||||||
epos.bh = udf_tread(inode->i_sb, block);
|
epos.bh = udf_tread(inode->i_sb, block);
|
||||||
lock_buffer(epos.bh);
|
lock_buffer(epos.bh);
|
||||||
memset(epos.bh->b_data, 0x00, inode->i_sb->s_blocksize);
|
memset(epos.bh->b_data, 0x00, inode->i_sb->s_blocksize);
|
||||||
@ -972,8 +938,9 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
|
|||||||
unlock_buffer(epos.bh);
|
unlock_buffer(epos.bh);
|
||||||
mark_buffer_dirty_inode(epos.bh, inode);
|
mark_buffer_dirty_inode(epos.bh, inode);
|
||||||
ea = epos.bh->b_data + udf_ext0_offset(inode);
|
ea = epos.bh->b_data + udf_ext0_offset(inode);
|
||||||
} else
|
} else {
|
||||||
ea = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode);
|
ea = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode);
|
||||||
|
}
|
||||||
|
|
||||||
eoffset = inode->i_sb->s_blocksize - udf_ext0_offset(inode);
|
eoffset = inode->i_sb->s_blocksize - udf_ext0_offset(inode);
|
||||||
pc = (struct pathComponent *)ea;
|
pc = (struct pathComponent *)ea;
|
||||||
@ -1010,20 +977,17 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
|
|||||||
if (compstart[0] == '.') {
|
if (compstart[0] == '.') {
|
||||||
if ((symname - compstart) == 1)
|
if ((symname - compstart) == 1)
|
||||||
pc->componentType = 4;
|
pc->componentType = 4;
|
||||||
else if ((symname - compstart) == 2
|
else if ((symname - compstart) == 2 && compstart[1] == '.')
|
||||||
&& compstart[1] == '.')
|
|
||||||
pc->componentType = 3;
|
pc->componentType = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pc->componentType == 5) {
|
if (pc->componentType == 5) {
|
||||||
if (!
|
namelen = udf_put_filename(inode->i_sb, compstart, name,
|
||||||
(namelen =
|
symname - compstart);
|
||||||
udf_put_filename(inode->i_sb, compstart, name,
|
if (!namelen)
|
||||||
symname - compstart)))
|
|
||||||
goto out_no_entry;
|
goto out_no_entry;
|
||||||
|
|
||||||
if (elen + sizeof(struct pathComponent) + namelen >
|
if (elen + sizeof(struct pathComponent) + namelen > eoffset)
|
||||||
eoffset)
|
|
||||||
goto out_no_entry;
|
goto out_no_entry;
|
||||||
else
|
else
|
||||||
pc->lengthComponentIdent = namelen;
|
pc->lengthComponentIdent = namelen;
|
||||||
@ -1053,12 +1017,10 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
|
|||||||
if (UDF_SB_LVIDBH(inode->i_sb)) {
|
if (UDF_SB_LVIDBH(inode->i_sb)) {
|
||||||
struct logicalVolHeaderDesc *lvhd;
|
struct logicalVolHeaderDesc *lvhd;
|
||||||
uint64_t uniqueID;
|
uint64_t uniqueID;
|
||||||
lvhd =
|
lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->logicalVolContentsUse);
|
||||||
(struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->
|
|
||||||
logicalVolContentsUse);
|
|
||||||
uniqueID = le64_to_cpu(lvhd->uniqueID);
|
uniqueID = le64_to_cpu(lvhd->uniqueID);
|
||||||
*(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
|
*(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
|
||||||
cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL);
|
cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL);
|
||||||
if (!(++uniqueID & 0x00000000FFFFFFFFUL))
|
if (!(++uniqueID & 0x00000000FFFFFFFFUL))
|
||||||
uniqueID += 16;
|
uniqueID += 16;
|
||||||
lvhd->uniqueID = cpu_to_le64(uniqueID);
|
lvhd->uniqueID = cpu_to_le64(uniqueID);
|
||||||
@ -1074,11 +1036,11 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
|
|||||||
d_instantiate(dentry, inode);
|
d_instantiate(dentry, inode);
|
||||||
err = 0;
|
err = 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
unlock_kernel();
|
unlock_kernel();
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
out_no_entry:
|
out_no_entry:
|
||||||
inode_dec_link_count(inode);
|
inode_dec_link_count(inode);
|
||||||
iput(inode);
|
iput(inode);
|
||||||
goto out;
|
goto out;
|
||||||
@ -1107,12 +1069,10 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
|
|||||||
if (UDF_SB_LVIDBH(inode->i_sb)) {
|
if (UDF_SB_LVIDBH(inode->i_sb)) {
|
||||||
struct logicalVolHeaderDesc *lvhd;
|
struct logicalVolHeaderDesc *lvhd;
|
||||||
uint64_t uniqueID;
|
uint64_t uniqueID;
|
||||||
lvhd =
|
lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->logicalVolContentsUse);
|
||||||
(struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->
|
|
||||||
logicalVolContentsUse);
|
|
||||||
uniqueID = le64_to_cpu(lvhd->uniqueID);
|
uniqueID = le64_to_cpu(lvhd->uniqueID);
|
||||||
*(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
|
*(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
|
||||||
cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL);
|
cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL);
|
||||||
if (!(++uniqueID & 0x00000000FFFFFFFFUL))
|
if (!(++uniqueID & 0x00000000FFFFFFFFUL))
|
||||||
uniqueID += 16;
|
uniqueID += 16;
|
||||||
lvhd->uniqueID = cpu_to_le64(uniqueID);
|
lvhd->uniqueID = cpu_to_le64(uniqueID);
|
||||||
@ -1122,6 +1082,7 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
|
|||||||
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
|
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
|
||||||
mark_inode_dirty(dir);
|
mark_inode_dirty(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fibh.sbh != fibh.ebh)
|
if (fibh.sbh != fibh.ebh)
|
||||||
brelse(fibh.ebh);
|
brelse(fibh.ebh);
|
||||||
brelse(fibh.sbh);
|
brelse(fibh.sbh);
|
||||||
@ -1131,6 +1092,7 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
|
|||||||
atomic_inc(&inode->i_count);
|
atomic_inc(&inode->i_count);
|
||||||
d_instantiate(dentry, inode);
|
d_instantiate(dentry, inode);
|
||||||
unlock_kernel();
|
unlock_kernel();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1143,8 +1105,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||||||
struct inode *old_inode = old_dentry->d_inode;
|
struct inode *old_inode = old_dentry->d_inode;
|
||||||
struct inode *new_inode = new_dentry->d_inode;
|
struct inode *new_inode = new_dentry->d_inode;
|
||||||
struct udf_fileident_bh ofibh, nfibh;
|
struct udf_fileident_bh ofibh, nfibh;
|
||||||
struct fileIdentDesc *ofi = NULL, *nfi = NULL, *dir_fi =
|
struct fileIdentDesc *ofi = NULL, *nfi = NULL, *dir_fi = NULL, ocfi, ncfi;
|
||||||
NULL, ocfi, ncfi;
|
|
||||||
struct buffer_head *dir_bh = NULL;
|
struct buffer_head *dir_bh = NULL;
|
||||||
int retval = -ENOENT;
|
int retval = -ENOENT;
|
||||||
kernel_lb_addr tloc;
|
kernel_lb_addr tloc;
|
||||||
@ -1181,36 +1142,27 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||||||
if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB) {
|
if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB) {
|
||||||
dir_fi = udf_get_fileident(UDF_I_DATA(old_inode) -
|
dir_fi = udf_get_fileident(UDF_I_DATA(old_inode) -
|
||||||
(UDF_I_EFE(old_inode) ?
|
(UDF_I_EFE(old_inode) ?
|
||||||
sizeof(struct
|
sizeof(struct extendedFileEntry) :
|
||||||
extendedFileEntry) :
|
|
||||||
sizeof(struct fileEntry)),
|
sizeof(struct fileEntry)),
|
||||||
old_inode->i_sb->s_blocksize,
|
old_inode->i_sb->s_blocksize, &offset);
|
||||||
&offset);
|
|
||||||
} else {
|
} else {
|
||||||
dir_bh = udf_bread(old_inode, 0, 0, &retval);
|
dir_bh = udf_bread(old_inode, 0, 0, &retval);
|
||||||
if (!dir_bh)
|
if (!dir_bh)
|
||||||
goto end_rename;
|
goto end_rename;
|
||||||
dir_fi =
|
dir_fi = udf_get_fileident(dir_bh->b_data, old_inode->i_sb->s_blocksize, &offset);
|
||||||
udf_get_fileident(dir_bh->b_data,
|
|
||||||
old_inode->i_sb->s_blocksize,
|
|
||||||
&offset);
|
|
||||||
}
|
}
|
||||||
if (!dir_fi)
|
if (!dir_fi)
|
||||||
goto end_rename;
|
goto end_rename;
|
||||||
tloc = lelb_to_cpu(dir_fi->icb.extLocation);
|
tloc = lelb_to_cpu(dir_fi->icb.extLocation);
|
||||||
if (udf_get_lb_pblock(old_inode->i_sb, tloc, 0)
|
if (udf_get_lb_pblock(old_inode->i_sb, tloc, 0) != old_dir->i_ino)
|
||||||
!= old_dir->i_ino)
|
|
||||||
goto end_rename;
|
goto end_rename;
|
||||||
|
|
||||||
retval = -EMLINK;
|
retval = -EMLINK;
|
||||||
if (!new_inode
|
if (!new_inode && new_dir->i_nlink >= (256 << sizeof(new_dir->i_nlink)) - 1)
|
||||||
&& new_dir->i_nlink >=
|
|
||||||
(256 << sizeof(new_dir->i_nlink)) - 1)
|
|
||||||
goto end_rename;
|
goto end_rename;
|
||||||
}
|
}
|
||||||
if (!nfi) {
|
if (!nfi) {
|
||||||
nfi =
|
nfi = udf_add_entry(new_dir, new_dentry, &nfibh, &ncfi, &retval);
|
||||||
udf_add_entry(new_dir, new_dentry, &nfibh, &ncfi, &retval);
|
|
||||||
if (!nfi)
|
if (!nfi)
|
||||||
goto end_rename;
|
goto end_rename;
|
||||||
}
|
}
|
||||||
@ -1244,13 +1196,12 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||||||
if (dir_fi) {
|
if (dir_fi) {
|
||||||
dir_fi->icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(new_dir));
|
dir_fi->icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(new_dir));
|
||||||
udf_update_tag((char *)dir_fi, (sizeof(struct fileIdentDesc) +
|
udf_update_tag((char *)dir_fi, (sizeof(struct fileIdentDesc) +
|
||||||
le16_to_cpu(dir_fi->
|
le16_to_cpu(dir_fi->lengthOfImpUse) + 3) & ~3);
|
||||||
lengthOfImpUse) +
|
|
||||||
3) & ~3);
|
|
||||||
if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB) {
|
if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB) {
|
||||||
mark_inode_dirty(old_inode);
|
mark_inode_dirty(old_inode);
|
||||||
} else
|
} else {
|
||||||
mark_buffer_dirty_inode(dir_bh, old_inode);
|
mark_buffer_dirty_inode(dir_bh, old_inode);
|
||||||
|
}
|
||||||
inode_dec_link_count(old_dir);
|
inode_dec_link_count(old_dir);
|
||||||
if (new_inode) {
|
if (new_inode) {
|
||||||
inode_dec_link_count(new_inode);
|
inode_dec_link_count(new_inode);
|
||||||
@ -1268,7 +1219,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||||||
|
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
||||||
end_rename:
|
end_rename:
|
||||||
brelse(dir_bh);
|
brelse(dir_bh);
|
||||||
if (nfi) {
|
if (nfi) {
|
||||||
if (nfibh.sbh != nfibh.ebh)
|
if (nfibh.sbh != nfibh.ebh)
|
||||||
@ -1276,17 +1227,18 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||||||
brelse(nfibh.sbh);
|
brelse(nfibh.sbh);
|
||||||
}
|
}
|
||||||
unlock_kernel();
|
unlock_kernel();
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct inode_operations udf_dir_inode_operations = {
|
const struct inode_operations udf_dir_inode_operations = {
|
||||||
.lookup = udf_lookup,
|
.lookup = udf_lookup,
|
||||||
.create = udf_create,
|
.create = udf_create,
|
||||||
.link = udf_link,
|
.link = udf_link,
|
||||||
.unlink = udf_unlink,
|
.unlink = udf_unlink,
|
||||||
.symlink = udf_symlink,
|
.symlink = udf_symlink,
|
||||||
.mkdir = udf_mkdir,
|
.mkdir = udf_mkdir,
|
||||||
.rmdir = udf_rmdir,
|
.rmdir = udf_rmdir,
|
||||||
.mknod = udf_mknod,
|
.mknod = udf_mknod,
|
||||||
.rename = udf_rename,
|
.rename = udf_rename,
|
||||||
};
|
};
|
||||||
|
@ -66,64 +66,64 @@
|
|||||||
#define IS_DF_SOFT_WRITE_PROTECT 0x02
|
#define IS_DF_SOFT_WRITE_PROTECT 0x02
|
||||||
|
|
||||||
struct UDFIdentSuffix {
|
struct UDFIdentSuffix {
|
||||||
__le16 UDFRevision;
|
__le16 UDFRevision;
|
||||||
uint8_t OSClass;
|
uint8_t OSClass;
|
||||||
uint8_t OSIdentifier;
|
uint8_t OSIdentifier;
|
||||||
uint8_t reserved[4];
|
uint8_t reserved[4];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
struct impIdentSuffix {
|
struct impIdentSuffix {
|
||||||
uint8_t OSClass;
|
uint8_t OSClass;
|
||||||
uint8_t OSIdentifier;
|
uint8_t OSIdentifier;
|
||||||
uint8_t reserved[6];
|
uint8_t reserved[6];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
struct appIdentSuffix {
|
struct appIdentSuffix {
|
||||||
uint8_t impUse[8];
|
uint8_t impUse[8];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Logical Volume Integrity Descriptor (UDF 2.50 2.2.6) */
|
/* Logical Volume Integrity Descriptor (UDF 2.50 2.2.6) */
|
||||||
/* Implementation Use (UDF 2.50 2.2.6.4) */
|
/* Implementation Use (UDF 2.50 2.2.6.4) */
|
||||||
struct logicalVolIntegrityDescImpUse {
|
struct logicalVolIntegrityDescImpUse {
|
||||||
regid impIdent;
|
regid impIdent;
|
||||||
__le32 numFiles;
|
__le32 numFiles;
|
||||||
__le32 numDirs;
|
__le32 numDirs;
|
||||||
__le16 minUDFReadRev;
|
__le16 minUDFReadRev;
|
||||||
__le16 minUDFWriteRev;
|
__le16 minUDFWriteRev;
|
||||||
__le16 maxUDFWriteRev;
|
__le16 maxUDFWriteRev;
|
||||||
uint8_t impUse[0];
|
uint8_t impUse[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Implementation Use Volume Descriptor (UDF 2.50 2.2.7) */
|
/* Implementation Use Volume Descriptor (UDF 2.50 2.2.7) */
|
||||||
/* Implementation Use (UDF 2.50 2.2.7.2) */
|
/* Implementation Use (UDF 2.50 2.2.7.2) */
|
||||||
struct impUseVolDescImpUse {
|
struct impUseVolDescImpUse {
|
||||||
charspec LVICharset;
|
charspec LVICharset;
|
||||||
dstring logicalVolIdent[128];
|
dstring logicalVolIdent[128];
|
||||||
dstring LVInfo1[36];
|
dstring LVInfo1[36];
|
||||||
dstring LVInfo2[36];
|
dstring LVInfo2[36];
|
||||||
dstring LVInfo3[36];
|
dstring LVInfo3[36];
|
||||||
regid impIdent;
|
regid impIdent;
|
||||||
uint8_t impUse[128];
|
uint8_t impUse[128];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
struct udfPartitionMap2 {
|
struct udfPartitionMap2 {
|
||||||
uint8_t partitionMapType;
|
uint8_t partitionMapType;
|
||||||
uint8_t partitionMapLength;
|
uint8_t partitionMapLength;
|
||||||
uint8_t reserved1[2];
|
uint8_t reserved1[2];
|
||||||
regid partIdent;
|
regid partIdent;
|
||||||
__le16 volSeqNum;
|
__le16 volSeqNum;
|
||||||
__le16 partitionNum;
|
__le16 partitionNum;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Virtual Partition Map (UDF 2.50 2.2.8) */
|
/* Virtual Partition Map (UDF 2.50 2.2.8) */
|
||||||
struct virtualPartitionMap {
|
struct virtualPartitionMap {
|
||||||
uint8_t partitionMapType;
|
uint8_t partitionMapType;
|
||||||
uint8_t partitionMapLength;
|
uint8_t partitionMapLength;
|
||||||
uint8_t reserved1[2];
|
uint8_t reserved1[2];
|
||||||
regid partIdent;
|
regid partIdent;
|
||||||
__le16 volSeqNum;
|
__le16 volSeqNum;
|
||||||
__le16 partitionNum;
|
__le16 partitionNum;
|
||||||
uint8_t reserved2[24];
|
uint8_t reserved2[24];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Sparable Partition Map (UDF 2.50 2.2.9) */
|
/* Sparable Partition Map (UDF 2.50 2.2.9) */
|
||||||
@ -143,62 +143,62 @@ struct sparablePartitionMap {
|
|||||||
|
|
||||||
/* Metadata Partition Map (UDF 2.4.0 2.2.10) */
|
/* Metadata Partition Map (UDF 2.4.0 2.2.10) */
|
||||||
struct metadataPartitionMap {
|
struct metadataPartitionMap {
|
||||||
uint8_t partitionMapType;
|
uint8_t partitionMapType;
|
||||||
uint8_t partitionMapLength;
|
uint8_t partitionMapLength;
|
||||||
uint8_t reserved1[2];
|
uint8_t reserved1[2];
|
||||||
regid partIdent;
|
regid partIdent;
|
||||||
__le16 volSeqNum;
|
__le16 volSeqNum;
|
||||||
__le16 partitionNum;
|
__le16 partitionNum;
|
||||||
__le32 metadataFileLoc;
|
__le32 metadataFileLoc;
|
||||||
__le32 metadataMirrorFileLoc;
|
__le32 metadataMirrorFileLoc;
|
||||||
__le32 metadataBitmapFileLoc;
|
__le32 metadataBitmapFileLoc;
|
||||||
__le32 allocUnitSize;
|
__le32 allocUnitSize;
|
||||||
__le16 alignUnitSize;
|
__le16 alignUnitSize;
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
uint8_t reserved2[5];
|
uint8_t reserved2[5];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Virtual Allocation Table (UDF 1.5 2.2.10) */
|
/* Virtual Allocation Table (UDF 1.5 2.2.10) */
|
||||||
struct virtualAllocationTable15 {
|
struct virtualAllocationTable15 {
|
||||||
__le32 VirtualSector[0];
|
__le32 VirtualSector[0];
|
||||||
regid vatIdent;
|
regid vatIdent;
|
||||||
__le32 previousVATICBLoc;
|
__le32 previousVATICBLoc;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#define ICBTAG_FILE_TYPE_VAT15 0x00U
|
#define ICBTAG_FILE_TYPE_VAT15 0x00U
|
||||||
|
|
||||||
/* Virtual Allocation Table (UDF 2.50 2.2.11) */
|
/* Virtual Allocation Table (UDF 2.50 2.2.11) */
|
||||||
struct virtualAllocationTable20 {
|
struct virtualAllocationTable20 {
|
||||||
__le16 lengthHeader;
|
__le16 lengthHeader;
|
||||||
__le16 lengthImpUse;
|
__le16 lengthImpUse;
|
||||||
dstring logicalVolIdent[128];
|
dstring logicalVolIdent[128];
|
||||||
__le32 previousVATICBLoc;
|
__le32 previousVATICBLoc;
|
||||||
__le32 numFiles;
|
__le32 numFiles;
|
||||||
__le32 numDirs;
|
__le32 numDirs;
|
||||||
__le16 minReadRevision;
|
__le16 minReadRevision;
|
||||||
__le16 minWriteRevision;
|
__le16 minWriteRevision;
|
||||||
__le16 maxWriteRevision;
|
__le16 maxWriteRevision;
|
||||||
__le16 reserved;
|
__le16 reserved;
|
||||||
uint8_t impUse[0];
|
uint8_t impUse[0];
|
||||||
__le32 vatEntry[0];
|
__le32 vatEntry[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#define ICBTAG_FILE_TYPE_VAT20 0xF8U
|
#define ICBTAG_FILE_TYPE_VAT20 0xF8U
|
||||||
|
|
||||||
/* Sparing Table (UDF 2.50 2.2.12) */
|
/* Sparing Table (UDF 2.50 2.2.12) */
|
||||||
struct sparingEntry {
|
struct sparingEntry {
|
||||||
__le32 origLocation;
|
__le32 origLocation;
|
||||||
__le32 mappedLocation;
|
__le32 mappedLocation;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
struct sparingTable {
|
struct sparingTable {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
regid sparingIdent;
|
regid sparingIdent;
|
||||||
__le16 reallocationTableLen;
|
__le16 reallocationTableLen;
|
||||||
__le16 reserved;
|
__le16 reserved;
|
||||||
__le32 sequenceNum;
|
__le32 sequenceNum;
|
||||||
struct sparingEntry
|
struct sparingEntry
|
||||||
mapEntry[0];
|
mapEntry[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Metadata File (and Metadata Mirror File) (UDF 2.50 2.2.13.1) */
|
/* Metadata File (and Metadata Mirror File) (UDF 2.50 2.2.13.1) */
|
||||||
@ -208,8 +208,8 @@ struct sparingTable {
|
|||||||
|
|
||||||
/* struct long_ad ICB - ADImpUse (UDF 2.50 2.2.4.3) */
|
/* struct long_ad ICB - ADImpUse (UDF 2.50 2.2.4.3) */
|
||||||
struct allocDescImpUse {
|
struct allocDescImpUse {
|
||||||
__le16 flags;
|
__le16 flags;
|
||||||
uint8_t impUse[4];
|
uint8_t impUse[4];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#define AD_IU_EXT_ERASED 0x0001
|
#define AD_IU_EXT_ERASED 0x0001
|
||||||
@ -220,23 +220,23 @@ struct allocDescImpUse {
|
|||||||
/* Implementation Use Extended Attribute (UDF 2.50 3.3.4.5) */
|
/* Implementation Use Extended Attribute (UDF 2.50 3.3.4.5) */
|
||||||
/* FreeEASpace (UDF 2.50 3.3.4.5.1.1) */
|
/* FreeEASpace (UDF 2.50 3.3.4.5.1.1) */
|
||||||
struct freeEaSpace {
|
struct freeEaSpace {
|
||||||
__le16 headerChecksum;
|
__le16 headerChecksum;
|
||||||
uint8_t freeEASpace[0];
|
uint8_t freeEASpace[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* DVD Copyright Management Information (UDF 2.50 3.3.4.5.1.2) */
|
/* DVD Copyright Management Information (UDF 2.50 3.3.4.5.1.2) */
|
||||||
struct DVDCopyrightImpUse {
|
struct DVDCopyrightImpUse {
|
||||||
__le16 headerChecksum;
|
__le16 headerChecksum;
|
||||||
uint8_t CGMSInfo;
|
uint8_t CGMSInfo;
|
||||||
uint8_t dataType;
|
uint8_t dataType;
|
||||||
uint8_t protectionSystemInfo[4];
|
uint8_t protectionSystemInfo[4];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* Application Use Extended Attribute (UDF 2.50 3.3.4.6) */
|
/* Application Use Extended Attribute (UDF 2.50 3.3.4.6) */
|
||||||
/* FreeAppEASpace (UDF 2.50 3.3.4.6.1) */
|
/* FreeAppEASpace (UDF 2.50 3.3.4.6.1) */
|
||||||
struct freeAppEASpace {
|
struct freeAppEASpace {
|
||||||
__le16 headerChecksum;
|
__le16 headerChecksum;
|
||||||
uint8_t freeEASpace[0];
|
uint8_t freeEASpace[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* UDF Defined System Stream (UDF 2.50 3.3.7) */
|
/* UDF Defined System Stream (UDF 2.50 3.3.7) */
|
||||||
@ -276,4 +276,4 @@ struct freeAppEASpace {
|
|||||||
#define UDF_OS_ID_BEOS 0x00U
|
#define UDF_OS_ID_BEOS 0x00U
|
||||||
#define UDF_OS_ID_WINCE 0x00U
|
#define UDF_OS_ID_WINCE 0x00U
|
||||||
|
|
||||||
#endif /* _OSTA_UDF_H */
|
#endif /* _OSTA_UDF_H */
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
*
|
*
|
||||||
* HISTORY
|
* HISTORY
|
||||||
*
|
*
|
||||||
* 12/06/98 blf Created file.
|
* 12/06/98 blf Created file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -32,19 +32,17 @@ inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block,
|
|||||||
uint16_t partition, uint32_t offset)
|
uint16_t partition, uint32_t offset)
|
||||||
{
|
{
|
||||||
if (partition >= UDF_SB_NUMPARTS(sb)) {
|
if (partition >= UDF_SB_NUMPARTS(sb)) {
|
||||||
udf_debug
|
udf_debug("block=%d, partition=%d, offset=%d: invalid partition\n",
|
||||||
("block=%d, partition=%d, offset=%d: invalid partition\n",
|
block, partition, offset);
|
||||||
block, partition, offset);
|
|
||||||
return 0xFFFFFFFF;
|
return 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
if (UDF_SB_PARTFUNC(sb, partition))
|
if (UDF_SB_PARTFUNC(sb, partition))
|
||||||
return UDF_SB_PARTFUNC(sb, partition) (sb, block, partition,
|
return UDF_SB_PARTFUNC(sb, partition)(sb, block, partition, offset);
|
||||||
offset);
|
|
||||||
else
|
else
|
||||||
return UDF_SB_PARTROOT(sb, partition) + block + offset;
|
return UDF_SB_PARTROOT(sb, partition) + block + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block,
|
uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
|
||||||
uint16_t partition, uint32_t offset)
|
uint16_t partition, uint32_t offset)
|
||||||
{
|
{
|
||||||
struct buffer_head *bh = NULL;
|
struct buffer_head *bh = NULL;
|
||||||
@ -52,14 +50,11 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block,
|
|||||||
uint32_t index;
|
uint32_t index;
|
||||||
uint32_t loc;
|
uint32_t loc;
|
||||||
|
|
||||||
index =
|
index = (sb->s_blocksize - UDF_SB_TYPEVIRT(sb,partition).s_start_offset) / sizeof(uint32_t);
|
||||||
(sb->s_blocksize -
|
|
||||||
UDF_SB_TYPEVIRT(sb, partition).s_start_offset) / sizeof(uint32_t);
|
|
||||||
|
|
||||||
if (block > UDF_SB_TYPEVIRT(sb, partition).s_num_entries) {
|
if (block > UDF_SB_TYPEVIRT(sb,partition).s_num_entries) {
|
||||||
udf_debug
|
udf_debug("Trying to access block beyond end of VAT (%d max %d)\n",
|
||||||
("Trying to access block beyond end of VAT (%d max %d)\n",
|
block, UDF_SB_TYPEVIRT(sb,partition).s_num_entries);
|
||||||
block, UDF_SB_TYPEVIRT(sb, partition).s_num_entries);
|
|
||||||
return 0xFFFFFFFF;
|
return 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,10 +64,7 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block,
|
|||||||
index = block % (sb->s_blocksize / sizeof(uint32_t));
|
index = block % (sb->s_blocksize / sizeof(uint32_t));
|
||||||
} else {
|
} else {
|
||||||
newblock = 0;
|
newblock = 0;
|
||||||
index =
|
index = UDF_SB_TYPEVIRT(sb,partition).s_start_offset / sizeof(uint32_t) + block;
|
||||||
UDF_SB_TYPEVIRT(sb,
|
|
||||||
partition).s_start_offset /
|
|
||||||
sizeof(uint32_t) + block;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loc = udf_block_map(UDF_SB_VAT(sb), newblock);
|
loc = udf_block_map(UDF_SB_VAT(sb), newblock);
|
||||||
@ -83,7 +75,7 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block,
|
|||||||
return 0xFFFFFFFF;
|
return 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
loc = le32_to_cpu(((__le32 *) bh->b_data)[index]);
|
loc = le32_to_cpu(((__le32 *)bh->b_data)[index]);
|
||||||
|
|
||||||
brelse(bh);
|
brelse(bh);
|
||||||
|
|
||||||
@ -93,8 +85,8 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return udf_get_pblock(sb, loc,
|
return udf_get_pblock(sb, loc,
|
||||||
UDF_I_LOCATION(UDF_SB_VAT(sb)).
|
UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum,
|
||||||
partitionReferenceNum, offset);
|
offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint32_t udf_get_pblock_virt20(struct super_block * sb, uint32_t block,
|
inline uint32_t udf_get_pblock_virt20(struct super_block * sb, uint32_t block,
|
||||||
@ -108,40 +100,29 @@ uint32_t udf_get_pblock_spar15(struct super_block * sb, uint32_t block,
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct sparingTable *st = NULL;
|
struct sparingTable *st = NULL;
|
||||||
uint32_t packet =
|
uint32_t packet = (block + offset) & ~(UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1);
|
||||||
(block + offset) & ~(UDF_SB_TYPESPAR(sb, partition).s_packet_len -
|
|
||||||
1);
|
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
if (UDF_SB_TYPESPAR(sb, partition).s_spar_map[i] != NULL) {
|
if (UDF_SB_TYPESPAR(sb,partition).s_spar_map[i] != NULL) {
|
||||||
st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,
|
st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,partition).s_spar_map[i]->b_data;
|
||||||
partition).
|
|
||||||
s_spar_map[i]->b_data;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (st) {
|
if (st) {
|
||||||
for (i = 0; i < le16_to_cpu(st->reallocationTableLen); i++) {
|
for (i = 0; i < le16_to_cpu(st->reallocationTableLen); i++) {
|
||||||
if (le32_to_cpu(st->mapEntry[i].origLocation) >=
|
if (le32_to_cpu(st->mapEntry[i].origLocation) >= 0xFFFFFFF0) {
|
||||||
0xFFFFFFF0)
|
|
||||||
break;
|
break;
|
||||||
else if (le32_to_cpu(st->mapEntry[i].origLocation) ==
|
} else if (le32_to_cpu(st->mapEntry[i].origLocation) == packet) {
|
||||||
packet) {
|
return le32_to_cpu(st->mapEntry[i].mappedLocation) +
|
||||||
return le32_to_cpu(st->mapEntry[i].
|
((block + offset) & (UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1));
|
||||||
mappedLocation) + ((block +
|
} else if (le32_to_cpu(st->mapEntry[i].origLocation) > packet) {
|
||||||
offset) &
|
|
||||||
(UDF_SB_TYPESPAR
|
|
||||||
(sb,
|
|
||||||
partition).
|
|
||||||
s_packet_len
|
|
||||||
- 1));
|
|
||||||
} else if (le32_to_cpu(st->mapEntry[i].origLocation) >
|
|
||||||
packet)
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return UDF_SB_PARTROOT(sb, partition) + block + offset;
|
|
||||||
|
return UDF_SB_PARTROOT(sb,partition) + block + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
|
int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
|
||||||
@ -153,20 +134,14 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
|
|||||||
int i, j, k, l;
|
int i, j, k, l;
|
||||||
|
|
||||||
for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) {
|
for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) {
|
||||||
if (old_block > UDF_SB_PARTROOT(sb, i) &&
|
if (old_block > UDF_SB_PARTROOT(sb,i) &&
|
||||||
old_block < UDF_SB_PARTROOT(sb, i) + UDF_SB_PARTLEN(sb, i))
|
old_block < UDF_SB_PARTROOT(sb,i) + UDF_SB_PARTLEN(sb,i)) {
|
||||||
{
|
sdata = &UDF_SB_TYPESPAR(sb,i);
|
||||||
sdata = &UDF_SB_TYPESPAR(sb, i);
|
packet = (old_block - UDF_SB_PARTROOT(sb,i)) & ~(sdata->s_packet_len - 1);
|
||||||
packet =
|
|
||||||
(old_block -
|
|
||||||
UDF_SB_PARTROOT(sb,
|
|
||||||
i)) & ~(sdata->s_packet_len - 1);
|
|
||||||
|
|
||||||
for (j = 0; j < 4; j++) {
|
for (j = 0; j < 4; j++) {
|
||||||
if (UDF_SB_TYPESPAR(sb, i).s_spar_map[j] !=
|
if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL) {
|
||||||
NULL) {
|
st = (struct sparingTable *)sdata->s_spar_map[j]->b_data;
|
||||||
st = (struct sparingTable *)sdata->
|
|
||||||
s_spar_map[j]->b_data;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,122 +149,51 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
|
|||||||
if (!st)
|
if (!st)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (k = 0; k < le16_to_cpu(st->reallocationTableLen);
|
for (k = 0; k < le16_to_cpu(st->reallocationTableLen); k++) {
|
||||||
k++) {
|
if (le32_to_cpu(st->mapEntry[k].origLocation) == 0xFFFFFFFF) {
|
||||||
if (le32_to_cpu(st->mapEntry[k].origLocation) ==
|
|
||||||
0xFFFFFFFF) {
|
|
||||||
for (; j < 4; j++) {
|
for (; j < 4; j++) {
|
||||||
if (sdata->s_spar_map[j]) {
|
if (sdata->s_spar_map[j]) {
|
||||||
st = (struct
|
st = (struct sparingTable *)sdata->s_spar_map[j]->b_data;
|
||||||
sparingTable *)
|
st->mapEntry[k].origLocation = cpu_to_le32(packet);
|
||||||
sdata->
|
udf_update_tag((char *)st, sizeof(struct sparingTable) + le16_to_cpu(st->reallocationTableLen) * sizeof(struct sparingEntry));
|
||||||
s_spar_map[j]->
|
mark_buffer_dirty(sdata->s_spar_map[j]);
|
||||||
b_data;
|
|
||||||
st->mapEntry[k].
|
|
||||||
origLocation =
|
|
||||||
cpu_to_le32(packet);
|
|
||||||
udf_update_tag((char *)
|
|
||||||
st,
|
|
||||||
sizeof
|
|
||||||
(struct
|
|
||||||
sparingTable)
|
|
||||||
+
|
|
||||||
le16_to_cpu
|
|
||||||
(st->
|
|
||||||
reallocationTableLen)
|
|
||||||
*
|
|
||||||
sizeof
|
|
||||||
(struct
|
|
||||||
sparingEntry));
|
|
||||||
mark_buffer_dirty
|
|
||||||
(sdata->
|
|
||||||
s_spar_map[j]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*new_block =
|
*new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
|
||||||
le32_to_cpu(st->mapEntry[k].
|
((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
|
||||||
mappedLocation) +
|
|
||||||
((old_block -
|
|
||||||
UDF_SB_PARTROOT(sb,
|
|
||||||
i)) & (sdata->
|
|
||||||
s_packet_len
|
|
||||||
- 1));
|
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else if (le32_to_cpu(st->mapEntry[k].origLocation) == packet) {
|
||||||
if (le32_to_cpu
|
*new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
|
||||||
(st->mapEntry[k].origLocation) ==
|
((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
|
||||||
packet) {
|
|
||||||
*new_block =
|
|
||||||
le32_to_cpu(st->mapEntry[k].
|
|
||||||
mappedLocation) +
|
|
||||||
((old_block -
|
|
||||||
UDF_SB_PARTROOT(sb,
|
|
||||||
i)) & (sdata->
|
|
||||||
s_packet_len
|
|
||||||
- 1));
|
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else if (le32_to_cpu(st->mapEntry[k].origLocation) > packet) {
|
||||||
if (le32_to_cpu
|
|
||||||
(st->mapEntry[k].origLocation) > packet)
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (l = k; l < le16_to_cpu(st->reallocationTableLen);
|
|
||||||
l++) {
|
for (l = k; l < le16_to_cpu(st->reallocationTableLen); l++) {
|
||||||
if (le32_to_cpu(st->mapEntry[l].origLocation) ==
|
if (le32_to_cpu(st->mapEntry[l].origLocation) == 0xFFFFFFFF) {
|
||||||
0xFFFFFFFF) {
|
|
||||||
for (; j < 4; j++) {
|
for (; j < 4; j++) {
|
||||||
if (sdata->s_spar_map[j]) {
|
if (sdata->s_spar_map[j]) {
|
||||||
st = (struct
|
st = (struct sparingTable *)sdata->s_spar_map[j]->b_data;
|
||||||
sparingTable *)
|
mapEntry = st->mapEntry[l];
|
||||||
sdata->
|
mapEntry.origLocation = cpu_to_le32(packet);
|
||||||
s_spar_map[j]->
|
memmove(&st->mapEntry[k + 1], &st->mapEntry[k], (l - k) * sizeof(struct sparingEntry));
|
||||||
b_data;
|
st->mapEntry[k] = mapEntry;
|
||||||
mapEntry =
|
udf_update_tag((char *)st, sizeof(struct sparingTable) + le16_to_cpu(st->reallocationTableLen) * sizeof(struct sparingEntry));
|
||||||
st->mapEntry[l];
|
mark_buffer_dirty(sdata->s_spar_map[j]);
|
||||||
mapEntry.origLocation =
|
|
||||||
cpu_to_le32(packet);
|
|
||||||
memmove(&st->
|
|
||||||
mapEntry[k + 1],
|
|
||||||
&st->
|
|
||||||
mapEntry[k],
|
|
||||||
(l -
|
|
||||||
k) *
|
|
||||||
sizeof(struct
|
|
||||||
sparingEntry));
|
|
||||||
st->mapEntry[k] =
|
|
||||||
mapEntry;
|
|
||||||
udf_update_tag((char *)
|
|
||||||
st,
|
|
||||||
sizeof
|
|
||||||
(struct
|
|
||||||
sparingTable)
|
|
||||||
+
|
|
||||||
le16_to_cpu
|
|
||||||
(st->
|
|
||||||
reallocationTableLen)
|
|
||||||
*
|
|
||||||
sizeof
|
|
||||||
(struct
|
|
||||||
sparingEntry));
|
|
||||||
mark_buffer_dirty
|
|
||||||
(sdata->
|
|
||||||
s_spar_map[j]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*new_block =
|
*new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
|
||||||
le32_to_cpu(st->mapEntry[k].
|
((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
|
||||||
mappedLocation) +
|
|
||||||
((old_block -
|
|
||||||
UDF_SB_PARTROOT(sb,
|
|
||||||
i)) & (sdata->
|
|
||||||
s_packet_len
|
|
||||||
- 1));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
} /* if old_block */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == UDF_SB_NUMPARTS(sb)) {
|
if (i == UDF_SB_NUMPARTS(sb)) {
|
||||||
/* outside of partitions */
|
/* outside of partitions */
|
||||||
/* for now, fail =) */
|
/* for now, fail =) */
|
||||||
|
1033
fs/udf/super.c
1033
fs/udf/super.c
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,7 @@
|
|||||||
* Each contributing author retains all rights to their own work.
|
* Each contributing author retains all rights to their own work.
|
||||||
*
|
*
|
||||||
* (C) 1998-2001 Ben Fennema
|
* (C) 1998-2001 Ben Fennema
|
||||||
* (C) 1999 Stelias Computing Inc
|
* (C) 1999 Stelias Computing Inc
|
||||||
*
|
*
|
||||||
* HISTORY
|
* HISTORY
|
||||||
*
|
*
|
||||||
@ -33,8 +33,7 @@
|
|||||||
#include <linux/buffer_head.h>
|
#include <linux/buffer_head.h>
|
||||||
#include "udf_i.h"
|
#include "udf_i.h"
|
||||||
|
|
||||||
static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen,
|
static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen, char *to)
|
||||||
char *to)
|
|
||||||
{
|
{
|
||||||
struct pathComponent *pc;
|
struct pathComponent *pc;
|
||||||
int elen = 0;
|
int elen = 0;
|
||||||
@ -81,9 +80,9 @@ static int udf_symlink_filler(struct file *file, struct page *page)
|
|||||||
char *p = kmap(page);
|
char *p = kmap(page);
|
||||||
|
|
||||||
lock_kernel();
|
lock_kernel();
|
||||||
if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB)
|
if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) {
|
||||||
symlink = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode);
|
symlink = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode);
|
||||||
else {
|
} else {
|
||||||
bh = sb_bread(inode->i_sb, udf_block_map(inode, 0));
|
bh = sb_bread(inode->i_sb, udf_block_map(inode, 0));
|
||||||
|
|
||||||
if (!bh)
|
if (!bh)
|
||||||
@ -100,7 +99,8 @@ static int udf_symlink_filler(struct file *file, struct page *page)
|
|||||||
kunmap(page);
|
kunmap(page);
|
||||||
unlock_page(page);
|
unlock_page(page);
|
||||||
return 0;
|
return 0;
|
||||||
out:
|
|
||||||
|
out:
|
||||||
unlock_kernel();
|
unlock_kernel();
|
||||||
SetPageError(page);
|
SetPageError(page);
|
||||||
kunmap(page);
|
kunmap(page);
|
||||||
@ -112,5 +112,5 @@ static int udf_symlink_filler(struct file *file, struct page *page)
|
|||||||
* symlinks can't do much...
|
* symlinks can't do much...
|
||||||
*/
|
*/
|
||||||
const struct address_space_operations udf_symlink_aops = {
|
const struct address_space_operations udf_symlink_aops = {
|
||||||
.readpage = udf_symlink_filler,
|
.readpage = udf_symlink_filler,
|
||||||
};
|
};
|
||||||
|
@ -32,13 +32,11 @@ static void extent_trunc(struct inode *inode, struct extent_position *epos,
|
|||||||
kernel_lb_addr eloc, int8_t etype, uint32_t elen,
|
kernel_lb_addr eloc, int8_t etype, uint32_t elen,
|
||||||
uint32_t nelen)
|
uint32_t nelen)
|
||||||
{
|
{
|
||||||
kernel_lb_addr neloc = { 0, 0 };
|
kernel_lb_addr neloc = {};
|
||||||
int last_block =
|
int last_block = (elen + inode->i_sb->s_blocksize - 1) >>
|
||||||
(elen + inode->i_sb->s_blocksize -
|
inode->i_sb->s_blocksize_bits;
|
||||||
1) >> inode->i_sb->s_blocksize_bits;
|
int first_block = (nelen + inode->i_sb->s_blocksize - 1) >>
|
||||||
int first_block =
|
inode->i_sb->s_blocksize_bits;
|
||||||
(nelen + inode->i_sb->s_blocksize -
|
|
||||||
1) >> inode->i_sb->s_blocksize_bits;
|
|
||||||
|
|
||||||
if (nelen) {
|
if (nelen) {
|
||||||
if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) {
|
if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) {
|
||||||
@ -70,7 +68,7 @@ static void extent_trunc(struct inode *inode, struct extent_position *epos,
|
|||||||
*/
|
*/
|
||||||
void udf_truncate_tail_extent(struct inode *inode)
|
void udf_truncate_tail_extent(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct extent_position epos = { NULL, 0, {0, 0} };
|
struct extent_position epos = {};
|
||||||
kernel_lb_addr eloc;
|
kernel_lb_addr eloc;
|
||||||
uint32_t elen, nelen;
|
uint32_t elen, nelen;
|
||||||
uint64_t lbcount = 0;
|
uint64_t lbcount = 0;
|
||||||
@ -156,16 +154,16 @@ void udf_discard_prealloc(struct inode *inode)
|
|||||||
extent_trunc(inode, &epos, eloc, etype, elen, 0);
|
extent_trunc(inode, &epos, eloc, etype, elen, 0);
|
||||||
if (!epos.bh) {
|
if (!epos.bh) {
|
||||||
UDF_I_LENALLOC(inode) =
|
UDF_I_LENALLOC(inode) =
|
||||||
epos.offset - udf_file_entry_alloc_offset(inode);
|
epos.offset - udf_file_entry_alloc_offset(inode);
|
||||||
mark_inode_dirty(inode);
|
mark_inode_dirty(inode);
|
||||||
} else {
|
} else {
|
||||||
struct allocExtDesc *aed =
|
struct allocExtDesc *aed =
|
||||||
(struct allocExtDesc *)(epos.bh->b_data);
|
(struct allocExtDesc *)(epos.bh->b_data);
|
||||||
aed->lengthAllocDescs =
|
aed->lengthAllocDescs =
|
||||||
cpu_to_le32(epos.offset -
|
cpu_to_le32(epos.offset -
|
||||||
sizeof(struct allocExtDesc));
|
sizeof(struct allocExtDesc));
|
||||||
if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)
|
if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) ||
|
||||||
|| UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
|
UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
|
||||||
udf_update_tag(epos.bh->b_data, epos.offset);
|
udf_update_tag(epos.bh->b_data, epos.offset);
|
||||||
else
|
else
|
||||||
udf_update_tag(epos.bh->b_data,
|
udf_update_tag(epos.bh->b_data,
|
||||||
@ -182,7 +180,7 @@ void udf_discard_prealloc(struct inode *inode)
|
|||||||
void udf_truncate_extents(struct inode *inode)
|
void udf_truncate_extents(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct extent_position epos;
|
struct extent_position epos;
|
||||||
kernel_lb_addr eloc, neloc = { 0, 0 };
|
kernel_lb_addr eloc, neloc = {};
|
||||||
uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc;
|
uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc;
|
||||||
int8_t etype;
|
int8_t etype;
|
||||||
struct super_block *sb = inode->i_sb;
|
struct super_block *sb = inode->i_sb;
|
||||||
@ -198,9 +196,8 @@ void udf_truncate_extents(struct inode *inode)
|
|||||||
BUG();
|
BUG();
|
||||||
|
|
||||||
etype = inode_bmap(inode, first_block, &epos, &eloc, &elen, &offset);
|
etype = inode_bmap(inode, first_block, &epos, &eloc, &elen, &offset);
|
||||||
byte_offset =
|
byte_offset = (offset << sb->s_blocksize_bits) +
|
||||||
(offset << sb->s_blocksize_bits) +
|
(inode->i_size & (sb->s_blocksize - 1));
|
||||||
(inode->i_size & (sb->s_blocksize - 1));
|
|
||||||
if (etype != -1) {
|
if (etype != -1) {
|
||||||
epos.offset -= adsize;
|
epos.offset -= adsize;
|
||||||
extent_trunc(inode, &epos, eloc, etype, elen, byte_offset);
|
extent_trunc(inode, &epos, eloc, etype, elen, byte_offset);
|
||||||
@ -215,9 +212,7 @@ void udf_truncate_extents(struct inode *inode)
|
|||||||
else
|
else
|
||||||
lenalloc -= sizeof(struct allocExtDesc);
|
lenalloc -= sizeof(struct allocExtDesc);
|
||||||
|
|
||||||
while ((etype =
|
while ((etype = udf_current_aext(inode, &epos, &eloc, &elen, 0)) != -1) {
|
||||||
udf_current_aext(inode, &epos, &eloc, &elen,
|
|
||||||
0)) != -1) {
|
|
||||||
if (etype == (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) {
|
if (etype == (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) {
|
||||||
udf_write_aext(inode, &epos, neloc, nelen, 0);
|
udf_write_aext(inode, &epos, neloc, nelen, 0);
|
||||||
if (indirect_ext_len) {
|
if (indirect_ext_len) {
|
||||||
@ -229,52 +224,35 @@ void udf_truncate_extents(struct inode *inode)
|
|||||||
0, indirect_ext_len);
|
0, indirect_ext_len);
|
||||||
} else {
|
} else {
|
||||||
if (!epos.bh) {
|
if (!epos.bh) {
|
||||||
UDF_I_LENALLOC(inode) =
|
UDF_I_LENALLOC(inode) = lenalloc;
|
||||||
lenalloc;
|
|
||||||
mark_inode_dirty(inode);
|
mark_inode_dirty(inode);
|
||||||
} else {
|
} else {
|
||||||
struct allocExtDesc *aed =
|
struct allocExtDesc *aed =
|
||||||
(struct allocExtDesc
|
(struct allocExtDesc *)(epos.bh->b_data);
|
||||||
*)(epos.bh->b_data);
|
|
||||||
aed->lengthAllocDescs =
|
aed->lengthAllocDescs =
|
||||||
cpu_to_le32(lenalloc);
|
cpu_to_le32(lenalloc);
|
||||||
if (!UDF_QUERY_FLAG
|
if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) ||
|
||||||
(sb, UDF_FLAG_STRICT)
|
UDF_SB_UDFREV(sb) >= 0x0201)
|
||||||
|| UDF_SB_UDFREV(sb) >=
|
udf_update_tag(epos.bh->b_data,
|
||||||
0x0201)
|
lenalloc +
|
||||||
udf_update_tag(epos.bh->
|
sizeof(struct allocExtDesc));
|
||||||
b_data,
|
|
||||||
lenalloc
|
|
||||||
+
|
|
||||||
sizeof
|
|
||||||
(struct
|
|
||||||
allocExtDesc));
|
|
||||||
else
|
else
|
||||||
udf_update_tag(epos.bh->
|
udf_update_tag(epos.bh->b_data,
|
||||||
b_data,
|
sizeof(struct allocExtDesc));
|
||||||
sizeof
|
mark_buffer_dirty_inode(epos.bh, inode);
|
||||||
(struct
|
|
||||||
allocExtDesc));
|
|
||||||
mark_buffer_dirty_inode(epos.bh,
|
|
||||||
inode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
brelse(epos.bh);
|
brelse(epos.bh);
|
||||||
epos.offset = sizeof(struct allocExtDesc);
|
epos.offset = sizeof(struct allocExtDesc);
|
||||||
epos.block = eloc;
|
epos.block = eloc;
|
||||||
epos.bh =
|
epos.bh = udf_tread(sb, udf_get_lb_pblock(sb, eloc, 0));
|
||||||
udf_tread(sb,
|
|
||||||
udf_get_lb_pblock(sb, eloc, 0));
|
|
||||||
if (elen)
|
if (elen)
|
||||||
indirect_ext_len = (elen +
|
indirect_ext_len = (elen + sb->s_blocksize -1) >>
|
||||||
sb->s_blocksize -
|
sb->s_blocksize_bits;
|
||||||
1) >> sb->
|
|
||||||
s_blocksize_bits;
|
|
||||||
else
|
else
|
||||||
indirect_ext_len = 1;
|
indirect_ext_len = 1;
|
||||||
} else {
|
} else {
|
||||||
extent_trunc(inode, &epos, eloc, etype, elen,
|
extent_trunc(inode, &epos, eloc, etype, elen, 0);
|
||||||
0);
|
|
||||||
epos.offset += adsize;
|
epos.offset += adsize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -292,16 +270,13 @@ void udf_truncate_extents(struct inode *inode)
|
|||||||
struct allocExtDesc *aed =
|
struct allocExtDesc *aed =
|
||||||
(struct allocExtDesc *)(epos.bh->b_data);
|
(struct allocExtDesc *)(epos.bh->b_data);
|
||||||
aed->lengthAllocDescs = cpu_to_le32(lenalloc);
|
aed->lengthAllocDescs = cpu_to_le32(lenalloc);
|
||||||
if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT)
|
if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) ||
|
||||||
|| UDF_SB_UDFREV(sb) >= 0x0201)
|
UDF_SB_UDFREV(sb) >= 0x0201)
|
||||||
udf_update_tag(epos.bh->b_data,
|
udf_update_tag(epos.bh->b_data,
|
||||||
lenalloc +
|
lenalloc + sizeof(struct allocExtDesc));
|
||||||
sizeof(struct
|
|
||||||
allocExtDesc));
|
|
||||||
else
|
else
|
||||||
udf_update_tag(epos.bh->b_data,
|
udf_update_tag(epos.bh->b_data,
|
||||||
sizeof(struct
|
sizeof(struct allocExtDesc));
|
||||||
allocExtDesc));
|
|
||||||
mark_buffer_dirty_inode(epos.bh, inode);
|
mark_buffer_dirty_inode(epos.bh, inode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -314,21 +289,14 @@ void udf_truncate_extents(struct inode *inode)
|
|||||||
* no extent above inode->i_size => truncate is
|
* no extent above inode->i_size => truncate is
|
||||||
* extending the file by 'offset' blocks.
|
* extending the file by 'offset' blocks.
|
||||||
*/
|
*/
|
||||||
if ((!epos.bh
|
if ((!epos.bh &&
|
||||||
&& epos.offset ==
|
epos.offset == udf_file_entry_alloc_offset(inode)) ||
|
||||||
udf_file_entry_alloc_offset(inode)) || (epos.bh
|
(epos.bh && epos.offset == sizeof(struct allocExtDesc))) {
|
||||||
&& epos.
|
|
||||||
offset ==
|
|
||||||
sizeof
|
|
||||||
(struct
|
|
||||||
allocExtDesc)))
|
|
||||||
{
|
|
||||||
/* File has no extents at all or has empty last
|
/* File has no extents at all or has empty last
|
||||||
* indirect extent! Create a fake extent... */
|
* indirect extent! Create a fake extent... */
|
||||||
extent.extLocation.logicalBlockNum = 0;
|
extent.extLocation.logicalBlockNum = 0;
|
||||||
extent.extLocation.partitionReferenceNum = 0;
|
extent.extLocation.partitionReferenceNum = 0;
|
||||||
extent.extLength =
|
extent.extLength = EXT_NOT_RECORDED_NOT_ALLOCATED;
|
||||||
EXT_NOT_RECORDED_NOT_ALLOCATED;
|
|
||||||
} else {
|
} else {
|
||||||
epos.offset -= adsize;
|
epos.offset -= adsize;
|
||||||
etype = udf_next_aext(inode, &epos,
|
etype = udf_next_aext(inode, &epos,
|
||||||
@ -337,10 +305,7 @@ void udf_truncate_extents(struct inode *inode)
|
|||||||
extent.extLength |= etype << 30;
|
extent.extLength |= etype << 30;
|
||||||
}
|
}
|
||||||
udf_extend_file(inode, &epos, &extent,
|
udf_extend_file(inode, &epos, &extent,
|
||||||
offset +
|
offset + ((inode->i_size & (sb->s_blocksize - 1)) != 0));
|
||||||
((inode->
|
|
||||||
i_size & (sb->s_blocksize - 1)) !=
|
|
||||||
0));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UDF_I_LENEXTENTS(inode) = inode->i_size;
|
UDF_I_LENEXTENTS(inode) = inode->i_size;
|
||||||
|
@ -23,4 +23,4 @@ static inline struct udf_inode_info *UDF_I(struct inode *inode)
|
|||||||
#define UDF_I_LAD(X) ( UDF_I(X)->i_ext.i_lad )
|
#define UDF_I_LAD(X) ( UDF_I(X)->i_ext.i_lad )
|
||||||
#define UDF_I_DATA(X) ( UDF_I(X)->i_ext.i_data )
|
#define UDF_I_DATA(X) ( UDF_I(X)->i_ext.i_data )
|
||||||
|
|
||||||
#endif /* !defined(_LINUX_UDF_I_H) */
|
#endif /* !defined(_LINUX_UDF_I_H) */
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
#define UDF_FLAG_VARCONV 8
|
#define UDF_FLAG_VARCONV 8
|
||||||
#define UDF_FLAG_NLS_MAP 9
|
#define UDF_FLAG_NLS_MAP 9
|
||||||
#define UDF_FLAG_UTF8 10
|
#define UDF_FLAG_UTF8 10
|
||||||
#define UDF_FLAG_UID_FORGET 11 /* save -1 for uid to disk */
|
#define UDF_FLAG_UID_FORGET 11 /* save -1 for uid to disk */
|
||||||
#define UDF_FLAG_UID_IGNORE 12 /* use sb uid instead of on disk uid */
|
#define UDF_FLAG_UID_IGNORE 12 /* use sb uid instead of on disk uid */
|
||||||
#define UDF_FLAG_GID_FORGET 13
|
#define UDF_FLAG_GID_FORGET 13
|
||||||
#define UDF_FLAG_GID_IGNORE 14
|
#define UDF_FLAG_GID_IGNORE 14
|
||||||
|
|
||||||
@ -41,8 +41,7 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
|
|||||||
|
|
||||||
#define UDF_SB_FREE(X)\
|
#define UDF_SB_FREE(X)\
|
||||||
{\
|
{\
|
||||||
if (UDF_SB(X))\
|
if (UDF_SB(X)) {\
|
||||||
{\
|
|
||||||
kfree(UDF_SB_PARTMAPS(X));\
|
kfree(UDF_SB_PARTMAPS(X));\
|
||||||
UDF_SB_PARTMAPS(X) = NULL;\
|
UDF_SB_PARTMAPS(X) = NULL;\
|
||||||
}\
|
}\
|
||||||
@ -51,13 +50,10 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
|
|||||||
#define UDF_SB_ALLOC_PARTMAPS(X,Y)\
|
#define UDF_SB_ALLOC_PARTMAPS(X,Y)\
|
||||||
{\
|
{\
|
||||||
UDF_SB_PARTMAPS(X) = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
|
UDF_SB_PARTMAPS(X) = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
|
||||||
if (UDF_SB_PARTMAPS(X) != NULL)\
|
if (UDF_SB_PARTMAPS(X) != NULL) {\
|
||||||
{\
|
|
||||||
UDF_SB_NUMPARTS(X) = Y;\
|
UDF_SB_NUMPARTS(X) = Y;\
|
||||||
memset(UDF_SB_PARTMAPS(X), 0x00, sizeof(struct udf_part_map) * Y);\
|
memset(UDF_SB_PARTMAPS(X), 0x00, sizeof(struct udf_part_map) * Y);\
|
||||||
}\
|
} else {\
|
||||||
else\
|
|
||||||
{\
|
|
||||||
UDF_SB_NUMPARTS(X) = 0;\
|
UDF_SB_NUMPARTS(X) = 0;\
|
||||||
udf_error(X, __FUNCTION__, "Unable to allocate space for %d partition maps", Y);\
|
udf_error(X, __FUNCTION__, "Unable to allocate space for %d partition maps", Y);\
|
||||||
}\
|
}\
|
||||||
@ -72,15 +68,12 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
|
|||||||
UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = kmalloc(size, GFP_KERNEL);\
|
UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = kmalloc(size, GFP_KERNEL);\
|
||||||
else\
|
else\
|
||||||
UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = vmalloc(size);\
|
UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = vmalloc(size);\
|
||||||
if (UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap != NULL)\
|
if (UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap != NULL) {\
|
||||||
{\
|
|
||||||
memset(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap, 0x00, size);\
|
memset(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap, 0x00, size);\
|
||||||
UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_block_bitmap =\
|
UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_block_bitmap =\
|
||||||
(struct buffer_head **)(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap + 1);\
|
(struct buffer_head **)(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap + 1);\
|
||||||
UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_nr_groups = nr_groups;\
|
UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_nr_groups = nr_groups;\
|
||||||
}\
|
} else {\
|
||||||
else\
|
|
||||||
{\
|
|
||||||
udf_error(X, __FUNCTION__, "Unable to allocate space for bitmap and %d buffer_head pointers", nr_groups);\
|
udf_error(X, __FUNCTION__, "Unable to allocate space for bitmap and %d buffer_head pointers", nr_groups);\
|
||||||
}\
|
}\
|
||||||
}
|
}
|
||||||
@ -90,8 +83,7 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
|
|||||||
int i;\
|
int i;\
|
||||||
int nr_groups = UDF_SB_BITMAP_NR_GROUPS(X,Y,Z);\
|
int nr_groups = UDF_SB_BITMAP_NR_GROUPS(X,Y,Z);\
|
||||||
int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * nr_groups);\
|
int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * nr_groups);\
|
||||||
for (i=0; i<nr_groups; i++)\
|
for (i = 0; i < nr_groups; i++) {\
|
||||||
{\
|
|
||||||
if (UDF_SB_BITMAP(X,Y,Z,i))\
|
if (UDF_SB_BITMAP(X,Y,Z,i))\
|
||||||
brelse(UDF_SB_BITMAP(X,Y,Z,i));\
|
brelse(UDF_SB_BITMAP(X,Y,Z,i));\
|
||||||
}\
|
}\
|
||||||
@ -139,4 +131,4 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
|
|||||||
#define UDF_SB_FLAGS(X) ( UDF_SB(X)->s_flags )
|
#define UDF_SB_FLAGS(X) ( UDF_SB(X)->s_flags )
|
||||||
#define UDF_SB_VAT(X) ( UDF_SB(X)->s_vat )
|
#define UDF_SB_VAT(X) ( UDF_SB(X)->s_vat )
|
||||||
|
|
||||||
#endif /* __LINUX_UDF_SB_H */
|
#endif /* __LINUX_UDF_SB_H */
|
||||||
|
@ -63,8 +63,8 @@ struct udf_vds_record {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct generic_desc {
|
struct generic_desc {
|
||||||
tag descTag;
|
tag descTag;
|
||||||
__le32 volDescSeqNum;
|
__le32 volDescSeqNum;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ustr {
|
struct ustr {
|
||||||
|
@ -7,75 +7,93 @@
|
|||||||
static inline kernel_lb_addr lelb_to_cpu(lb_addr in)
|
static inline kernel_lb_addr lelb_to_cpu(lb_addr in)
|
||||||
{
|
{
|
||||||
kernel_lb_addr out;
|
kernel_lb_addr out;
|
||||||
|
|
||||||
out.logicalBlockNum = le32_to_cpu(in.logicalBlockNum);
|
out.logicalBlockNum = le32_to_cpu(in.logicalBlockNum);
|
||||||
out.partitionReferenceNum = le16_to_cpu(in.partitionReferenceNum);
|
out.partitionReferenceNum = le16_to_cpu(in.partitionReferenceNum);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline lb_addr cpu_to_lelb(kernel_lb_addr in)
|
static inline lb_addr cpu_to_lelb(kernel_lb_addr in)
|
||||||
{
|
{
|
||||||
lb_addr out;
|
lb_addr out;
|
||||||
|
|
||||||
out.logicalBlockNum = cpu_to_le32(in.logicalBlockNum);
|
out.logicalBlockNum = cpu_to_le32(in.logicalBlockNum);
|
||||||
out.partitionReferenceNum = cpu_to_le16(in.partitionReferenceNum);
|
out.partitionReferenceNum = cpu_to_le16(in.partitionReferenceNum);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline kernel_timestamp lets_to_cpu(timestamp in)
|
static inline kernel_timestamp lets_to_cpu(timestamp in)
|
||||||
{
|
{
|
||||||
kernel_timestamp out;
|
kernel_timestamp out;
|
||||||
|
|
||||||
memcpy(&out, &in, sizeof(timestamp));
|
memcpy(&out, &in, sizeof(timestamp));
|
||||||
out.typeAndTimezone = le16_to_cpu(in.typeAndTimezone);
|
out.typeAndTimezone = le16_to_cpu(in.typeAndTimezone);
|
||||||
out.year = le16_to_cpu(in.year);
|
out.year = le16_to_cpu(in.year);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline short_ad lesa_to_cpu(short_ad in)
|
static inline short_ad lesa_to_cpu(short_ad in)
|
||||||
{
|
{
|
||||||
short_ad out;
|
short_ad out;
|
||||||
|
|
||||||
out.extLength = le32_to_cpu(in.extLength);
|
out.extLength = le32_to_cpu(in.extLength);
|
||||||
out.extPosition = le32_to_cpu(in.extPosition);
|
out.extPosition = le32_to_cpu(in.extPosition);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline short_ad cpu_to_lesa(short_ad in)
|
static inline short_ad cpu_to_lesa(short_ad in)
|
||||||
{
|
{
|
||||||
short_ad out;
|
short_ad out;
|
||||||
|
|
||||||
out.extLength = cpu_to_le32(in.extLength);
|
out.extLength = cpu_to_le32(in.extLength);
|
||||||
out.extPosition = cpu_to_le32(in.extPosition);
|
out.extPosition = cpu_to_le32(in.extPosition);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline kernel_long_ad lela_to_cpu(long_ad in)
|
static inline kernel_long_ad lela_to_cpu(long_ad in)
|
||||||
{
|
{
|
||||||
kernel_long_ad out;
|
kernel_long_ad out;
|
||||||
|
|
||||||
out.extLength = le32_to_cpu(in.extLength);
|
out.extLength = le32_to_cpu(in.extLength);
|
||||||
out.extLocation = lelb_to_cpu(in.extLocation);
|
out.extLocation = lelb_to_cpu(in.extLocation);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline long_ad cpu_to_lela(kernel_long_ad in)
|
static inline long_ad cpu_to_lela(kernel_long_ad in)
|
||||||
{
|
{
|
||||||
long_ad out;
|
long_ad out;
|
||||||
|
|
||||||
out.extLength = cpu_to_le32(in.extLength);
|
out.extLength = cpu_to_le32(in.extLength);
|
||||||
out.extLocation = cpu_to_lelb(in.extLocation);
|
out.extLocation = cpu_to_lelb(in.extLocation);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline kernel_extent_ad leea_to_cpu(extent_ad in)
|
static inline kernel_extent_ad leea_to_cpu(extent_ad in)
|
||||||
{
|
{
|
||||||
kernel_extent_ad out;
|
kernel_extent_ad out;
|
||||||
|
|
||||||
out.extLength = le32_to_cpu(in.extLength);
|
out.extLength = le32_to_cpu(in.extLength);
|
||||||
out.extLocation = le32_to_cpu(in.extLocation);
|
out.extLocation = le32_to_cpu(in.extLocation);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline timestamp cpu_to_lets(kernel_timestamp in)
|
static inline timestamp cpu_to_lets(kernel_timestamp in)
|
||||||
{
|
{
|
||||||
timestamp out;
|
timestamp out;
|
||||||
|
|
||||||
memcpy(&out, &in, sizeof(timestamp));
|
memcpy(&out, &in, sizeof(timestamp));
|
||||||
out.typeAndTimezone = cpu_to_le16(in.typeAndTimezone);
|
out.typeAndTimezone = cpu_to_le16(in.typeAndTimezone);
|
||||||
out.year = cpu_to_le16(in.year);
|
out.year = cpu_to_le16(in.year);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __UDF_ENDIAN_H */
|
#endif /* __UDF_ENDIAN_H */
|
||||||
|
@ -18,18 +18,18 @@
|
|||||||
Boston, MA 02111-1307, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* dgb 10/02/98: ripped this from glibc source to help convert timestamps to unix time
|
* dgb 10/02/98: ripped this from glibc source to help convert timestamps to unix time
|
||||||
* 10/04/98: added new table-based lookup after seeing how ugly the gnu code is
|
* 10/04/98: added new table-based lookup after seeing how ugly the gnu code is
|
||||||
* blf 09/27/99: ripped out all the old code and inserted new table from
|
* blf 09/27/99: ripped out all the old code and inserted new table from
|
||||||
* John Brockmeyer (without leap second corrections)
|
* John Brockmeyer (without leap second corrections)
|
||||||
* rewrote udf_stamp_to_time and fixed timezone accounting in
|
* rewrote udf_stamp_to_time and fixed timezone accounting in
|
||||||
udf_time_to_stamp.
|
* udf_time_to_stamp.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We don't take into account leap seconds. This may be correct or incorrect.
|
* We don't take into account leap seconds. This may be correct or incorrect.
|
||||||
* For more NIST information (especially dealing with leap seconds), see:
|
* For more NIST information (especially dealing with leap seconds), see:
|
||||||
* http://www.boulder.nist.gov/timefreq/pubs/bulletin/leapsecond.htm
|
* http://www.boulder.nist.gov/timefreq/pubs/bulletin/leapsecond.htm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
@ -54,28 +54,28 @@ static const unsigned short int __mon_yday[2][13] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_YEAR_SECONDS 69
|
#define MAX_YEAR_SECONDS 69
|
||||||
#define SPD 0x15180 /*3600*24 */
|
#define SPD 0x15180 /*3600*24 */
|
||||||
#define SPY(y,l,s) (SPD * (365*y+l)+s)
|
#define SPY(y,l,s) (SPD * (365*y+l)+s)
|
||||||
|
|
||||||
static time_t year_seconds[MAX_YEAR_SECONDS] = {
|
static time_t year_seconds[MAX_YEAR_SECONDS]= {
|
||||||
/*1970*/ SPY(0, 0, 0), SPY(1, 0, 0), SPY(2, 0, 0), SPY(3, 1, 0),
|
/*1970*/ SPY( 0, 0,0), SPY( 1, 0,0), SPY( 2, 0,0), SPY( 3, 1,0),
|
||||||
/*1974*/ SPY(4, 1, 0), SPY(5, 1, 0), SPY(6, 1, 0), SPY(7, 2, 0),
|
/*1974*/ SPY( 4, 1,0), SPY( 5, 1,0), SPY( 6, 1,0), SPY( 7, 2,0),
|
||||||
/*1978*/ SPY(8, 2, 0), SPY(9, 2, 0), SPY(10, 2, 0), SPY(11, 3, 0),
|
/*1978*/ SPY( 8, 2,0), SPY( 9, 2,0), SPY(10, 2,0), SPY(11, 3,0),
|
||||||
/*1982*/ SPY(12, 3, 0), SPY(13, 3, 0), SPY(14, 3, 0), SPY(15, 4, 0),
|
/*1982*/ SPY(12, 3,0), SPY(13, 3,0), SPY(14, 3,0), SPY(15, 4,0),
|
||||||
/*1986*/ SPY(16, 4, 0), SPY(17, 4, 0), SPY(18, 4, 0), SPY(19, 5, 0),
|
/*1986*/ SPY(16, 4,0), SPY(17, 4,0), SPY(18, 4,0), SPY(19, 5,0),
|
||||||
/*1990*/ SPY(20, 5, 0), SPY(21, 5, 0), SPY(22, 5, 0), SPY(23, 6, 0),
|
/*1990*/ SPY(20, 5,0), SPY(21, 5,0), SPY(22, 5,0), SPY(23, 6,0),
|
||||||
/*1994*/ SPY(24, 6, 0), SPY(25, 6, 0), SPY(26, 6, 0), SPY(27, 7, 0),
|
/*1994*/ SPY(24, 6,0), SPY(25, 6,0), SPY(26, 6,0), SPY(27, 7,0),
|
||||||
/*1998*/ SPY(28, 7, 0), SPY(29, 7, 0), SPY(30, 7, 0), SPY(31, 8, 0),
|
/*1998*/ SPY(28, 7,0), SPY(29, 7,0), SPY(30, 7,0), SPY(31, 8,0),
|
||||||
/*2002*/ SPY(32, 8, 0), SPY(33, 8, 0), SPY(34, 8, 0), SPY(35, 9, 0),
|
/*2002*/ SPY(32, 8,0), SPY(33, 8,0), SPY(34, 8,0), SPY(35, 9,0),
|
||||||
/*2006*/ SPY(36, 9, 0), SPY(37, 9, 0), SPY(38, 9, 0), SPY(39, 10, 0),
|
/*2006*/ SPY(36, 9,0), SPY(37, 9,0), SPY(38, 9,0), SPY(39,10,0),
|
||||||
/*2010*/ SPY(40, 10, 0), SPY(41, 10, 0), SPY(42, 10, 0), SPY(43, 11, 0),
|
/*2010*/ SPY(40,10,0), SPY(41,10,0), SPY(42,10,0), SPY(43,11,0),
|
||||||
/*2014*/ SPY(44, 11, 0), SPY(45, 11, 0), SPY(46, 11, 0), SPY(47, 12, 0),
|
/*2014*/ SPY(44,11,0), SPY(45,11,0), SPY(46,11,0), SPY(47,12,0),
|
||||||
/*2018*/ SPY(48, 12, 0), SPY(49, 12, 0), SPY(50, 12, 0), SPY(51, 13, 0),
|
/*2018*/ SPY(48,12,0), SPY(49,12,0), SPY(50,12,0), SPY(51,13,0),
|
||||||
/*2022*/ SPY(52, 13, 0), SPY(53, 13, 0), SPY(54, 13, 0), SPY(55, 14, 0),
|
/*2022*/ SPY(52,13,0), SPY(53,13,0), SPY(54,13,0), SPY(55,14,0),
|
||||||
/*2026*/ SPY(56, 14, 0), SPY(57, 14, 0), SPY(58, 14, 0), SPY(59, 15, 0),
|
/*2026*/ SPY(56,14,0), SPY(57,14,0), SPY(58,14,0), SPY(59,15,0),
|
||||||
/*2030*/ SPY(60, 15, 0), SPY(61, 15, 0), SPY(62, 15, 0), SPY(63, 16, 0),
|
/*2030*/ SPY(60,15,0), SPY(61,15,0), SPY(62,15,0), SPY(63,16,0),
|
||||||
/*2034*/ SPY(64, 16, 0), SPY(65, 16, 0), SPY(66, 16, 0), SPY(67, 17, 0),
|
/*2034*/ SPY(64,16,0), SPY(65,16,0), SPY(66,16,0), SPY(67,17,0),
|
||||||
/*2038*/ SPY(68, 17, 0)
|
/*2038*/ SPY(68,17,0)
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct timezone sys_tz;
|
extern struct timezone sys_tz;
|
||||||
@ -83,7 +83,7 @@ extern struct timezone sys_tz;
|
|||||||
#define SECS_PER_HOUR (60 * 60)
|
#define SECS_PER_HOUR (60 * 60)
|
||||||
#define SECS_PER_DAY (SECS_PER_HOUR * 24)
|
#define SECS_PER_DAY (SECS_PER_HOUR * 24)
|
||||||
|
|
||||||
time_t *udf_stamp_to_time(time_t * dest, long *dest_usec, kernel_timestamp src)
|
time_t *udf_stamp_to_time(time_t *dest, long *dest_usec, kernel_timestamp src)
|
||||||
{
|
{
|
||||||
int yday;
|
int yday;
|
||||||
uint8_t type = src.typeAndTimezone >> 12;
|
uint8_t type = src.typeAndTimezone >> 12;
|
||||||
@ -93,10 +93,11 @@ time_t *udf_stamp_to_time(time_t * dest, long *dest_usec, kernel_timestamp src)
|
|||||||
offset = src.typeAndTimezone << 4;
|
offset = src.typeAndTimezone << 4;
|
||||||
/* sign extent offset */
|
/* sign extent offset */
|
||||||
offset = (offset >> 4);
|
offset = (offset >> 4);
|
||||||
if (offset == -2047) /* unspecified offset */
|
if (offset == -2047) /* unspecified offset */
|
||||||
offset = 0;
|
offset = 0;
|
||||||
} else
|
} else {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ((src.year < EPOCH_YEAR) ||
|
if ((src.year < EPOCH_YEAR) ||
|
||||||
(src.year >= EPOCH_YEAR + MAX_YEAR_SECONDS)) {
|
(src.year >= EPOCH_YEAR + MAX_YEAR_SECONDS)) {
|
||||||
@ -107,12 +108,10 @@ time_t *udf_stamp_to_time(time_t * dest, long *dest_usec, kernel_timestamp src)
|
|||||||
*dest = year_seconds[src.year - EPOCH_YEAR];
|
*dest = year_seconds[src.year - EPOCH_YEAR];
|
||||||
*dest -= offset * 60;
|
*dest -= offset * 60;
|
||||||
|
|
||||||
yday = ((__mon_yday[__isleap(src.year)]
|
yday = ((__mon_yday[__isleap (src.year)]
|
||||||
[src.month - 1]) + (src.day - 1));
|
[src.month - 1]) + (src.day - 1));
|
||||||
*dest += (((yday * 24) + src.hour) * 60 + src.minute) * 60 + src.second;
|
*dest += ( ( (yday * 24) + src.hour ) * 60 + src.minute ) * 60 + src.second;
|
||||||
*dest_usec =
|
*dest_usec = src.centiseconds * 10000 + src.hundredsOfMicroseconds * 100 + src.microseconds;
|
||||||
src.centiseconds * 10000 + src.hundredsOfMicroseconds * 100 +
|
|
||||||
src.microseconds;
|
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,8 +144,9 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts)
|
|||||||
long int yg = y + days / 365 - (days % 365 < 0);
|
long int yg = y + days / 365 - (days % 365 < 0);
|
||||||
|
|
||||||
/* Adjust DAYS and Y to match the guessed year. */
|
/* Adjust DAYS and Y to match the guessed year. */
|
||||||
days -= ((yg - y) * 365 + LEAPS_THRU_END_OF(yg - 1)
|
days -= ((yg - y) * 365
|
||||||
- LEAPS_THRU_END_OF(y - 1));
|
+ LEAPS_THRU_END_OF (yg - 1)
|
||||||
|
- LEAPS_THRU_END_OF (y - 1));
|
||||||
y = yg;
|
y = yg;
|
||||||
}
|
}
|
||||||
dest->year = y;
|
dest->year = y;
|
||||||
@ -158,11 +158,9 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts)
|
|||||||
dest->day = days + 1;
|
dest->day = days + 1;
|
||||||
|
|
||||||
dest->centiseconds = ts.tv_nsec / 10000000;
|
dest->centiseconds = ts.tv_nsec / 10000000;
|
||||||
dest->hundredsOfMicroseconds =
|
dest->hundredsOfMicroseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000) / 100;
|
||||||
(ts.tv_nsec / 1000 - dest->centiseconds * 10000) / 100;
|
dest->microseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000 -
|
||||||
dest->microseconds =
|
dest->hundredsOfMicroseconds * 100);
|
||||||
(ts.tv_nsec / 1000 - dest->centiseconds * 10000 -
|
|
||||||
dest->hundredsOfMicroseconds * 100);
|
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
155
fs/udf/unicode.c
155
fs/udf/unicode.c
@ -29,21 +29,23 @@
|
|||||||
|
|
||||||
static int udf_translate_to_linux(uint8_t *, uint8_t *, int, uint8_t *, int);
|
static int udf_translate_to_linux(uint8_t *, uint8_t *, int, uint8_t *, int);
|
||||||
|
|
||||||
static int udf_char_to_ustr(struct ustr *dest, const uint8_t * src, int strlen)
|
static int udf_char_to_ustr(struct ustr *dest, const uint8_t *src, int strlen)
|
||||||
{
|
{
|
||||||
if ((!dest) || (!src) || (!strlen) || (strlen > UDF_NAME_LEN - 2))
|
if ((!dest) || (!src) || (!strlen) || (strlen > UDF_NAME_LEN - 2))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
memset(dest, 0, sizeof(struct ustr));
|
memset(dest, 0, sizeof(struct ustr));
|
||||||
memcpy(dest->u_name, src, strlen);
|
memcpy(dest->u_name, src, strlen);
|
||||||
dest->u_cmpID = 0x08;
|
dest->u_cmpID = 0x08;
|
||||||
dest->u_len = strlen;
|
dest->u_len = strlen;
|
||||||
|
|
||||||
return strlen;
|
return strlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* udf_build_ustr
|
* udf_build_ustr
|
||||||
*/
|
*/
|
||||||
int udf_build_ustr(struct ustr *dest, dstring * ptr, int size)
|
int udf_build_ustr(struct ustr *dest, dstring *ptr, int size)
|
||||||
{
|
{
|
||||||
int usesize;
|
int usesize;
|
||||||
|
|
||||||
@ -55,13 +57,14 @@ int udf_build_ustr(struct ustr *dest, dstring * ptr, int size)
|
|||||||
dest->u_cmpID = ptr[0];
|
dest->u_cmpID = ptr[0];
|
||||||
dest->u_len = ptr[size - 1];
|
dest->u_len = ptr[size - 1];
|
||||||
memcpy(dest->u_name, ptr + 1, usesize - 1);
|
memcpy(dest->u_name, ptr + 1, usesize - 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* udf_build_ustr_exact
|
* udf_build_ustr_exact
|
||||||
*/
|
*/
|
||||||
static int udf_build_ustr_exact(struct ustr *dest, dstring * ptr, int exactsize)
|
static int udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int exactsize)
|
||||||
{
|
{
|
||||||
if ((!dest) || (!ptr) || (!exactsize))
|
if ((!dest) || (!ptr) || (!exactsize))
|
||||||
return -1;
|
return -1;
|
||||||
@ -70,6 +73,7 @@ static int udf_build_ustr_exact(struct ustr *dest, dstring * ptr, int exactsize)
|
|||||||
dest->u_cmpID = ptr[0];
|
dest->u_cmpID = ptr[0];
|
||||||
dest->u_len = exactsize - 1;
|
dest->u_len = exactsize - 1;
|
||||||
memcpy(dest->u_name, ptr + 1, exactsize - 1);
|
memcpy(dest->u_name, ptr + 1, exactsize - 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,20 +133,15 @@ int udf_CS0toUTF8(struct ustr *utf_o, struct ustr *ocu_i)
|
|||||||
c = (c << 8) | ocu[i++];
|
c = (c << 8) | ocu[i++];
|
||||||
|
|
||||||
/* Compress Unicode to UTF-8 */
|
/* Compress Unicode to UTF-8 */
|
||||||
if (c < 0x80U)
|
if (c < 0x80U) {
|
||||||
utf_o->u_name[utf_o->u_len++] = (uint8_t) c;
|
utf_o->u_name[utf_o->u_len++] = (uint8_t)c;
|
||||||
else if (c < 0x800U) {
|
} else if (c < 0x800U) {
|
||||||
utf_o->u_name[utf_o->u_len++] =
|
utf_o->u_name[utf_o->u_len++] = (uint8_t)(0xc0 | (c >> 6));
|
||||||
(uint8_t) (0xc0 | (c >> 6));
|
utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | (c & 0x3f));
|
||||||
utf_o->u_name[utf_o->u_len++] =
|
|
||||||
(uint8_t) (0x80 | (c & 0x3f));
|
|
||||||
} else {
|
} else {
|
||||||
utf_o->u_name[utf_o->u_len++] =
|
utf_o->u_name[utf_o->u_len++] = (uint8_t)(0xe0 | (c >> 12));
|
||||||
(uint8_t) (0xe0 | (c >> 12));
|
utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | ((c >> 6) & 0x3f));
|
||||||
utf_o->u_name[utf_o->u_len++] =
|
utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | (c & 0x3f));
|
||||||
(uint8_t) (0x80 | ((c >> 6) & 0x3f));
|
|
||||||
utf_o->u_name[utf_o->u_len++] =
|
|
||||||
(uint8_t) (0x80 | (c & 0x3f));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
utf_o->u_cmpID = 8;
|
utf_o->u_cmpID = 8;
|
||||||
@ -173,7 +172,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, struct ustr *ocu_i)
|
|||||||
* November 12, 1997 - Andrew E. Mileski
|
* November 12, 1997 - Andrew E. Mileski
|
||||||
* Written, tested, and released.
|
* Written, tested, and released.
|
||||||
*/
|
*/
|
||||||
static int udf_UTF8toCS0(dstring * ocu, struct ustr *utf, int length)
|
static int udf_UTF8toCS0(dstring *ocu, struct ustr *utf, int length)
|
||||||
{
|
{
|
||||||
unsigned c, i, max_val, utf_char;
|
unsigned c, i, max_val, utf_char;
|
||||||
int utf_cnt, u_len;
|
int utf_cnt, u_len;
|
||||||
@ -182,12 +181,12 @@ static int udf_UTF8toCS0(dstring * ocu, struct ustr *utf, int length)
|
|||||||
ocu[0] = 8;
|
ocu[0] = 8;
|
||||||
max_val = 0xffU;
|
max_val = 0xffU;
|
||||||
|
|
||||||
try_again:
|
try_again:
|
||||||
u_len = 0U;
|
u_len = 0U;
|
||||||
utf_char = 0U;
|
utf_char = 0U;
|
||||||
utf_cnt = 0U;
|
utf_cnt = 0U;
|
||||||
for (i = 0U; i < utf->u_len; i++) {
|
for (i = 0U; i < utf->u_len; i++) {
|
||||||
c = (uint8_t) utf->u_name[i];
|
c = (uint8_t)utf->u_name[i];
|
||||||
|
|
||||||
/* Complete a multi-byte UTF-8 character */
|
/* Complete a multi-byte UTF-8 character */
|
||||||
if (utf_cnt) {
|
if (utf_cnt) {
|
||||||
@ -213,37 +212,40 @@ static int udf_UTF8toCS0(dstring * ocu, struct ustr *utf, int length)
|
|||||||
} else if ((c & 0xfeU) == 0xfcU) {
|
} else if ((c & 0xfeU) == 0xfcU) {
|
||||||
utf_char = c & 0x01U;
|
utf_char = c & 0x01U;
|
||||||
utf_cnt = 5;
|
utf_cnt = 5;
|
||||||
} else
|
} else {
|
||||||
goto error_out;
|
goto error_out;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
} else
|
} else {
|
||||||
/* Single byte UTF-8 character (most common) */
|
/* Single byte UTF-8 character (most common) */
|
||||||
utf_char = c;
|
utf_char = c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Choose no compression if necessary */
|
/* Choose no compression if necessary */
|
||||||
if (utf_char > max_val) {
|
if (utf_char > max_val) {
|
||||||
if (0xffU == max_val) {
|
if (max_val == 0xffU) {
|
||||||
max_val = 0xffffU;
|
max_val = 0xffffU;
|
||||||
ocu[0] = (uint8_t) 0x10U;
|
ocu[0] = (uint8_t)0x10U;
|
||||||
goto try_again;
|
goto try_again;
|
||||||
}
|
}
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max_val == 0xffffU) {
|
if (max_val == 0xffffU) {
|
||||||
ocu[++u_len] = (uint8_t) (utf_char >> 8);
|
ocu[++u_len] = (uint8_t)(utf_char >> 8);
|
||||||
}
|
}
|
||||||
ocu[++u_len] = (uint8_t) (utf_char & 0xffU);
|
ocu[++u_len] = (uint8_t)(utf_char & 0xffU);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utf_cnt) {
|
if (utf_cnt) {
|
||||||
error_out:
|
error_out:
|
||||||
ocu[++u_len] = '?';
|
ocu[++u_len] = '?';
|
||||||
printk(KERN_DEBUG "udf: bad UTF-8 character\n");
|
printk(KERN_DEBUG "udf: bad UTF-8 character\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
ocu[length - 1] = (uint8_t) u_len + 1;
|
ocu[length - 1] = (uint8_t)u_len + 1;
|
||||||
|
|
||||||
return u_len + 1;
|
return u_len + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,7 +290,7 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
|
|||||||
return utf_o->u_len;
|
return utf_o->u_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int udf_NLStoCS0(struct nls_table *nls, dstring * ocu, struct ustr *uni,
|
static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni,
|
||||||
int length)
|
int length)
|
||||||
{
|
{
|
||||||
unsigned len, i, max_val;
|
unsigned len, i, max_val;
|
||||||
@ -299,7 +301,7 @@ static int udf_NLStoCS0(struct nls_table *nls, dstring * ocu, struct ustr *uni,
|
|||||||
ocu[0] = 8;
|
ocu[0] = 8;
|
||||||
max_val = 0xffU;
|
max_val = 0xffU;
|
||||||
|
|
||||||
try_again:
|
try_again:
|
||||||
u_len = 0U;
|
u_len = 0U;
|
||||||
for (i = 0U; i < uni->u_len; i++) {
|
for (i = 0U; i < uni->u_len; i++) {
|
||||||
len = nls->char2uni(&uni->u_name[i], uni->u_len - i, &uni_char);
|
len = nls->char2uni(&uni->u_name[i], uni->u_len - i, &uni_char);
|
||||||
@ -308,21 +310,21 @@ static int udf_NLStoCS0(struct nls_table *nls, dstring * ocu, struct ustr *uni,
|
|||||||
|
|
||||||
if (uni_char > max_val) {
|
if (uni_char > max_val) {
|
||||||
max_val = 0xffffU;
|
max_val = 0xffffU;
|
||||||
ocu[0] = (uint8_t) 0x10U;
|
ocu[0] = (uint8_t)0x10U;
|
||||||
goto try_again;
|
goto try_again;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max_val == 0xffffU)
|
if (max_val == 0xffffU)
|
||||||
ocu[++u_len] = (uint8_t) (uni_char >> 8);
|
ocu[++u_len] = (uint8_t)(uni_char >> 8);
|
||||||
ocu[++u_len] = (uint8_t) (uni_char & 0xffU);
|
ocu[++u_len] = (uint8_t)(uni_char & 0xffU);
|
||||||
i += len - 1;
|
i += len - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ocu[length - 1] = (uint8_t) u_len + 1;
|
ocu[length - 1] = (uint8_t)u_len + 1;
|
||||||
return u_len + 1;
|
return u_len + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int udf_get_filename(struct super_block *sb, uint8_t * sname, uint8_t * dname,
|
int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname,
|
||||||
int flen)
|
int flen)
|
||||||
{
|
{
|
||||||
struct ustr filename, unifilename;
|
struct ustr filename, unifilename;
|
||||||
@ -334,30 +336,29 @@ int udf_get_filename(struct super_block *sb, uint8_t * sname, uint8_t * dname,
|
|||||||
|
|
||||||
if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
|
if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
|
||||||
if (!udf_CS0toUTF8(&filename, &unifilename)) {
|
if (!udf_CS0toUTF8(&filename, &unifilename)) {
|
||||||
udf_debug("Failed in udf_get_filename: sname = %s\n",
|
udf_debug("Failed in udf_get_filename: sname = %s\n", sname);
|
||||||
sname);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
|
} else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
|
||||||
if (!udf_CS0toNLS
|
if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, &filename, &unifilename)) {
|
||||||
(UDF_SB(sb)->s_nls_map, &filename, &unifilename)) {
|
udf_debug("Failed in udf_get_filename: sname = %s\n", sname);
|
||||||
udf_debug("Failed in udf_get_filename: sname = %s\n",
|
|
||||||
sname);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ((len =
|
len = udf_translate_to_linux(dname, filename.u_name, filename.u_len,
|
||||||
udf_translate_to_linux(dname, filename.u_name, filename.u_len,
|
unifilename.u_name, unifilename.u_len);
|
||||||
unifilename.u_name, unifilename.u_len))) {
|
if (len) {
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int udf_put_filename(struct super_block *sb, const uint8_t * sname,
|
int udf_put_filename(struct super_block *sb, const uint8_t *sname,
|
||||||
uint8_t * dname, int flen)
|
uint8_t *dname, int flen)
|
||||||
{
|
{
|
||||||
struct ustr unifilename;
|
struct ustr unifilename;
|
||||||
int namelen;
|
int namelen;
|
||||||
@ -367,31 +368,29 @@ int udf_put_filename(struct super_block *sb, const uint8_t * sname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
|
if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
|
||||||
if (!
|
namelen = udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN);
|
||||||
(namelen =
|
if (!namelen) {
|
||||||
udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN))) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
|
} else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
|
||||||
if (!
|
namelen = udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname, &unifilename, UDF_NAME_LEN);
|
||||||
(namelen =
|
if (!namelen) {
|
||||||
udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname, &unifilename,
|
|
||||||
UDF_NAME_LEN))) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return namelen;
|
return namelen;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ILLEGAL_CHAR_MARK '_'
|
#define ILLEGAL_CHAR_MARK '_'
|
||||||
#define EXT_MARK '.'
|
#define EXT_MARK '.'
|
||||||
#define CRC_MARK '#'
|
#define CRC_MARK '#'
|
||||||
#define EXT_SIZE 5
|
#define EXT_SIZE 5
|
||||||
|
|
||||||
static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName,
|
static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen,
|
||||||
int udfLen, uint8_t * fidName, int fidNameLen)
|
uint8_t *fidName, int fidNameLen)
|
||||||
{
|
{
|
||||||
int index, newIndex = 0, needsCRC = 0;
|
int index, newIndex = 0, needsCRC = 0;
|
||||||
int extIndex = 0, newExtIndex = 0, hasExt = 0;
|
int extIndex = 0, newExtIndex = 0, hasExt = 0;
|
||||||
@ -399,8 +398,8 @@ static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName,
|
|||||||
uint8_t curr;
|
uint8_t curr;
|
||||||
const uint8_t hexChar[] = "0123456789ABCDEF";
|
const uint8_t hexChar[] = "0123456789ABCDEF";
|
||||||
|
|
||||||
if (udfName[0] == '.' && (udfLen == 1 ||
|
if (udfName[0] == '.' &&
|
||||||
(udfLen == 2 && udfName[1] == '.'))) {
|
(udfLen == 1 || (udfLen == 2 && udfName[1] == '.'))) {
|
||||||
needsCRC = 1;
|
needsCRC = 1;
|
||||||
newIndex = udfLen;
|
newIndex = udfLen;
|
||||||
memcpy(newName, udfName, udfLen);
|
memcpy(newName, udfName, udfLen);
|
||||||
@ -410,16 +409,13 @@ static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName,
|
|||||||
if (curr == '/' || curr == 0) {
|
if (curr == '/' || curr == 0) {
|
||||||
needsCRC = 1;
|
needsCRC = 1;
|
||||||
curr = ILLEGAL_CHAR_MARK;
|
curr = ILLEGAL_CHAR_MARK;
|
||||||
while (index + 1 < udfLen
|
while (index + 1 < udfLen && (udfName[index + 1] == '/' ||
|
||||||
&& (udfName[index + 1] == '/'
|
udfName[index + 1] == 0))
|
||||||
|| udfName[index + 1] == 0))
|
|
||||||
index++;
|
index++;
|
||||||
}
|
} if (curr == EXT_MARK && (udfLen - index - 1) <= EXT_SIZE) {
|
||||||
if (curr == EXT_MARK
|
if (udfLen == index + 1) {
|
||||||
&& (udfLen - index - 1) <= EXT_SIZE) {
|
|
||||||
if (udfLen == index + 1)
|
|
||||||
hasExt = 0;
|
hasExt = 0;
|
||||||
else {
|
} else {
|
||||||
hasExt = 1;
|
hasExt = 1;
|
||||||
extIndex = index;
|
extIndex = index;
|
||||||
newExtIndex = newIndex;
|
newExtIndex = newIndex;
|
||||||
@ -437,23 +433,16 @@ static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName,
|
|||||||
|
|
||||||
if (hasExt) {
|
if (hasExt) {
|
||||||
int maxFilenameLen;
|
int maxFilenameLen;
|
||||||
for (index = 0;
|
for(index = 0; index < EXT_SIZE && extIndex + index + 1 < udfLen; index++) {
|
||||||
index < EXT_SIZE && extIndex + index + 1 < udfLen;
|
|
||||||
index++) {
|
|
||||||
curr = udfName[extIndex + index + 1];
|
curr = udfName[extIndex + index + 1];
|
||||||
|
|
||||||
if (curr == '/' || curr == 0) {
|
if (curr == '/' || curr == 0) {
|
||||||
needsCRC = 1;
|
needsCRC = 1;
|
||||||
curr = ILLEGAL_CHAR_MARK;
|
curr = ILLEGAL_CHAR_MARK;
|
||||||
while (extIndex + index + 2 < udfLen
|
while(extIndex + index + 2 < udfLen &&
|
||||||
&& (index + 1 < EXT_SIZE
|
(index + 1 < EXT_SIZE
|
||||||
&&
|
&& (udfName[extIndex + index + 2] == '/' ||
|
||||||
(udfName
|
udfName[extIndex + index + 2] == 0)))
|
||||||
[extIndex + index + 2] ==
|
|
||||||
'/'
|
|
||||||
|| udfName[extIndex +
|
|
||||||
index + 2] ==
|
|
||||||
0)))
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
ext[localExtIndex++] = curr;
|
ext[localExtIndex++] = curr;
|
||||||
@ -463,8 +452,9 @@ static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName,
|
|||||||
newIndex = maxFilenameLen;
|
newIndex = maxFilenameLen;
|
||||||
else
|
else
|
||||||
newIndex = newExtIndex;
|
newIndex = newExtIndex;
|
||||||
} else if (newIndex > 250)
|
} else if (newIndex > 250) {
|
||||||
newIndex = 250;
|
newIndex = 250;
|
||||||
|
}
|
||||||
newName[newIndex++] = CRC_MARK;
|
newName[newIndex++] = CRC_MARK;
|
||||||
valueCRC = udf_crc(fidName, fidNameLen, 0);
|
valueCRC = udf_crc(fidName, fidNameLen, 0);
|
||||||
newName[newIndex++] = hexChar[(valueCRC & 0xf000) >> 12];
|
newName[newIndex++] = hexChar[(valueCRC & 0xf000) >> 12];
|
||||||
@ -478,5 +468,6 @@ static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName,
|
|||||||
newName[newIndex++] = ext[index];
|
newName[newIndex++] = ext[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return newIndex;
|
return newIndex;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user