UDF: coding style conversion - lindent

This patch converts UDF coding style to kernel coding style using 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:
Cyrill Gorcunov 2007-07-19 01:47:43 -07:00 committed by Linus Torvalds
parent 95a631e2d9
commit cb00ea3528
23 changed files with 3789 additions and 3637 deletions

View file

@ -51,8 +51,7 @@ static inline int find_next_one_bit (void * addr, int size, int offset)
return size; return size;
size -= result; size -= result;
offset &= (BITS_PER_LONG - 1); offset &= (BITS_PER_LONG - 1);
if (offset) if (offset) {
{
tmp = leBPL_to_cpup(p++); tmp = leBPL_to_cpup(p++);
tmp &= ~0UL << offset; tmp &= ~0UL << offset;
if (size < BITS_PER_LONG) if (size < BITS_PER_LONG)
@ -62,8 +61,7 @@ static inline int find_next_one_bit (void * addr, int size, int offset)
size -= BITS_PER_LONG; size -= BITS_PER_LONG;
result += BITS_PER_LONG; result += BITS_PER_LONG;
} }
while (size & ~(BITS_PER_LONG-1)) while (size & ~(BITS_PER_LONG - 1)) {
{
if ((tmp = leBPL_to_cpup(p++))) if ((tmp = leBPL_to_cpup(p++)))
goto found_middle; goto found_middle;
result += BITS_PER_LONG; result += BITS_PER_LONG;
@ -82,7 +80,8 @@ found_middle:
find_next_one_bit((addr), (size), 0) find_next_one_bit((addr), (size), 0)
static int read_block_bitmap(struct super_block *sb, static int read_block_bitmap(struct super_block *sb,
struct udf_bitmap *bitmap, unsigned int block, unsigned long bitmap_nr) struct udf_bitmap *bitmap, unsigned int block,
unsigned long bitmap_nr)
{ {
struct buffer_head *bh = NULL; struct buffer_head *bh = NULL;
int retval = 0; int retval = 0;
@ -92,8 +91,7 @@ static int read_block_bitmap(struct super_block * sb,
loc.partitionReferenceNum = UDF_SB_PARTITION(sb); loc.partitionReferenceNum = UDF_SB_PARTITION(sb);
bh = udf_tread(sb, udf_get_lb_pblock(sb, loc, block)); bh = udf_tread(sb, udf_get_lb_pblock(sb, loc, block));
if (!bh) if (!bh) {
{
retval = -EIO; retval = -EIO;
} }
bitmap->s_block_bitmap[bitmap_nr] = bh; bitmap->s_block_bitmap[bitmap_nr] = bh;
@ -101,21 +99,22 @@ static int read_block_bitmap(struct super_block * sb,
} }
static int __load_block_bitmap(struct super_block *sb, static int __load_block_bitmap(struct super_block *sb,
struct udf_bitmap *bitmap, unsigned int block_group) struct udf_bitmap *bitmap,
unsigned int block_group)
{ {
int retval = 0; int retval = 0;
int nr_groups = bitmap->s_nr_groups; int nr_groups = bitmap->s_nr_groups;
if (block_group >= nr_groups) if (block_group >= nr_groups) {
{ udf_debug("block_group (%d) > nr_groups (%d)\n", block_group,
udf_debug("block_group (%d) > nr_groups (%d)\n", block_group, 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, block_group); read_block_bitmap(sb, bitmap, block_group, block_group);
if (retval < 0) if (retval < 0)
return retval; return retval;
return block_group; return block_group;
@ -123,7 +122,8 @@ static int __load_block_bitmap(struct super_block * sb,
} }
static inline int load_block_bitmap(struct super_block *sb, static inline int load_block_bitmap(struct super_block *sb,
struct udf_bitmap *bitmap, unsigned int block_group) struct udf_bitmap *bitmap,
unsigned int block_group)
{ {
int slot; int slot;
@ -141,7 +141,8 @@ static inline int load_block_bitmap(struct super_block * sb,
static void udf_bitmap_free_blocks(struct super_block *sb, static void udf_bitmap_free_blocks(struct super_block *sb,
struct inode *inode, struct inode *inode,
struct udf_bitmap *bitmap, struct udf_bitmap *bitmap,
kernel_lb_addr bloc, uint32_t offset, uint32_t count) kernel_lb_addr bloc, uint32_t offset,
uint32_t count)
{ {
struct udf_sb_info *sbi = UDF_SB(sb); struct udf_sb_info *sbi = UDF_SB(sb);
struct buffer_head *bh = NULL; struct buffer_head *bh = NULL;
@ -154,15 +155,20 @@ 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.partitionReferenceNum)) (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb,
bloc.
partitionReferenceNum))
{ {
udf_debug("%d < %d || %d + %d > %d\n", udf_debug("%d < %d || %d + %d > %d\n", bloc.logicalBlockNum, 0,
bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, bloc.logicalBlockNum, count, UDF_SB_PARTLEN(sb,
UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)); bloc.
partitionReferenceNum));
goto error_return; goto error_return;
} }
block = bloc.logicalBlockNum + offset + (sizeof(struct spaceBitmapDesc) << 3); block =
bloc.logicalBlockNum + offset +
(sizeof(struct spaceBitmapDesc) << 3);
do_more: do_more:
overflow = 0; overflow = 0;
@ -172,8 +178,7 @@ do_more:
/* /*
* Check to see if we are freeing blocks across a group boundary. * Check to see if we are freeing blocks across a group boundary.
*/ */
if (bit + count > (sb->s_blocksize << 3)) if (bit + count > (sb->s_blocksize << 3)) {
{
overflow = bit + count - (sb->s_blocksize << 3); overflow = bit + count - (sb->s_blocksize << 3);
count -= overflow; count -= overflow;
} }
@ -182,27 +187,26 @@ do_more:
goto error_return; goto error_return;
bh = bitmap->s_block_bitmap[bitmap_nr]; bh = bitmap->s_block_bitmap[bitmap_nr];
for (i=0; i < count; i++) for (i = 0; i < count; i++) {
{ if (udf_set_bit(bit + i, bh->b_data)) {
if (udf_set_bit(bit + i, bh->b_data))
{
udf_debug("bit %ld already set\n", bit + i); udf_debug("bit %ld already set\n", bit + i);
udf_debug("byte=%2x\n", ((char *)bh->b_data)[(bit + i) >> 3]); udf_debug("byte=%2x\n",
} ((char *)bh->b_data)[(bit + i) >> 3]);
else } else {
{
if (inode) if (inode)
DQUOT_FREE_BLOCK(inode, 1); DQUOT_FREE_BLOCK(inode, 1);
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);
} }
} }
} }
mark_buffer_dirty(bh); mark_buffer_dirty(bh);
if (overflow) if (overflow) {
{
block += count; block += count;
count = overflow; count = overflow;
goto do_more; goto do_more;
@ -217,7 +221,8 @@ error_return:
static int udf_bitmap_prealloc_blocks(struct super_block *sb, static int udf_bitmap_prealloc_blocks(struct super_block *sb,
struct inode *inode, struct inode *inode,
struct udf_bitmap *bitmap, uint16_t partition, uint32_t first_block, struct udf_bitmap *bitmap,
uint16_t partition, uint32_t first_block,
uint32_t block_count) uint32_t block_count)
{ {
struct udf_sb_info *sbi = UDF_SB(sb); struct udf_sb_info *sbi = UDF_SB(sb);
@ -235,7 +240,8 @@ static int udf_bitmap_prealloc_blocks(struct super_block * sb,
repeat: repeat:
nr_groups = (UDF_SB_PARTLEN(sb, partition) + nr_groups = (UDF_SB_PARTLEN(sb, partition) +
(sizeof(struct spaceBitmapDesc) << 3) + (sb->s_blocksize * 8) - 1) / (sb->s_blocksize * 8); (sizeof(struct spaceBitmapDesc) << 3) +
(sb->s_blocksize * 8) - 1) / (sb->s_blocksize * 8);
block = first_block + (sizeof(struct spaceBitmapDesc) << 3); block = first_block + (sizeof(struct spaceBitmapDesc) << 3);
block_group = block >> (sb->s_blocksize_bits + 3); block_group = block >> (sb->s_blocksize_bits + 3);
group_start = block_group ? 0 : sizeof(struct spaceBitmapDesc); group_start = block_group ? 0 : sizeof(struct spaceBitmapDesc);
@ -247,14 +253,12 @@ repeat:
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;
@ -268,10 +272,11 @@ repeat:
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(UDF_SB_LVID(sb)->freeSpaceTable[partition])-alloc_count); cpu_to_le32(le32_to_cpu
(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;
@ -281,7 +286,8 @@ out:
static int udf_bitmap_new_block(struct super_block *sb, static int udf_bitmap_new_block(struct super_block *sb,
struct inode *inode, struct inode *inode,
struct udf_bitmap *bitmap, uint16_t partition, uint32_t goal, int *err) struct udf_bitmap *bitmap, uint16_t partition,
uint32_t goal, int *err)
{ {
struct udf_sb_info *sbi = UDF_SB(sb); struct udf_sb_info *sbi = UDF_SB(sb);
int newbit, bit = 0, block, block_group, group_start; int newbit, bit = 0, block, block_group, group_start;
@ -306,37 +312,38 @@ repeat:
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 = memscan((char *)bh->b_data + group_start, 0xFF, sb->s_blocksize - group_start); ptr =
memscan((char *)bh->b_data + group_start, 0xFF,
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, sb->s_blocksize - ((bit + 7) >> 3)); ptr =
memscan((char *)bh->b_data + (bit >> 3), 0xFF,
sb->s_blocksize - ((bit + 7) >> 3));
newbit = (ptr - ((char *)bh->b_data)) << 3; newbit = (ptr - ((char *)bh->b_data)) << 3;
if (newbit < sb->s_blocksize << 3) if (newbit < sb->s_blocksize << 3) {
{
bit = newbit; bit = newbit;
goto search_back; goto search_back;
} }
newbit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, bit); newbit =
if (newbit < sb->s_blocksize << 3) udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3,
{ bit);
if (newbit < sb->s_blocksize << 3) {
bit = newbit; bit = newbit;
goto got_block; goto got_block;
} }
} }
for (i=0; i<(nr_groups*2); i++) for (i = 0; i < (nr_groups * 2); i++) {
{
block_group++; block_group++;
if (block_group >= nr_groups) if (block_group >= nr_groups)
block_group = 0; block_group = 0;
@ -346,47 +353,49 @@ repeat:
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];
if (i < nr_groups) if (i < nr_groups) {
{ ptr =
ptr = memscan((char *)bh->b_data + group_start, 0xFF, sb->s_blocksize - group_start); memscan((char *)bh->b_data + group_start, 0xFF,
if ((ptr - ((char *)bh->b_data)) < sb->s_blocksize) sb->s_blocksize - group_start);
{ 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 =
{ udf_find_next_one_bit((char *)bh->b_data,
bit = udf_find_next_one_bit((char *)bh->b_data, sb->s_blocksize << 3, group_start << 3); sb->s_blocksize << 3,
group_start << 3);
if (bit < sb->s_blocksize << 3) if (bit < sb->s_blocksize << 3)
break; break;
} }
} }
if (i >= (nr_groups*2)) if (i >= (nr_groups * 2)) {
{
mutex_unlock(&sbi->s_alloc_mutex); mutex_unlock(&sbi->s_alloc_mutex);
return newblock; return newblock;
} }
if (bit < sb->s_blocksize << 3) if (bit < sb->s_blocksize << 3)
goto search_back; goto search_back;
else else
bit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, group_start << 3); bit =
if (bit >= sb->s_blocksize << 3) udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3,
{ group_start << 3);
if (bit >= sb->s_blocksize << 3) {
mutex_unlock(&sbi->s_alloc_mutex); mutex_unlock(&sbi->s_alloc_mutex);
return 0; return 0;
} }
search_back: search_back:
for (i=0; i<7 && bit > (group_start << 3) && udf_test_bit(bit - 1, bh->b_data); i++, bit--); for (i = 0;
i < 7 && bit > (group_start << 3)
&& 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.
*/ */
if (inode && DQUOT_ALLOC_BLOCK(inode, 1)) if (inode && DQUOT_ALLOC_BLOCK(inode, 1)) {
{
mutex_unlock(&sbi->s_alloc_mutex); mutex_unlock(&sbi->s_alloc_mutex);
*err = -EDQUOT; *err = -EDQUOT;
return 0; return 0;
@ -395,18 +404,18 @@ got_block:
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);
goto repeat; goto repeat;
} }
mark_buffer_dirty(bh); mark_buffer_dirty(bh);
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(UDF_SB_LVID(sb)->freeSpaceTable[partition])-1); cpu_to_le32(le32_to_cpu
(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 +432,8 @@ error_return:
static void udf_table_free_blocks(struct super_block *sb, static void udf_table_free_blocks(struct super_block *sb,
struct inode *inode, struct inode *inode,
struct inode *table, struct inode *table,
kernel_lb_addr bloc, uint32_t offset, uint32_t count) kernel_lb_addr bloc, uint32_t offset,
uint32_t count)
{ {
struct udf_sb_info *sbi = UDF_SB(sb); struct udf_sb_info *sbi = UDF_SB(sb);
uint32_t start, end; uint32_t start, end;
@ -435,11 +445,14 @@ 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.partitionReferenceNum)) (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb,
bloc.
partitionReferenceNum))
{ {
udf_debug("%d < %d || %d + %d > %d\n", udf_debug("%d < %d || %d + %d > %d\n", bloc.logicalBlockNum, 0,
bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, bloc.logicalBlockNum, count, UDF_SB_PARTLEN(sb,
UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)); bloc.
partitionReferenceNum));
goto error_return; goto error_return;
} }
@ -447,10 +460,11 @@ static void udf_table_free_blocks(struct super_block * sb,
but.. oh well */ but.. oh well */
if (inode) if (inode)
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(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)])+count); cpu_to_le32(le32_to_cpu
(UDF_SB_LVID(sb)->
freeSpaceTable[UDF_SB_PARTITION(sb)]) + count);
mark_buffer_dirty(UDF_SB_LVIDBH(sb)); mark_buffer_dirty(UDF_SB_LVIDBH(sb));
} }
@ -463,38 +477,43 @@ static void udf_table_free_blocks(struct super_block * sb,
epos.bh = oepos.bh = NULL; epos.bh = oepos.bh = NULL;
while (count && (etype = while (count && (etype =
udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) 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) <
if ((0x3FFFFFFF - elen) < (count << sb->s_blocksize_bits)) (count << sb->s_blocksize_bits)) {
{ count -=
count -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits); ((0x3FFFFFFF -
start += ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits); elen) >> sb->s_blocksize_bits);
elen = (etype << 30) | (0x40000000 - sb->s_blocksize); start +=
} ((0x3FFFFFFF -
else elen) >> sb->s_blocksize_bits);
{ elen =
(etype << 30) | (0x40000000 -
sb->s_blocksize);
} 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) <
{ (count << sb->s_blocksize_bits)) {
if ((0x3FFFFFFF - elen) < (count << sb->s_blocksize_bits)) count -=
{ ((0x3FFFFFFF -
count -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits); elen) >> sb->s_blocksize_bits);
end -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits); end -=
((0x3FFFFFFF -
elen) >> sb->s_blocksize_bits);
eloc.logicalBlockNum -= eloc.logicalBlockNum -=
((0x3FFFFFFF - elen) >> sb->s_blocksize_bits); ((0x3FFFFFFF -
elen = (etype << 30) | (0x40000000 - sb->s_blocksize); elen) >> sb->s_blocksize_bits);
} elen =
else (etype << 30) | (0x40000000 -
{ sb->s_blocksize);
} 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));
@ -504,21 +523,18 @@ static void udf_table_free_blocks(struct super_block * sb,
udf_write_aext(table, &oepos, eloc, elen, 1); udf_write_aext(table, &oepos, eloc, elen, 1);
} }
if (epos.bh != oepos.bh) if (epos.bh != oepos.bh) {
{
i = -1; i = -1;
oepos.block = epos.block; oepos.block = epos.block;
brelse(oepos.bh); brelse(oepos.bh);
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 /* 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 a new block, and since we hold the super block lock already
very bad things would happen :) very bad things would happen :)
@ -537,22 +553,19 @@ 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 | elen = EXT_RECORDED_ALLOCATED | (count << sb->s_blocksize_bits);
(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;
} }
if (epos.offset + (2 * adsize) > sb->s_blocksize) if (epos.offset + (2 * adsize) > sb->s_blocksize) {
{
char *sptr, *dptr; char *sptr, *dptr;
int loffset; int loffset;
@ -565,93 +578,99 @@ static void udf_table_free_blocks(struct super_block * sb,
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 = cpu_to_le32(oepos.block.logicalBlockNum); aed->previousAllocExtLocation =
if (epos.offset + adsize > sb->s_blocksize) cpu_to_le32(oepos.block.logicalBlockNum);
{ 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 = epos.bh->b_data + sizeof(struct allocExtDesc); dptr =
epos.bh->b_data +
sizeof(struct allocExtDesc);
memcpy(dptr, sptr, adsize); memcpy(dptr, sptr, adsize);
epos.offset = sizeof(struct allocExtDesc) + adsize; epos.offset =
} sizeof(struct allocExtDesc) + adsize;
else } else {
{
loffset = epos.offset + adsize; loffset = epos.offset + adsize;
aed->lengthAllocDescs = cpu_to_le32(0); aed->lengthAllocDescs = cpu_to_le32(0);
sptr = oepos.bh->b_data + epos.offset; sptr = oepos.bh->b_data + epos.offset;
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(aed->lengthAllocDescs) + adsize); cpu_to_le32(le32_to_cpu
} (aed->
else lengthAllocDescs) +
{ adsize);
} 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, 1, udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 3,
epos.block.logicalBlockNum, sizeof(tag)); 1, epos.block.logicalBlockNum,
sizeof(tag));
else else
udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 2, 1, udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 2,
epos.block.logicalBlockNum, sizeof(tag)); 1, epos.block.logicalBlockNum,
switch (UDF_I_ALLOCTYPE(table)) sizeof(tag));
{ 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 = (long_ad *) sptr;
lad->extLength = cpu_to_le32( lad->extLength =
EXT_NEXT_EXTENT_ALLOCDECS | cpu_to_le32
sb->s_blocksize); (EXT_NEXT_EXTENT_ALLOCDECS | sb->
lad->extLocation = cpu_to_lelb(epos.block); 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) {
{
UDF_I_LENALLOC(table) += adsize; UDF_I_LENALLOC(table) += adsize;
mark_inode_dirty(table); mark_inode_dirty(table);
} } else {
else
{
aed = (struct allocExtDesc *)epos.bh->b_data; aed = (struct allocExtDesc *)epos.bh->b_data;
aed->lengthAllocDescs = aed->lengthAllocDescs =
cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); cpu_to_le32(le32_to_cpu
(aed->lengthAllocDescs) +
adsize);
udf_update_tag(epos.bh->b_data, epos.offset); udf_update_tag(epos.bh->b_data, epos.offset);
mark_buffer_dirty(epos.bh); mark_buffer_dirty(epos.bh);
} }
@ -669,8 +688,8 @@ error_return:
static int udf_table_prealloc_blocks(struct super_block *sb, static int udf_table_prealloc_blocks(struct super_block *sb,
struct inode *inode, struct inode *inode,
struct inode *table, uint16_t partition, uint32_t first_block, struct inode *table, uint16_t partition,
uint32_t block_count) uint32_t first_block, uint32_t block_count)
{ {
struct udf_sb_info *sbi = UDF_SB(sb); struct udf_sb_info *sbi = UDF_SB(sb);
int alloc_count = 0; int alloc_count = 0;
@ -696,39 +715,46 @@ static int udf_table_prealloc_blocks(struct super_block * sb,
eloc.logicalBlockNum = 0xFFFFFFFF; eloc.logicalBlockNum = 0xFFFFFFFF;
while (first_block != eloc.logicalBlockNum && (etype = while (first_block != eloc.logicalBlockNum && (etype =
udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) udf_next_aext(table,
{ &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 && DQUOT_PREALLOC_BLOCK(inode, alloc_count > block_count ? block_count : alloc_count)) if (inode
&& DQUOT_PREALLOC_BLOCK(inode,
alloc_count >
block_count ? block_count :
alloc_count))
alloc_count = 0; alloc_count = 0;
else if (alloc_count > block_count) else if (alloc_count > block_count) {
{
alloc_count = block_count; alloc_count = block_count;
eloc.logicalBlockNum += alloc_count; eloc.logicalBlockNum += alloc_count;
elen -= (alloc_count << sb->s_blocksize_bits); elen -= (alloc_count << sb->s_blocksize_bits);
udf_write_aext(table, &epos, eloc, (etype << 30) | elen, 1); udf_write_aext(table, &epos, eloc, (etype << 30) | elen,
} 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(UDF_SB_LVID(sb)->freeSpaceTable[partition])-alloc_count); cpu_to_le32(le32_to_cpu
(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;
} }
@ -738,7 +764,8 @@ static int udf_table_prealloc_blocks(struct super_block * sb,
static int udf_table_new_block(struct super_block *sb, static int udf_table_new_block(struct super_block *sb,
struct inode *inode, struct inode *inode,
struct inode *table, uint16_t partition, uint32_t goal, int *err) struct inode *table, uint16_t partition,
uint32_t goal, int *err)
{ {
struct udf_sb_info *sbi = UDF_SB(sb); struct udf_sb_info *sbi = UDF_SB(sb);
uint32_t spread = 0xFFFFFFFF, nspread = 0xFFFFFFFF; uint32_t spread = 0xFFFFFFFF, nspread = 0xFFFFFFFF;
@ -771,24 +798,21 @@ static int udf_table_new_block(struct super_block * sb,
epos.bh = goal_epos.bh = NULL; epos.bh = goal_epos.bh = NULL;
while (spread && (etype = while (spread && (etype =
udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) {
{ if (goal >= eloc.logicalBlockNum) {
if (goal >= eloc.logicalBlockNum) if (goal <
{ eloc.logicalBlockNum +
if (goal < eloc.logicalBlockNum + (elen >> sb->s_blocksize_bits)) (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;
if (goal_epos.bh != epos.bh) if (goal_epos.bh != epos.bh) {
{
brelse(goal_epos.bh); brelse(goal_epos.bh);
goal_epos.bh = epos.bh; goal_epos.bh = epos.bh;
get_bh(goal_epos.bh); get_bh(goal_epos.bh);
@ -802,8 +826,7 @@ static int udf_table_new_block(struct super_block * sb,
brelse(epos.bh); brelse(epos.bh);
if (spread == 0xFFFFFFFF) if (spread == 0xFFFFFFFF) {
{
brelse(goal_epos.bh); brelse(goal_epos.bh);
mutex_unlock(&sbi->s_alloc_mutex); mutex_unlock(&sbi->s_alloc_mutex);
return 0; return 0;
@ -818,8 +841,7 @@ static int udf_table_new_block(struct super_block * sb,
goal_eloc.logicalBlockNum++; goal_eloc.logicalBlockNum++;
goal_elen -= sb->s_blocksize; goal_elen -= sb->s_blocksize;
if (inode && DQUOT_ALLOC_BLOCK(inode, 1)) if (inode && DQUOT_ALLOC_BLOCK(inode, 1)) {
{
brelse(goal_epos.bh); brelse(goal_epos.bh);
mutex_unlock(&sbi->s_alloc_mutex); mutex_unlock(&sbi->s_alloc_mutex);
*err = -EDQUOT; *err = -EDQUOT;
@ -832,10 +854,11 @@ static int udf_table_new_block(struct super_block * sb,
udf_delete_aext(table, goal_epos, goal_eloc, goal_elen); udf_delete_aext(table, goal_epos, goal_eloc, goal_elen);
brelse(goal_epos.bh); brelse(goal_epos.bh);
if (UDF_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(UDF_SB_LVID(sb)->freeSpaceTable[partition])-1); cpu_to_le32(le32_to_cpu
(UDF_SB_LVID(sb)->freeSpaceTable[partition]) -
1);
mark_buffer_dirty(UDF_SB_LVIDBH(sb)); mark_buffer_dirty(UDF_SB_LVIDBH(sb));
} }
@ -847,67 +870,65 @@ static int udf_table_new_block(struct super_block * sb,
inline void udf_free_blocks(struct super_block *sb, inline void udf_free_blocks(struct super_block *sb,
struct inode *inode, struct inode *inode,
kernel_lb_addr bloc, uint32_t offset, uint32_t count) kernel_lb_addr bloc, uint32_t offset,
uint32_t count)
{ {
uint16_t partition = bloc.partitionReferenceNum; uint16_t partition = bloc.partitionReferenceNum;
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].s_uspace.s_bitmap, UDF_SB_PARTMAPS(sb)[partition].
bloc, offset, count); s_uspace.s_bitmap, bloc, offset,
} 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].s_uspace.s_table, UDF_SB_PARTMAPS(sb)[partition].
bloc, offset, count); s_uspace.s_table, bloc, offset,
} 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].s_fspace.s_bitmap, UDF_SB_PARTMAPS(sb)[partition].
bloc, offset, count); s_fspace.s_bitmap, bloc, offset,
} 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].s_fspace.s_table, UDF_SB_PARTMAPS(sb)[partition].
bloc, offset, count); s_fspace.s_table, bloc, offset,
} count);
else } else
return; return;
} }
inline int udf_prealloc_blocks(struct super_block *sb, inline int udf_prealloc_blocks(struct super_block *sb,
struct inode *inode, struct inode *inode,
uint16_t partition, uint32_t first_block, uint32_t block_count) uint16_t partition, uint32_t first_block,
{ uint32_t block_count)
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)[partition].s_uspace.s_bitmap, UDF_SB_PARTMAPS(sb)
partition, first_block, block_count); [partition].s_uspace.s_bitmap,
} 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].s_uspace.s_table, UDF_SB_PARTMAPS(sb)[partition].
partition, first_block, block_count); s_uspace.s_table, partition,
} 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)[partition].s_fspace.s_bitmap, UDF_SB_PARTMAPS(sb)
partition, first_block, block_count); [partition].s_fspace.s_bitmap,
} partition, first_block,
else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) block_count);
{ } 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].s_fspace.s_table, UDF_SB_PARTMAPS(sb)[partition].
partition, first_block, block_count); s_fspace.s_table, partition,
} first_block, block_count);
else } else
return 0; return 0;
} }
@ -917,33 +938,29 @@ inline int udf_new_block(struct super_block * sb,
{ {
int ret; int ret;
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].s_uspace.s_bitmap, UDF_SB_PARTMAPS(sb)[partition].
partition, goal, err); s_uspace.s_bitmap, partition, goal,
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].s_uspace.s_table, UDF_SB_PARTMAPS(sb)[partition].
partition, goal, err); s_uspace.s_table, partition, goal,
} 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].s_fspace.s_bitmap, UDF_SB_PARTMAPS(sb)[partition].
partition, goal, err); s_fspace.s_bitmap, partition, goal,
} 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].s_fspace.s_table, UDF_SB_PARTMAPS(sb)[partition].
partition, goal, err); s_fspace.s_table, partition, goal,
} err);
else } else {
{
*err = -EIO; *err = -EIO;
return 0; return 0;
} }

View file

@ -79,8 +79,7 @@ static uint16_t crc_table[256] = {
* July 21, 1997 - Andrew E. Mileski * July 21, 1997 - Andrew E. Mileski
* Adapted from OSTA-UDF(tm) 1.50 standard. * Adapted from OSTA-UDF(tm) 1.50 standard.
*/ */
uint16_t uint16_t udf_crc(uint8_t * data, uint32_t size, uint16_t crc)
udf_crc(uint8_t *data, uint32_t size, uint16_t crc)
{ {
while (size--) while (size--)
crc = crc_table[(crc >> 8 ^ *(data++)) & 0xffU] ^ (crc << 8); crc = crc_table[(crc >> 8 ^ *(data++)) & 0xffU] ^ (crc << 8);

View file

@ -82,10 +82,9 @@ 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;
} }
@ -98,7 +97,8 @@ int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
} }
static int static int
do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *dirent) do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
void *dirent)
{ {
struct udf_fileident_bh fibh; struct udf_fileident_bh fibh;
struct fileIdentDesc *fi = NULL; struct fileIdentDesc *fi = NULL;
@ -125,65 +125,61 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
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 = (nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; fibh.soffset = fibh.eoffset =
(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, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) &epos, &eloc, &elen,
{ &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);
return -EIO; return -EIO;
} }
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)-offset; i = (elen >> dir->i_sb->s_blocksize_bits) -
for (num=0; i>0; i--) offset;
{ for (num = 0; i > 0; i--) {
block = udf_get_lb_pblock(dir->i_sb, eloc, offset+i); block =
udf_get_lb_pblock(dir->i_sb, eloc,
offset + i);
tmp = udf_tgetblk(dir->i_sb, block); tmp = udf_tgetblk(dir->i_sb, block);
if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp)) if (tmp && !buffer_uptodate(tmp)
&& !buffer_locked(tmp))
bha[num++] = tmp; bha[num++] = tmp;
else else
brelse(tmp); brelse(tmp);
} }
if (num) if (num) {
{
ll_rw_block(READA, num, bha); ll_rw_block(READA, num, bha);
for (i = 0; i < num; i++) for (i = 0; i < num; i++)
brelse(bha[i]); brelse(bha[i]);
} }
} }
} } else {
else
{
brelse(epos.bh); brelse(epos.bh);
return -ENOENT; return -ENOENT;
} }
while ( nf_pos < size ) while (nf_pos < size) {
{
filp->f_pos = nf_pos + 1; filp->f_pos = nf_pos + 1;
fi = udf_fileident_read(dir, &nf_pos, &fibh, &cfi, &epos, &eloc, &elen, &offset); fi = udf_fileident_read(dir, &nf_pos, &fibh, &cfi, &epos, &eloc,
&elen, &offset);
if (!fi) if (!fi) {
{
if (fibh.sbh != fibh.ebh) if (fibh.sbh != fibh.ebh)
brelse(fibh.ebh); brelse(fibh.ebh);
brelse(fibh.sbh); brelse(fibh.sbh);
@ -196,43 +192,41 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
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 = fibh.soffset + sizeof(struct fileIdentDesc) + liu + lfi; poffset =
fibh.soffset + sizeof(struct fileIdentDesc) + liu +
lfi;
if (poffset >= lfi) if (poffset >= lfi)
nameptr = (char *)(fibh.ebh->b_data + poffset - lfi); nameptr =
else (char *)(fibh.ebh->b_data + poffset - lfi);
{ else {
nameptr = fname; nameptr = fname;
memcpy(nameptr, fi->fileIdent + liu, lfi - poffset); memcpy(nameptr, fi->fileIdent + liu,
memcpy(nameptr + lfi - poffset, fibh.ebh->b_data, poffset); lfi - 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 (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNDELETE)) if (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNDELETE))
continue; continue;
} }
if ( (cfi.fileCharacteristics & FID_FILE_CHAR_HIDDEN) != 0 ) if ((cfi.fileCharacteristics & FID_FILE_CHAR_HIDDEN) != 0) {
{
if (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNHIDE)) if (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNHIDE))
continue; continue;
} }
if ( cfi.fileCharacteristics & FID_FILE_CHAR_PARENT ) if (cfi.fileCharacteristics & FID_FILE_CHAR_PARENT) {
{
iblock = parent_ino(filp->f_path.dentry); iblock = parent_ino(filp->f_path.dentry);
flen = 2; flen = 2;
memcpy(fname, "..", flen); memcpy(fname, "..", flen);
dt_type = DT_DIR; dt_type = DT_DIR;
} } else {
else
{
kernel_lb_addr tloc = lelb_to_cpu(cfi.icb.extLocation); kernel_lb_addr tloc = lelb_to_cpu(cfi.icb.extLocation);
iblock = udf_get_lb_pblock(dir->i_sb, tloc, 0); iblock = udf_get_lb_pblock(dir->i_sb, tloc, 0);
@ -240,10 +234,10 @@ do_udf_readdir(struct inode * dir, struct file *filp, filldir_t filldir, void *d
dt_type = DT_UNKNOWN; dt_type = DT_UNKNOWN;
} }
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);

View file

@ -19,10 +19,10 @@
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#if 0 #if 0
static uint8_t * static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad,
udf_filead_read(struct inode *dir, uint8_t *tmpad, uint8_t ad_size, uint8_t ad_size, kernel_lb_addr fe_loc,
kernel_lb_addr fe_loc, int *pos, int *offset, int *pos, int *offset, struct buffer_head **bh,
struct buffer_head **bh, int *error) int *error)
{ {
int loffset = *offset; int loffset = *offset;
int block; int block;
@ -34,24 +34,20 @@ udf_filead_read(struct inode *dir, uint8_t *tmpad, uint8_t ad_size,
ad = (uint8_t *) (*bh)->b_data + *offset; ad = (uint8_t *) (*bh)->b_data + *offset;
*offset += ad_size; *offset += ad_size;
if (!ad) if (!ad) {
{
brelse(*bh); brelse(*bh);
*error = 1; *error = 1;
return NULL; return NULL;
} }
if (*offset == dir->i_sb->s_blocksize) if (*offset == dir->i_sb->s_blocksize) {
{
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);
if (!block) if (!block)
return NULL; return NULL;
if (!(*bh = udf_tread(dir->i_sb, block))) if (!(*bh = udf_tread(dir->i_sb, block)))
return NULL; return NULL;
} } else if (*offset > dir->i_sb->s_blocksize) {
else if (*offset > dir->i_sb->s_blocksize)
{
ad = tmpad; ad = tmpad;
remainder = dir->i_sb->s_blocksize - loffset; remainder = dir->i_sb->s_blocksize - loffset;
@ -64,15 +60,15 @@ udf_filead_read(struct inode *dir, uint8_t *tmpad, uint8_t ad_size,
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, ad_size - remainder); memcpy((uint8_t *) ad + remainder, (*bh)->b_data,
ad_size - remainder);
*offset = ad_size - remainder; *offset = ad_size - remainder;
} }
return ad; return ad;
} }
#endif #endif
struct fileIdentDesc * struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
udf_fileident_read(struct inode *dir, loff_t *nf_pos,
struct udf_fileident_bh *fibh, struct udf_fileident_bh *fibh,
struct fileIdentDesc *cfi, struct fileIdentDesc *cfi,
struct extent_position *epos, struct extent_position *epos,
@ -85,26 +81,26 @@ udf_fileident_read(struct inode *dir, loff_t *nf_pos,
fibh->soffset = fibh->eoffset; fibh->soffset = fibh->eoffset;
if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
{
fi = udf_get_fileident(UDF_I_DATA(dir) - fi = udf_get_fileident(UDF_I_DATA(dir) -
(UDF_I_EFE(dir) ? (UDF_I_EFE(dir) ?
sizeof(struct extendedFileEntry) : sizeof(struct extendedFileEntry) :
sizeof(struct fileEntry)), sizeof(struct fileEntry)),
dir->i_sb->s_blocksize, &(fibh->eoffset)); dir->i_sb->s_blocksize,
&(fibh->eoffset));
if (!fi) if (!fi)
return NULL; return NULL;
*nf_pos += ((fibh->eoffset - fibh->soffset) >> 2); *nf_pos += ((fibh->eoffset - fibh->soffset) >> 2);
memcpy((uint8_t *)cfi, (uint8_t *)fi, sizeof(struct fileIdentDesc)); memcpy((uint8_t *) cfi, (uint8_t *) fi,
sizeof(struct fileIdentDesc));
return fi; return fi;
} }
if (fibh->eoffset == dir->i_sb->s_blocksize) if (fibh->eoffset == dir->i_sb->s_blocksize) {
{
int lextoffset = epos->offset; int lextoffset = epos->offset;
if (udf_next_aext(dir, epos, eloc, elen, 1) != if (udf_next_aext(dir, epos, eloc, elen, 1) !=
@ -125,30 +121,32 @@ 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 (!(*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 >
i = (*elen >> dir->i_sb->s_blocksize_bits)-*offset; (*elen >> dir->i_sb->s_blocksize_bits))
for (num=0; i>0; i--) i = (*elen >> dir->i_sb->s_blocksize_bits) -
{ *offset;
block = udf_get_lb_pblock(dir->i_sb, *eloc, *offset+i); for (num = 0; i > 0; i--) {
block =
udf_get_lb_pblock(dir->i_sb, *eloc,
*offset + i);
tmp = udf_tgetblk(dir->i_sb, block); tmp = udf_tgetblk(dir->i_sb, block);
if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp)) if (tmp && !buffer_uptodate(tmp)
&& !buffer_locked(tmp))
bha[num++] = tmp; bha[num++] = tmp;
else else
brelse(tmp); brelse(tmp);
} }
if (num) if (num) {
{
ll_rw_block(READA, num, bha); ll_rw_block(READA, num, bha);
for (i = 0; i < num; i++) for (i = 0; i < num; i++)
brelse(bha[i]); brelse(bha[i]);
} }
} }
} } else if (fibh->sbh != fibh->ebh) {
else if (fibh->sbh != fibh->ebh)
{
brelse(fibh->sbh); brelse(fibh->sbh);
fibh->sbh = fibh->ebh; fibh->sbh = fibh->ebh;
} }
@ -161,12 +159,10 @@ 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;
if (udf_next_aext(dir, epos, eloc, elen, 1) != if (udf_next_aext(dir, epos, eloc, elen, 1) !=
@ -188,30 +184,31 @@ udf_fileident_read(struct inode *dir, loff_t *nf_pos,
if (!(fibh->ebh = udf_tread(dir->i_sb, block))) if (!(fibh->ebh = udf_tread(dir->i_sb, block)))
return NULL; return NULL;
if (sizeof(struct fileIdentDesc) > - fibh->soffset) if (sizeof(struct fileIdentDesc) > -fibh->soffset) {
{
int fi_len; int fi_len;
memcpy((uint8_t *) cfi, (uint8_t *) fi, -fibh->soffset); memcpy((uint8_t *) cfi, (uint8_t *) fi, -fibh->soffset);
memcpy((uint8_t *)cfi - fibh->soffset, fibh->ebh->b_data, memcpy((uint8_t *) cfi - fibh->soffset,
fibh->ebh->b_data,
sizeof(struct fileIdentDesc) + fibh->soffset); sizeof(struct fileIdentDesc) + fibh->soffset);
fi_len = (sizeof(struct fileIdentDesc) + cfi->lengthFileIdent + fi_len =
(sizeof(struct fileIdentDesc) +
cfi->lengthFileIdent +
le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3; le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3;
*nf_pos += ((fi_len - (fibh->eoffset - fibh->soffset)) >> 2); *nf_pos +=
((fi_len - (fibh->eoffset - fibh->soffset)) >> 2);
fibh->eoffset = fibh->soffset + fi_len; fibh->eoffset = fibh->soffset + fi_len;
} } else {
else memcpy((uint8_t *) cfi, (uint8_t *) fi,
{ sizeof(struct fileIdentDesc));
memcpy((uint8_t *)cfi, (uint8_t *)fi, sizeof(struct fileIdentDesc));
} }
} }
return fi; return fi;
} }
struct fileIdentDesc * struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
udf_get_fileident(void * buffer, int bufsize, int * offset)
{ {
struct fileIdentDesc *fi; struct fileIdentDesc *fi;
int lengthThisIdent; int lengthThisIdent;
@ -219,7 +216,8 @@ udf_get_fileident(void * buffer, int bufsize, int * offset)
int padlen; int padlen;
if ((!buffer) || (!offset)) { if ((!buffer) || (!offset)) {
udf_debug("invalidparms\n, buffer=%p, offset=%p\n", buffer, offset); udf_debug("invalidparms\n, buffer=%p, offset=%p\n", buffer,
offset);
return NULL; return NULL;
} }
@ -229,19 +227,17 @@ udf_get_fileident(void * buffer, int bufsize, int * offset)
ptr += *offset; ptr += *offset;
} }
fi = (struct fileIdentDesc *)ptr; fi = (struct fileIdentDesc *)ptr;
if (le16_to_cpu(fi->descTag.tagIdent) != TAG_IDENT_FID) if (le16_to_cpu(fi->descTag.tagIdent) != TAG_IDENT_FID) {
{
udf_debug("0x%x != TAG_IDENT_FID\n", udf_debug("0x%x != TAG_IDENT_FID\n",
le16_to_cpu(fi->descTag.tagIdent)); le16_to_cpu(fi->descTag.tagIdent));
udf_debug("offset: %u sizeof: %lu bufsize: %u\n", udf_debug("offset: %u sizeof: %lu bufsize: %u\n",
*offset, (unsigned long)sizeof(struct fileIdentDesc), bufsize); *offset, (unsigned long)sizeof(struct fileIdentDesc),
bufsize);
return NULL; return NULL;
} }
if ( (*offset + sizeof(struct fileIdentDesc)) > bufsize ) if ((*offset + sizeof(struct fileIdentDesc)) > bufsize) {
{
lengthThisIdent = sizeof(struct fileIdentDesc); lengthThisIdent = sizeof(struct fileIdentDesc);
} } else
else
lengthThisIdent = sizeof(struct fileIdentDesc) + lengthThisIdent = sizeof(struct fileIdentDesc) +
fi->lengthFileIdent + le16_to_cpu(fi->lengthOfImpUse); fi->lengthFileIdent + le16_to_cpu(fi->lengthOfImpUse);
@ -255,32 +251,30 @@ udf_get_fileident(void * buffer, int bufsize, int * offset)
} }
#if 0 #if 0
static extent_ad * static extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset)
udf_get_fileextent(void * buffer, int bufsize, int * offset)
{ {
extent_ad *ext; extent_ad *ext;
struct fileEntry *fe; struct fileEntry *fe;
uint8_t *ptr; uint8_t *ptr;
if ( (!buffer) || (!offset) ) if ((!buffer) || (!offset)) {
{
printk(KERN_ERR "udf: udf_get_fileextent() invalidparms\n"); printk(KERN_ERR "udf: udf_get_fileextent() invalidparms\n");
return NULL; return NULL;
} }
fe = (struct fileEntry *)buffer; fe = (struct fileEntry *)buffer;
if ( le16_to_cpu(fe->descTag.tagIdent) != TAG_IDENT_FE ) if (le16_to_cpu(fe->descTag.tagIdent) != TAG_IDENT_FE) {
{
udf_debug("0x%x != TAG_IDENT_FE\n", udf_debug("0x%x != TAG_IDENT_FE\n",
le16_to_cpu(fe->descTag.tagIdent)); le16_to_cpu(fe->descTag.tagIdent));
return NULL; return NULL;
} }
ptr=(uint8_t *)(fe->extendedAttr) + le32_to_cpu(fe->lengthExtendedAttr); ptr =
(uint8_t *) (fe->extendedAttr) +
le32_to_cpu(fe->lengthExtendedAttr);
if ( (*offset > 0) && (*offset < le32_to_cpu(fe->lengthAllocDescs)) ) if ((*offset > 0) && (*offset < le32_to_cpu(fe->lengthAllocDescs))) {
{
ptr += *offset; ptr += *offset;
} }
@ -291,13 +285,12 @@ udf_get_fileextent(void * buffer, int bufsize, int * offset)
} }
#endif #endif
short_ad * short_ad *udf_get_fileshortad(uint8_t * ptr, int maxoffset, int *offset,
udf_get_fileshortad(uint8_t *ptr, int maxoffset, int *offset, int inc) int inc)
{ {
short_ad *sa; short_ad *sa;
if ( (!ptr) || (!offset) ) if ((!ptr) || (!offset)) {
{
printk(KERN_ERR "udf: udf_get_fileshortad() invalidparms\n"); printk(KERN_ERR "udf: udf_get_fileshortad() invalidparms\n");
return NULL; return NULL;
} }
@ -312,13 +305,11 @@ udf_get_fileshortad(uint8_t *ptr, int maxoffset, int *offset, int inc)
return sa; return sa;
} }
long_ad * long_ad *udf_get_filelongad(uint8_t * ptr, int maxoffset, int *offset, int inc)
udf_get_filelongad(uint8_t *ptr, int maxoffset, int * offset, int inc)
{ {
long_ad *la; long_ad *la;
if ( (!ptr) || (!offset) ) if ((!ptr) || (!offset)) {
{
printk(KERN_ERR "udf: udf_get_filelongad() invalidparms\n"); printk(KERN_ERR "udf: udf_get_filelongad() invalidparms\n");
return NULL; return NULL;
} }

View file

@ -38,8 +38,7 @@
#define _ECMA_167_H 1 #define _ECMA_167_H 1
/* 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;
@ -58,8 +57,7 @@ typedef struct
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;
@ -72,8 +70,7 @@ typedef struct
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;
@ -94,8 +91,7 @@ typedef struct
#define TIMESTAMP_TIMEZONE_MASK 0x0FFF #define TIMESTAMP_TIMEZONE_MASK 0x0FFF
/* 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];
@ -107,8 +103,7 @@ 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;
@ -127,8 +122,7 @@ struct volStructDesc
#define VSD_STD_ID_TEA01 "TEA01" /* (2/9.3) */ #define VSD_STD_ID_TEA01 "TEA01" /* (2/9.3) */
/* 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;
@ -136,8 +130,7 @@ struct beginningExtendedAreaDesc
} __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;
@ -145,8 +138,7 @@ struct terminatingExtendedAreaDesc
} __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;
@ -167,21 +159,18 @@ struct bootDesc
#define BOOT_FLAGS_ERASE 0x01 #define BOOT_FLAGS_ERASE 0x01
/* 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;
@ -204,8 +193,7 @@ typedef struct
#define TAG_IDENT_LVID 0x0009 #define TAG_IDENT_LVID 0x0009
/* 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;
@ -214,8 +202,7 @@ struct NSRDesc
} __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;
@ -244,8 +231,7 @@ struct primaryVolDesc
#define PVD_FLAGS_VSID_COMMON 0x0001 #define PVD_FLAGS_VSID_COMMON 0x0001
/* 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;
@ -253,8 +239,7 @@ struct anchorVolDescPtr
} __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;
@ -262,8 +247,7 @@ struct volDescPtr
} __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;
@ -271,8 +255,7 @@ struct impUseVolDesc
} __attribute__ ((packed)); } __attribute__ ((packed));
/* Partition Descriptor (ECMA 167r3 3/10.5) */ /* Partition Descriptor (ECMA 167r3 3/10.5) */
struct partitionDesc struct partitionDesc {
{
tag descTag; tag descTag;
__le32 volDescSeqNum; __le32 volDescSeqNum;
__le16 partitionFlags; __le16 partitionFlags;
@ -307,8 +290,7 @@ struct partitionDesc
#define PD_ACCESS_TYPE_OVERWRITABLE 0x00000004 #define PD_ACCESS_TYPE_OVERWRITABLE 0x00000004
/* 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;
@ -325,8 +307,7 @@ struct logicalVolDesc
} __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];
@ -338,8 +319,7 @@ struct genericPartitionMap
#define GP_PARTITION_MAP_TYPE_2 0x02 #define GP_PARTITION_MAP_TYPE_2 0x02
/* 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;
@ -347,16 +327,14 @@ struct genericPartitionMap1
} __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;
@ -364,15 +342,13 @@ struct unallocSpaceDesc
} __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;
@ -390,52 +366,45 @@ struct logicalVolIntegrityDesc
#define LVID_INTEGRITY_TYPE_CLOSE 0x00000001 #define LVID_INTEGRITY_TYPE_CLOSE 0x00000001
/* 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;
@ -458,8 +427,7 @@ typedef struct
#define TAG_IDENT_EFE 0x010A #define TAG_IDENT_EFE 0x010A
/* 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;
@ -482,8 +450,7 @@ struct fileSetDesc
} __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;
@ -493,8 +460,7 @@ struct partitionHeaderDesc
} __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;
@ -514,16 +480,14 @@ struct fileIdentDesc
#define FID_FILE_CHAR_METADATA 0x10 #define FID_FILE_CHAR_METADATA 0x10
/* 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;
@ -576,23 +540,20 @@ typedef struct
#define ICBTAG_FLAG_STREAM 0x2000 #define ICBTAG_FLAG_STREAM 0x2000
/* 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;
@ -655,16 +616,14 @@ struct fileEntry
#define FE_RECORD_DISPLAY_ATTR_3 0x03 #define FE_RECORD_DISPLAY_ATTR_3 0x03
/* 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];
@ -673,8 +632,7 @@ struct genericFormat
} __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];
@ -685,8 +643,7 @@ struct charSetInfo
} __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];
@ -697,8 +654,7 @@ struct altPerms
} __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];
@ -715,8 +671,7 @@ struct fileTimesExtAttr
#define FTE_BACKUP 0x00000002 #define FTE_BACKUP 0x00000002
/* 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];
@ -727,8 +682,7 @@ struct infoTimesExtAttr
} __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];
@ -740,8 +694,7 @@ struct deviceSpec
} __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];
@ -752,8 +705,7 @@ struct impUseExtAttr
} __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];
@ -771,10 +723,8 @@ struct appUseExtAttr
#define EXTATTR_IMP_USE 2048 #define EXTATTR_IMP_USE 2048
#define EXTATTR_APP_USE 65536 #define EXTATTR_APP_USE 65536
/* 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;
@ -782,8 +732,7 @@ struct unallocSpaceEntry
} __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;
@ -791,8 +740,7 @@ struct spaceBitmapDesc
} __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;
@ -815,15 +763,13 @@ struct partitionIntegrityEntry
/* Extended Allocation Descriptor (ECMA 167r3 4/14.14.3) */ /* Extended Allocation Descriptor (ECMA 167r3 4/14.14.3) */
/* 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;
@ -831,8 +777,7 @@ struct pathComponent
} __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;

View file

@ -58,7 +58,8 @@ static int udf_adinicb_readpage(struct file *file, struct page * page)
return 0; return 0;
} }
static int udf_adinicb_writepage(struct page *page, struct writeback_control *wbc) static int udf_adinicb_writepage(struct page *page,
struct writeback_control *wbc)
{ {
struct inode *inode = page->mapping->host; struct inode *inode = page->mapping->host;
char *kaddr; char *kaddr;
@ -74,13 +75,15 @@ static int udf_adinicb_writepage(struct page *page, struct writeback_control *wb
return 0; return 0;
} }
static int udf_adinicb_prepare_write(struct file *file, struct page *page, unsigned offset, unsigned to) static int udf_adinicb_prepare_write(struct file *file, struct page *page,
unsigned offset, unsigned to)
{ {
kmap(page); kmap(page);
return 0; return 0;
} }
static int udf_adinicb_commit_write(struct file *file, struct page *page, unsigned offset, unsigned to) static int udf_adinicb_commit_write(struct file *file, struct page *page,
unsigned offset, unsigned to)
{ {
struct inode *inode = page->mapping->host; struct inode *inode = page->mapping->host;
char *kaddr = page_address(page); char *kaddr = page_address(page);
@ -113,25 +116,20 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
int err, pos; int err, pos;
size_t count = iocb->ki_left; size_t count = iocb->ki_left;
if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) {
{
if (file->f_flags & O_APPEND) if (file->f_flags & O_APPEND)
pos = inode->i_size; pos = inode->i_size;
else else
pos = ppos; pos = ppos;
if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) + if (inode->i_sb->s_blocksize <
pos + count)) (udf_file_entry_alloc_offset(inode) + 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);
return err; return err;
} }
} } else {
else
{
if (pos + count > inode->i_size) if (pos + count > inode->i_size)
UDF_I_LENALLOC(inode) = pos + count; UDF_I_LENALLOC(inode) = pos + count;
else else
@ -185,30 +183,29 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
{ {
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;
} }
if ( !arg ) if (!arg) {
{
udf_debug("invalid argument to udf_ioctl\n"); udf_debug("invalid argument to udf_ioctl\n");
return -EINVAL; return -EINVAL;
} }
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), 32) ? -EFAULT : 0; UDF_SB_VOLIDENT(inode->i_sb),
32) ? -EFAULT : 0;
case UDF_RELOCATE_BLOCKS: case UDF_RELOCATE_BLOCKS:
{ {
long old, new; long old, new;
if (!capable(CAP_SYS_ADMIN)) return -EACCES; if (!capable(CAP_SYS_ADMIN))
if (get_user(old, (long __user *)arg)) return -EFAULT; return -EACCES;
if (get_user(old, (long __user *)arg))
return -EFAULT;
if ((result = udf_relocate_blocks(inode->i_sb, if ((result = udf_relocate_blocks(inode->i_sb,
old, &new)) == 0) old, &new)) == 0)
result = put_user(new, (long __user *)arg); result = put_user(new, (long __user *)arg);
@ -242,8 +239,7 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
*/ */
static int udf_release_file(struct inode *inode, struct file *filp) static int udf_release_file(struct inode *inode, struct file *filp)
{ {
if (filp->f_mode & FMODE_WRITE) if (filp->f_mode & FMODE_WRITE) {
{
lock_kernel(); lock_kernel();
udf_discard_prealloc(inode); udf_discard_prealloc(inode);
unlock_kernel(); unlock_kernel();

View file

@ -46,10 +46,12 @@ 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) - 1); cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)
- 1);
else else
UDF_SB_LVIDIU(sb)->numFiles = UDF_SB_LVIDIU(sb)->numFiles =
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) - 1); cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles)
- 1);
mark_buffer_dirty(sbi->s_lvidbh); mark_buffer_dirty(sbi->s_lvidbh);
} }
@ -68,8 +70,7 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
inode = new_inode(sb); inode = new_inode(sb);
if (!inode) if (!inode) {
{
*err = -ENOMEM; *err = -ENOMEM;
return NULL; return NULL;
} }
@ -81,26 +82,30 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
UDF_I_NEXT_ALLOC_GOAL(inode) = 0; UDF_I_NEXT_ALLOC_GOAL(inode) = 0;
UDF_I_STRAT4096(inode) = 0; UDF_I_STRAT4096(inode) = 0;
block = udf_new_block(dir->i_sb, NULL, UDF_I_LOCATION(dir).partitionReferenceNum, block =
start, err); udf_new_block(dir->i_sb, NULL,
if (*err) UDF_I_LOCATION(dir).partitionReferenceNum, start,
{ err);
if (*err) {
iput(inode); iput(inode);
return NULL; return NULL;
} }
mutex_lock(&sbi->s_alloc_mutex); mutex_lock(&sbi->s_alloc_mutex);
if (UDF_SB_LVIDBH(sb)) if (UDF_SB_LVIDBH(sb)) {
{
struct logicalVolHeaderDesc *lvhd; struct logicalVolHeaderDesc *lvhd;
uint64_t uniqueID; uint64_t uniqueID;
lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->logicalVolContentsUse); lvhd =
(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) + 1); cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)
+ 1);
else else
UDF_SB_LVIDIU(sb)->numFiles = UDF_SB_LVIDIU(sb)->numFiles =
cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + 1); cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles)
+ 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;
@ -109,35 +114,34 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
} }
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = current->fsuid; inode->i_uid = current->fsuid;
if (dir->i_mode & S_ISGID) if (dir->i_mode & S_ISGID) {
{
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(dir).partitionReferenceNum; UDF_I_LOCATION(inode).partitionReferenceNum =
UDF_I_LOCATION(dir).partitionReferenceNum;
inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0); inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0);
inode->i_blocks = 0; inode->i_blocks = 0;
UDF_I_LENEATTR(inode) = 0; UDF_I_LENEATTR(inode) = 0;
UDF_I_LENALLOC(inode) = 0; UDF_I_LENALLOC(inode) = 0;
UDF_I_USE(inode) = 0; UDF_I_USE(inode) = 0;
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) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL); UDF_I_DATA(inode) =
} kzalloc(inode->i_sb->s_blocksize -
else sizeof(struct extendedFileEntry), GFP_KERNEL);
{ } else {
UDF_I_EFE(inode) = 0; UDF_I_EFE(inode) = 0;
UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL); UDF_I_DATA(inode) =
kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry),
GFP_KERNEL);
} }
if (!UDF_I_DATA(inode)) if (!UDF_I_DATA(inode)) {
{
iput(inode); iput(inode);
*err = -ENOMEM; *err = -ENOMEM;
mutex_unlock(&sbi->s_alloc_mutex); mutex_unlock(&sbi->s_alloc_mutex);
@ -155,8 +159,7 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
mark_inode_dirty(inode); mark_inode_dirty(inode);
mutex_unlock(&sbi->s_alloc_mutex); mutex_unlock(&sbi->s_alloc_mutex);
if (DQUOT_ALLOC_INODE(inode)) if (DQUOT_ALLOC_INODE(inode)) {
{
DQUOT_DROP(inode); DQUOT_DROP(inode);
inode->i_flags |= S_NOQUOTA; inode->i_flags |= S_NOQUOTA;
inode->i_nlink = 0; inode->i_nlink = 0;

File diff suppressed because it is too large Load diff

View file

@ -26,8 +26,7 @@
#include <linux/udf_fs.h> #include <linux/udf_fs.h>
#include "udf_sb.h" #include "udf_sb.h"
unsigned int unsigned int udf_get_last_session(struct super_block *sb)
udf_get_last_session(struct super_block *sb)
{ {
struct cdrom_multisession ms_info; struct cdrom_multisession ms_info;
unsigned int vol_desc_start; unsigned int vol_desc_start;
@ -40,24 +39,20 @@ udf_get_last_session(struct super_block *sb)
#define WE_OBEY_THE_WRITTEN_STANDARDS 1 #define WE_OBEY_THE_WRITTEN_STANDARDS 1
if (i == 0) if (i == 0) {
{
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
{
udf_debug("CDROMMULTISESSION not supported: rc=%d\n", i); udf_debug("CDROMMULTISESSION not supported: rc=%d\n", i);
} }
return vol_desc_start; return vol_desc_start;
} }
unsigned long unsigned long udf_get_last_block(struct super_block *sb)
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;

View file

@ -29,8 +29,7 @@
#include "udf_i.h" #include "udf_i.h"
#include "udf_sb.h" #include "udf_sb.h"
struct buffer_head * struct buffer_head *udf_tgetblk(struct super_block *sb, int block)
udf_tgetblk(struct super_block *sb, int block)
{ {
if (UDF_QUERY_FLAG(sb, UDF_FLAG_VARCONV)) if (UDF_QUERY_FLAG(sb, UDF_FLAG_VARCONV))
return sb_getblk(sb, udf_fixed_to_variable(block)); return sb_getblk(sb, udf_fixed_to_variable(block));
@ -38,8 +37,7 @@ udf_tgetblk(struct super_block *sb, int block)
return sb_getblk(sb, block); return sb_getblk(sb, block);
} }
struct buffer_head * struct buffer_head *udf_tread(struct super_block *sb, int block)
udf_tread(struct super_block *sb, int block)
{ {
if (UDF_QUERY_FLAG(sb, UDF_FLAG_VARCONV)) if (UDF_QUERY_FLAG(sb, UDF_FLAG_VARCONV))
return sb_bread(sb, udf_fixed_to_variable(block)); return sb_bread(sb, udf_fixed_to_variable(block));
@ -47,9 +45,8 @@ udf_tread(struct super_block *sb, int block)
return sb_bread(sb, block); return sb_bread(sb, block);
} }
struct genericFormat * struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
udf_add_extendedattr(struct inode * inode, uint32_t size, uint32_t type, uint32_t type, uint8_t loc)
uint8_t loc)
{ {
uint8_t *ea = NULL, *ad = NULL; uint8_t *ea = NULL, *ad = NULL;
int offset; int offset;
@ -59,8 +56,7 @@ udf_add_extendedattr(struct inode * inode, uint32_t size, uint32_t type,
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);
} }
@ -70,67 +66,66 @@ udf_add_extendedattr(struct inode * inode, uint32_t size, uint32_t type,
/* TODO - Check for FreeEASpace */ /* TODO - Check for FreeEASpace */
if (loc & 0x01 && offset >= size) if (loc & 0x01 && offset >= size) {
{
struct extendedAttrHeaderDesc *eahd; struct extendedAttrHeaderDesc *eahd;
eahd = (struct extendedAttrHeaderDesc *)ea; eahd = (struct extendedAttrHeaderDesc *)ea;
if (UDF_I_LENALLOC(inode)) if (UDF_I_LENALLOC(inode)) {
{
memmove(&ad[size], ad, UDF_I_LENALLOC(inode)); memmove(&ad[size], ad, UDF_I_LENALLOC(inode));
} }
if (UDF_I_LENEATTR(inode)) if (UDF_I_LENEATTR(inode)) {
{
/* check checksum/crc */ /* check checksum/crc */
if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD || if (le16_to_cpu(eahd->descTag.tagIdent) !=
le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum) TAG_IDENT_EAHD
{ || 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) += sizeof(struct extendedAttrHeaderDesc); UDF_I_LENEATTR(inode) +=
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 = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb)); eahd->descTag.tagSerialNum =
eahd->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb));
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 =
uint32_t aal = le32_to_cpu(eahd->appAttrLocation); le32_to_cpu(eahd->appAttrLocation);
memmove(&ea[offset - aal + size], memmove(&ea[offset - aal + size], &ea[aal],
&ea[aal], offset - 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) < UDF_I_LENEATTR(inode)) if (le32_to_cpu(eahd->impAttrLocation) <
{ 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) <
{ UDF_I_LENEATTR(inode)) {
if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode)) uint32_t aal =
{ le32_to_cpu(eahd->appAttrLocation);
uint32_t aal = le32_to_cpu(eahd->appAttrLocation); memmove(&ea[offset - aal + size], &ea[aal],
memmove(&ea[offset - aal + size], offset - aal);
&ea[aal], offset - aal);
offset -= aal; offset -= aal;
eahd->appAttrLocation = cpu_to_le32(aal + size); eahd->appAttrLocation = cpu_to_le32(aal + size);
} }
@ -138,22 +133,23 @@ udf_add_extendedattr(struct inode * inode, uint32_t size, uint32_t type,
/* 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 = cpu_to_le16(udf_crc((char *)eahd + sizeof(tag), crclen, 0)); eahd->descTag.descCRC =
cpu_to_le16(udf_crc((char *)eahd + 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 += ((uint8_t *)&(eahd->descTag))[i]; eahd->descTag.tagChecksum +=
((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;
} }
struct genericFormat * struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
udf_get_extendedattr(struct inode *inode, uint32_t type, uint8_t subtype) uint8_t subtype)
{ {
struct genericFormat *gaf; struct genericFormat *gaf;
uint8_t *ea = NULL; uint8_t *ea = NULL;
@ -161,15 +157,14 @@ udf_get_extendedattr(struct inode *inode, uint32_t type, uint8_t subtype)
ea = UDF_I_DATA(inode); ea = UDF_I_DATA(inode);
if (UDF_I_LENEATTR(inode)) if (UDF_I_LENEATTR(inode)) {
{
struct extendedAttrHeaderDesc *eahd; struct extendedAttrHeaderDesc *eahd;
eahd = (struct extendedAttrHeaderDesc *)ea; eahd = (struct extendedAttrHeaderDesc *)ea;
/* 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) != UDF_I_LOCATION(inode).logicalBlockNum) le32_to_cpu(eahd->descTag.tagLocation) !=
{ UDF_I_LOCATION(inode).logicalBlockNum) {
return NULL; return NULL;
} }
@ -180,10 +175,10 @@ udf_get_extendedattr(struct inode *inode, uint32_t type, uint8_t subtype)
else else
offset = le32_to_cpu(eahd->appAttrLocation); offset = le32_to_cpu(eahd->appAttrLocation);
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 && gaf->attrSubtype == subtype) if (le32_to_cpu(gaf->attrType) == type
&& gaf->attrSubtype == subtype)
return gaf; return gaf;
else else
offset += le32_to_cpu(gaf->attrLength); offset += le32_to_cpu(gaf->attrLength);
@ -202,8 +197,8 @@ udf_get_extendedattr(struct inode *inode, uint32_t type, uint8_t subtype)
* July 1, 1997 - Andrew E. Mileski * July 1, 1997 - Andrew E. Mileski
* Written, tested, and released. * Written, tested, and released.
*/ */
struct buffer_head * struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
udf_read_tagged(struct super_block *sb, uint32_t block, uint32_t location, uint16_t *ident) uint32_t location, uint16_t * ident)
{ {
tag *tag_p; tag *tag_p;
struct buffer_head *bh = NULL; struct buffer_head *bh = NULL;
@ -215,9 +210,9 @@ udf_read_tagged(struct super_block *sb, uint32_t block, uint32_t location, uint1
return NULL; return NULL;
bh = udf_tread(sb, block + UDF_SB_SESSION(sb)); bh = udf_tread(sb, block + UDF_SB_SESSION(sb));
if (!bh) if (!bh) {
{ udf_debug("block=%d, location=%d: read failed\n",
udf_debug("block=%d, location=%d: read failed\n", block + UDF_SB_SESSION(sb), location); block + UDF_SB_SESSION(sb), location);
return NULL; return NULL;
} }
@ -225,10 +220,10 @@ udf_read_tagged(struct super_block *sb, uint32_t block, uint32_t location, uint1
*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), le32_to_cpu(tag_p->tagLocation), location); block + UDF_SB_SESSION(sb),
le32_to_cpu(tag_p->tagLocation), location);
goto error_out; goto error_out;
} }
@ -245,8 +240,7 @@ udf_read_tagged(struct super_block *sb, uint32_t block, uint32_t location, uint1
/* Verify the tag version */ /* Verify the tag version */
if (le16_to_cpu(tag_p->descVersion) != 0x0002U && if (le16_to_cpu(tag_p->descVersion) != 0x0002U &&
le16_to_cpu(tag_p->descVersion) != 0x0003U) le16_to_cpu(tag_p->descVersion) != 0x0003U) {
{
udf_debug("tag version 0x%04x != 0x0002 || 0x0003 block %d\n", udf_debug("tag version 0x%04x != 0x0002 || 0x0003 block %d\n",
le16_to_cpu(tag_p->descVersion), block); le16_to_cpu(tag_p->descVersion), block);
goto error_out; goto error_out;
@ -255,20 +249,22 @@ udf_read_tagged(struct super_block *sb, uint32_t block, uint32_t location, uint1
/* 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->descCRCLength), 0)) le16_to_cpu(tag_p->
{ 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), le16_to_cpu(tag_p->descCRCLength)); block + UDF_SB_SESSION(sb), le16_to_cpu(tag_p->descCRC),
le16_to_cpu(tag_p->descCRCLength));
error_out: error_out:
brelse(bh); brelse(bh);
return NULL; return NULL;
} }
struct buffer_head * struct buffer_head *udf_read_ptagged(struct super_block *sb, kernel_lb_addr loc,
udf_read_ptagged(struct super_block *sb, kernel_lb_addr loc, uint32_t offset, uint16_t *ident) uint32_t offset, uint16_t * ident)
{ {
return udf_read_tagged(sb, udf_get_lb_pblock(sb, loc, offset), return udf_read_tagged(sb, udf_get_lb_pblock(sb, loc, offset),
loc.logicalBlockNum + offset, ident); loc.logicalBlockNum + offset, ident);

File diff suppressed because it is too large Load diff

View file

@ -65,30 +65,26 @@
#define IS_DF_HARD_WRITE_PROTECT 0x01 #define IS_DF_HARD_WRITE_PROTECT 0x01
#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;
@ -100,8 +96,7 @@ struct logicalVolIntegrityDescImpUse
/* 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];
@ -111,8 +106,7 @@ struct impUseVolDescImpUse
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];
@ -122,8 +116,7 @@ struct udfPartitionMap2
} __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];
@ -134,8 +127,7 @@ struct virtualPartitionMap
} __attribute__ ((packed)); } __attribute__ ((packed));
/* Sparable Partition Map (UDF 2.50 2.2.9) */ /* Sparable Partition Map (UDF 2.50 2.2.9) */
struct sparablePartitionMap struct sparablePartitionMap {
{
uint8_t partitionMapType; uint8_t partitionMapType;
uint8_t partitionMapLength; uint8_t partitionMapLength;
uint8_t reserved1[2]; uint8_t reserved1[2];
@ -150,8 +142,7 @@ struct sparablePartitionMap
} __attribute__ ((packed)); } __attribute__ ((packed));
/* 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];
@ -168,8 +159,7 @@ struct metadataPartitionMap
} __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;
@ -178,8 +168,7 @@ struct virtualAllocationTable15
#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];
@ -197,14 +186,12 @@ struct virtualAllocationTable20
#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;
@ -220,8 +207,7 @@ struct sparingTable
#define ICBTAG_FILE_TYPE_BITMAP 0xFC #define ICBTAG_FILE_TYPE_BITMAP 0xFC
/* 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));
@ -233,15 +219,13 @@ 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;
@ -250,8 +234,7 @@ struct DVDCopyrightImpUse
/* 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));

View file

@ -28,52 +28,56 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block, uint16_t partition, uint32_t offset) inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block,
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, offset); return UDF_SB_PARTFUNC(sb, partition) (sb, block, partition,
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, uint16_t partition, uint32_t offset) uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block,
uint16_t partition, uint32_t offset)
{ {
struct buffer_head *bh = NULL; struct buffer_head *bh = NULL;
uint32_t newblock; uint32_t newblock;
uint32_t index; uint32_t index;
uint32_t loc; uint32_t loc;
index = (sb->s_blocksize - UDF_SB_TYPEVIRT(sb,partition).s_start_offset) / sizeof(uint32_t); index =
(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;
} }
if (block >= index) if (block >= index) {
{
block -= index; block -= index;
newblock = 1 + (block / (sb->s_blocksize / sizeof(uint32_t))); newblock = 1 + (block / (sb->s_blocksize / sizeof(uint32_t)));
index = block % (sb->s_blocksize / sizeof(uint32_t)); index = block % (sb->s_blocksize / sizeof(uint32_t));
} } else {
else
{
newblock = 0; newblock = 0;
index = UDF_SB_TYPEVIRT(sb,partition).s_start_offset / sizeof(uint32_t) + block; index =
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);
if (!(bh = sb_bread(sb, loc))) if (!(bh = sb_bread(sb, loc))) {
{
udf_debug("get_pblock(UDF_VIRTUAL_MAP:%p,%d,%d) VAT: %d[%d]\n", udf_debug("get_pblock(UDF_VIRTUAL_MAP:%p,%d,%d) VAT: %d[%d]\n",
sb, block, partition, loc, index); sb, block, partition, loc, index);
return 0xFFFFFFFF; return 0xFFFFFFFF;
@ -83,47 +87,57 @@ uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block, uint16_t
brelse(bh); brelse(bh);
if (UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum == partition) if (UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum == partition) {
{
udf_debug("recursive call to udf_get_pblock!\n"); udf_debug("recursive call to udf_get_pblock!\n");
return 0xFFFFFFFF; return 0xFFFFFFFF;
} }
return udf_get_pblock(sb, loc, UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum, offset); return udf_get_pblock(sb, loc,
UDF_I_LOCATION(UDF_SB_VAT(sb)).
partitionReferenceNum, offset);
} }
inline uint32_t udf_get_pblock_virt20(struct super_block *sb, uint32_t block, uint16_t partition, uint32_t offset) inline uint32_t udf_get_pblock_virt20(struct super_block * sb, uint32_t block,
uint16_t partition, uint32_t offset)
{ {
return udf_get_pblock_virt15(sb, block, partition, offset); return udf_get_pblock_virt15(sb, block, partition, offset);
} }
uint32_t udf_get_pblock_spar15(struct super_block *sb, uint32_t block, uint16_t partition, uint32_t offset) uint32_t udf_get_pblock_spar15(struct super_block * sb, uint32_t block,
uint16_t partition, uint32_t offset)
{ {
int i; int i;
struct sparingTable *st = NULL; struct sparingTable *st = NULL;
uint32_t packet = (block + offset) & ~(UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1); uint32_t packet =
(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,
{ partition).
st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,partition).s_spar_map[i]->b_data; 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) >=
{ 0xFFFFFFF0)
if (le32_to_cpu(st->mapEntry[i].origLocation) >= 0xFFFFFFF0)
break; break;
else if (le32_to_cpu(st->mapEntry[i].origLocation) == packet) else if (le32_to_cpu(st->mapEntry[i].origLocation) ==
{ 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 +
} offset) &
else if (le32_to_cpu(st->mapEntry[i].origLocation) > packet) (UDF_SB_TYPESPAR
(sb,
partition).
s_packet_len
- 1));
} else if (le32_to_cpu(st->mapEntry[i].origLocation) >
packet)
break; break;
} }
} }
@ -138,19 +152,21 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
uint32_t packet; uint32_t packet;
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->
st = (struct sparingTable *)sdata->s_spar_map[j]->b_data; s_spar_map[j]->b_data;
break; break;
} }
} }
@ -158,60 +174,123 @@ 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); k++) for (k = 0; k < le16_to_cpu(st->reallocationTableLen);
{ 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
{ sparingTable *)
st = (struct sparingTable *)sdata->s_spar_map[j]->b_data; sdata->
st->mapEntry[k].origLocation = cpu_to_le32(packet); s_spar_map[j]->
udf_update_tag((char *)st, sizeof(struct sparingTable) + le16_to_cpu(st->reallocationTableLen) * sizeof(struct sparingEntry)); b_data;
mark_buffer_dirty(sdata->s_spar_map[j]); 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 = le32_to_cpu(st->mapEntry[k].mappedLocation) + *new_block =
((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1)); 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) ==
*new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) + packet) {
((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1)); *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) == 0xFFFFFFFF) if (le32_to_cpu(st->mapEntry[l].origLocation) ==
{ 0xFFFFFFFF) {
for (; j<4; j++) for (; j < 4; j++) {
{ if (sdata->s_spar_map[j]) {
if (sdata->s_spar_map[j]) st = (struct
{ sparingTable *)
st = (struct sparingTable *)sdata->s_spar_map[j]->b_data; sdata->
mapEntry = st->mapEntry[l]; s_spar_map[j]->
mapEntry.origLocation = cpu_to_le32(packet); b_data;
memmove(&st->mapEntry[k+1], &st->mapEntry[k], (l-k)*sizeof(struct sparingEntry)); mapEntry =
st->mapEntry[k] = mapEntry; st->mapEntry[l];
udf_update_tag((char *)st, sizeof(struct sparingTable) + le16_to_cpu(st->reallocationTableLen) * sizeof(struct sparingEntry)); mapEntry.origLocation =
mark_buffer_dirty(sdata->s_spar_map[j]); 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 = le32_to_cpu(st->mapEntry[k].mappedLocation) + *new_block =
((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1)); le32_to_cpu(st->mapEntry[k].
mappedLocation) +
((old_block -
UDF_SB_PARTROOT(sb,
i)) & (sdata->
s_packet_len
- 1));
return 0; return 0;
} }
} }
return 1; return 1;
} }
} }
if (i == UDF_SB_NUMPARTS(sb)) if (i == UDF_SB_NUMPARTS(sb)) {
{
/* outside of partitions */ /* outside of partitions */
/* for now, fail =) */ /* for now, fail =) */
return 1; return 1;

File diff suppressed because it is too large Load diff

View file

@ -33,20 +33,18 @@
#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, char *to) static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen,
char *to)
{ {
struct pathComponent *pc; struct pathComponent *pc;
int elen = 0; int elen = 0;
char *p = to; char *p = to;
while (elen < fromlen) while (elen < fromlen) {
{
pc = (struct pathComponent *)(from + elen); pc = (struct pathComponent *)(from + elen);
switch (pc->componentType) switch (pc->componentType) {
{
case 1: case 1:
if (pc->lengthComponentIdent == 0) if (pc->lengthComponentIdent == 0) {
{
p = to; p = to;
*p++ = '/'; *p++ = '/';
} }
@ -61,7 +59,8 @@ static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen, char
/* that would be . - just ignore */ /* that would be . - just ignore */
break; break;
case 5: case 5:
p += udf_get_filename(sb, pc->componentIdent, p, pc->lengthComponentIdent); p += udf_get_filename(sb, pc->componentIdent, p,
pc->lengthComponentIdent);
*p++ = '/'; *p++ = '/';
break; break;
} }
@ -84,8 +83,7 @@ static int udf_symlink_filler(struct file *file, struct page *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)

View file

@ -29,34 +29,37 @@
#include "udf_sb.h" #include "udf_sb.h"
static void extent_trunc(struct inode *inode, struct extent_position *epos, static void extent_trunc(struct inode *inode, struct extent_position *epos,
kernel_lb_addr eloc, int8_t etype, uint32_t elen, uint32_t nelen) kernel_lb_addr eloc, int8_t etype, uint32_t elen,
uint32_t nelen)
{ {
kernel_lb_addr neloc = { 0, 0 }; kernel_lb_addr neloc = { 0, 0 };
int last_block = (elen + inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits; int last_block =
int first_block = (nelen + inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits; (elen + inode->i_sb->s_blocksize -
1) >> inode->i_sb->s_blocksize_bits;
int first_block =
(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)) udf_free_blocks(inode->i_sb, inode, eloc, 0,
{ last_block);
udf_free_blocks(inode->i_sb, inode, eloc, 0, last_block);
etype = (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30); etype = (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30);
} } else
else
neloc = eloc; neloc = eloc;
nelen = (etype << 30) | nelen; nelen = (etype << 30) | nelen;
} }
if (elen != nelen) if (elen != nelen) {
{
udf_write_aext(inode, epos, neloc, nelen, 0); udf_write_aext(inode, epos, neloc, nelen, 0);
if (last_block - first_block > 0) if (last_block - first_block > 0) {
{
if (etype == (EXT_RECORDED_ALLOCATED >> 30)) if (etype == (EXT_RECORDED_ALLOCATED >> 30))
mark_inode_dirty(inode); mark_inode_dirty(inode);
if (etype != (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) if (etype != (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))
udf_free_blocks(inode->i_sb, inode, eloc, first_block, last_block - first_block); udf_free_blocks(inode->i_sb, inode, eloc,
first_block,
last_block - first_block);
} }
} }
} }
@ -89,8 +92,7 @@ void udf_truncate_tail_extent(struct inode *inode)
BUG(); BUG();
/* Find the last extent in the file */ /* Find the last extent in the file */
while ((netype = udf_next_aext(inode, &epos, &eloc, &elen, 1)) != -1) while ((netype = udf_next_aext(inode, &epos, &eloc, &elen, 1)) != -1) {
{
etype = netype; etype = netype;
lbcount += elen; lbcount += elen;
if (lbcount > inode->i_size) { if (lbcount > inode->i_size) {
@ -153,15 +155,21 @@ void udf_discard_prealloc(struct inode *inode)
lbcount -= elen; lbcount -= elen;
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) = epos.offset - udf_file_entry_alloc_offset(inode); UDF_I_LENALLOC(inode) =
epos.offset - udf_file_entry_alloc_offset(inode);
mark_inode_dirty(inode); mark_inode_dirty(inode);
} else { } else {
struct allocExtDesc *aed = (struct allocExtDesc *)(epos.bh->b_data); struct allocExtDesc *aed =
aed->lengthAllocDescs = cpu_to_le32(epos.offset - sizeof(struct allocExtDesc)); (struct allocExtDesc *)(epos.bh->b_data);
if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) aed->lengthAllocDescs =
cpu_to_le32(epos.offset -
sizeof(struct allocExtDesc));
if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)
|| 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, sizeof(struct allocExtDesc)); udf_update_tag(epos.bh->b_data,
sizeof(struct allocExtDesc));
mark_buffer_dirty_inode(epos.bh, inode); mark_buffer_dirty_inode(epos.bh, inode);
} }
} }
@ -190,9 +198,10 @@ 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 = (offset << sb->s_blocksize_bits) + (inode->i_size & (sb->s_blocksize-1)); byte_offset =
if (etype != -1) (offset << sb->s_blocksize_bits) +
{ (inode->i_size & (sb->s_blocksize - 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);
epos.offset += adsize; epos.offset += adsize;
@ -206,86 +215,98 @@ void udf_truncate_extents(struct inode * inode)
else else
lenalloc -= sizeof(struct allocExtDesc); lenalloc -= sizeof(struct allocExtDesc);
while ((etype = udf_current_aext(inode, &epos, &eloc, &elen, 0)) != -1) while ((etype =
{ udf_current_aext(inode, &epos, &eloc, &elen,
if (etype == (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) 0)) != -1) {
{ 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) {
{
/* We managed to free all extents in the /* We managed to free all extents in the
* indirect extent - free it too */ * indirect extent - free it too */
if (!epos.bh) if (!epos.bh)
BUG(); BUG();
udf_free_blocks(sb, inode, epos.block, 0, indirect_ext_len); udf_free_blocks(sb, inode, epos.block,
} 0, indirect_ext_len);
else } else {
{ if (!epos.bh) {
if (!epos.bh) UDF_I_LENALLOC(inode) =
{ lenalloc;
UDF_I_LENALLOC(inode) = lenalloc;
mark_inode_dirty(inode); mark_inode_dirty(inode);
} } else {
struct allocExtDesc *aed =
(struct allocExtDesc
*)(epos.bh->b_data);
aed->lengthAllocDescs =
cpu_to_le32(lenalloc);
if (!UDF_QUERY_FLAG
(sb, UDF_FLAG_STRICT)
|| UDF_SB_UDFREV(sb) >=
0x0201)
udf_update_tag(epos.bh->
b_data,
lenalloc
+
sizeof
(struct
allocExtDesc));
else else
{ udf_update_tag(epos.bh->
struct allocExtDesc *aed = (struct allocExtDesc *)(epos.bh->b_data); b_data,
aed->lengthAllocDescs = cpu_to_le32(lenalloc); sizeof
if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(sb) >= 0x0201) (struct
udf_update_tag(epos.bh->b_data, lenalloc + allocExtDesc));
sizeof(struct allocExtDesc)); mark_buffer_dirty_inode(epos.bh,
else inode);
udf_update_tag(epos.bh->b_data, sizeof(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 = udf_tread(sb, udf_get_lb_pblock(sb, eloc, 0)); epos.bh =
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,
{ 0);
extent_trunc(inode, &epos, eloc, etype, elen, 0);
epos.offset += adsize; epos.offset += adsize;
} }
} }
if (indirect_ext_len) if (indirect_ext_len) {
{
if (!epos.bh) if (!epos.bh)
BUG(); BUG();
udf_free_blocks(sb, inode, epos.block, 0, indirect_ext_len); udf_free_blocks(sb, inode, epos.block, 0,
} indirect_ext_len);
else } else {
{ if (!epos.bh) {
if (!epos.bh)
{
UDF_I_LENALLOC(inode) = lenalloc; UDF_I_LENALLOC(inode) = lenalloc;
mark_inode_dirty(inode); mark_inode_dirty(inode);
} } else {
else struct allocExtDesc *aed =
{ (struct allocExtDesc *)(epos.bh->b_data);
struct allocExtDesc *aed = (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) || UDF_SB_UDFREV(sb) >= 0x0201) if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT)
udf_update_tag(epos.bh->b_data, lenalloc + || UDF_SB_UDFREV(sb) >= 0x0201)
sizeof(struct allocExtDesc)); udf_update_tag(epos.bh->b_data,
lenalloc +
sizeof(struct
allocExtDesc));
else else
udf_update_tag(epos.bh->b_data, sizeof(struct allocExtDesc)); udf_update_tag(epos.bh->b_data,
sizeof(struct
allocExtDesc));
mark_buffer_dirty_inode(epos.bh, inode); mark_buffer_dirty_inode(epos.bh, inode);
} }
} }
} } else if (inode->i_size) {
else if (inode->i_size) if (byte_offset) {
{
if (byte_offset)
{
kernel_long_ad extent; kernel_long_ad extent;
/* /*
@ -293,21 +314,33 @@ 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 && epos.offset == udf_file_entry_alloc_offset(inode)) || if ((!epos.bh
(epos.bh && epos.offset == sizeof(struct allocExtDesc))) { && epos.offset ==
udf_file_entry_alloc_offset(inode)) || (epos.bh
&& 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 = EXT_NOT_RECORDED_NOT_ALLOCATED; extent.extLength =
} 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,
&extent.extLocation, &extent.extLength, 0); &extent.extLocation,
&extent.extLength, 0);
extent.extLength |= etype << 30; extent.extLength |= etype << 30;
} }
udf_extend_file(inode, &epos, &extent, offset+((inode->i_size & (sb->s_blocksize-1)) != 0)); udf_extend_file(inode, &epos, &extent,
offset +
((inode->
i_size & (sb->s_blocksize - 1)) !=
0));
} }
} }
UDF_I_LENEXTENTS(inode) = inode->i_size; UDF_I_LENEXTENTS(inode) = inode->i_size;

View file

@ -50,28 +50,24 @@ extern const struct address_space_operations udf_aops;
extern const struct address_space_operations udf_adinicb_aops; extern const struct address_space_operations udf_adinicb_aops;
extern const struct address_space_operations udf_symlink_aops; extern const struct address_space_operations udf_symlink_aops;
struct udf_fileident_bh struct udf_fileident_bh {
{
struct buffer_head *sbh; struct buffer_head *sbh;
struct buffer_head *ebh; struct buffer_head *ebh;
int soffset; int soffset;
int eoffset; int eoffset;
}; };
struct udf_vds_record struct udf_vds_record {
{
uint32_t block; uint32_t block;
uint32_t volDescSeqNum; uint32_t volDescSeqNum;
}; };
struct generic_desc struct generic_desc {
{
tag descTag; tag descTag;
__le32 volDescSeqNum; __le32 volDescSeqNum;
}; };
struct ustr struct ustr {
{
uint8_t u_cmpID; uint8_t u_cmpID;
uint8_t u_name[UDF_NAME_LEN - 2]; uint8_t u_name[UDF_NAME_LEN - 2];
uint8_t u_len; uint8_t u_len;
@ -83,16 +79,18 @@ struct extent_position {
kernel_lb_addr block; kernel_lb_addr block;
}; };
/* super.c */ /* super.c */
extern void udf_error(struct super_block *, const char *, const char *, ...); extern void udf_error(struct super_block *, const char *, const char *, ...);
extern void udf_warning(struct super_block *, const char *, const char *, ...); extern void udf_warning(struct super_block *, const char *, const char *, ...);
/* namei.c */ /* namei.c */
extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *, struct fileIdentDesc *, struct udf_fileident_bh *, uint8_t *, uint8_t *); extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *,
struct fileIdentDesc *, struct udf_fileident_bh *,
uint8_t *, uint8_t *);
/* file.c */ /* file.c */
extern int udf_ioctl(struct inode *, struct file *, unsigned int, unsigned long); extern int udf_ioctl(struct inode *, struct file *, unsigned int,
unsigned long);
/* inode.c */ /* inode.c */
extern struct inode *udf_iget(struct super_block *, kernel_lb_addr); extern struct inode *udf_iget(struct super_block *, kernel_lb_addr);
@ -106,21 +104,33 @@ extern void udf_delete_inode(struct inode *);
extern void udf_clear_inode(struct inode *); extern void udf_clear_inode(struct inode *);
extern int udf_write_inode(struct inode *, int); extern int udf_write_inode(struct inode *, int);
extern long udf_block_map(struct inode *, sector_t); extern long udf_block_map(struct inode *, sector_t);
extern int udf_extend_file(struct inode *, struct extent_position *, kernel_long_ad *, sector_t); extern int udf_extend_file(struct inode *, struct extent_position *,
extern int8_t inode_bmap(struct inode *, sector_t, struct extent_position *, kernel_lb_addr *, uint32_t *, sector_t *); kernel_long_ad *, sector_t);
extern int8_t udf_add_aext(struct inode *, struct extent_position *, kernel_lb_addr, uint32_t, int); extern int8_t inode_bmap(struct inode *, sector_t, struct extent_position *,
extern int8_t udf_write_aext(struct inode *, struct extent_position *, kernel_lb_addr, uint32_t, int); kernel_lb_addr *, uint32_t *, sector_t *);
extern int8_t udf_delete_aext(struct inode *, struct extent_position, kernel_lb_addr, uint32_t); extern int8_t udf_add_aext(struct inode *, struct extent_position *,
extern int8_t udf_next_aext(struct inode *, struct extent_position *, kernel_lb_addr *, uint32_t *, int); kernel_lb_addr, uint32_t, int);
extern int8_t udf_current_aext(struct inode *, struct extent_position *, kernel_lb_addr *, uint32_t *, int); extern int8_t udf_write_aext(struct inode *, struct extent_position *,
kernel_lb_addr, uint32_t, int);
extern int8_t udf_delete_aext(struct inode *, struct extent_position,
kernel_lb_addr, uint32_t);
extern int8_t udf_next_aext(struct inode *, struct extent_position *,
kernel_lb_addr *, uint32_t *, int);
extern int8_t udf_current_aext(struct inode *, struct extent_position *,
kernel_lb_addr *, uint32_t *, int);
/* misc.c */ /* misc.c */
extern struct buffer_head *udf_tgetblk(struct super_block *, int); extern struct buffer_head *udf_tgetblk(struct super_block *, int);
extern struct buffer_head *udf_tread(struct super_block *, int); extern struct buffer_head *udf_tread(struct super_block *, int);
extern struct genericFormat *udf_add_extendedattr(struct inode *, uint32_t, uint32_t, uint8_t); extern struct genericFormat *udf_add_extendedattr(struct inode *, uint32_t,
extern struct genericFormat *udf_get_extendedattr(struct inode *, uint32_t, uint8_t); uint32_t, uint8_t);
extern struct buffer_head *udf_read_tagged(struct super_block *, uint32_t, uint32_t, uint16_t *); extern struct genericFormat *udf_get_extendedattr(struct inode *, uint32_t,
extern struct buffer_head *udf_read_ptagged(struct super_block *, kernel_lb_addr, uint32_t, uint16_t *); uint8_t);
extern struct buffer_head *udf_read_tagged(struct super_block *, uint32_t,
uint32_t, uint16_t *);
extern struct buffer_head *udf_read_ptagged(struct super_block *,
kernel_lb_addr, uint32_t,
uint16_t *);
extern void udf_update_tag(char *, int); extern void udf_update_tag(char *, int);
extern void udf_new_tag(char *, uint16_t, uint16_t, uint16_t, uint32_t, int); extern void udf_new_tag(char *, uint16_t, uint16_t, uint16_t, uint32_t, int);
@ -129,15 +139,20 @@ extern unsigned int udf_get_last_session(struct super_block *);
extern unsigned long udf_get_last_block(struct super_block *); extern unsigned long udf_get_last_block(struct super_block *);
/* partition.c */ /* partition.c */
extern uint32_t udf_get_pblock(struct super_block *, uint32_t, uint16_t, uint32_t); extern uint32_t udf_get_pblock(struct super_block *, uint32_t, uint16_t,
extern uint32_t udf_get_pblock_virt15(struct super_block *, uint32_t, uint16_t, uint32_t); uint32_t);
extern uint32_t udf_get_pblock_virt20(struct super_block *, uint32_t, uint16_t, uint32_t); extern uint32_t udf_get_pblock_virt15(struct super_block *, uint32_t, uint16_t,
extern uint32_t udf_get_pblock_spar15(struct super_block *, uint32_t, uint16_t, uint32_t); uint32_t);
extern uint32_t udf_get_pblock_virt20(struct super_block *, uint32_t, uint16_t,
uint32_t);
extern uint32_t udf_get_pblock_spar15(struct super_block *, uint32_t, uint16_t,
uint32_t);
extern int udf_relocate_blocks(struct super_block *, long, long *); extern int udf_relocate_blocks(struct super_block *, long, long *);
/* unicode.c */ /* unicode.c */
extern int udf_get_filename(struct super_block *, uint8_t *, uint8_t *, int); extern int udf_get_filename(struct super_block *, uint8_t *, uint8_t *, int);
extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *, int); extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *,
int);
extern int udf_build_ustr(struct ustr *, dstring *, int); extern int udf_build_ustr(struct ustr *, dstring *, int);
extern int udf_CS0toUTF8(struct ustr *, struct ustr *); extern int udf_CS0toUTF8(struct ustr *, struct ustr *);
@ -151,16 +166,25 @@ extern void udf_discard_prealloc(struct inode *);
extern void udf_truncate_extents(struct inode *); extern void udf_truncate_extents(struct inode *);
/* balloc.c */ /* balloc.c */
extern void udf_free_blocks(struct super_block *, struct inode *, kernel_lb_addr, uint32_t, uint32_t); extern void udf_free_blocks(struct super_block *, struct inode *,
extern int udf_prealloc_blocks(struct super_block *, struct inode *, uint16_t, uint32_t, uint32_t); kernel_lb_addr, uint32_t, uint32_t);
extern int udf_new_block(struct super_block *, struct inode *, uint16_t, uint32_t, int *); extern int udf_prealloc_blocks(struct super_block *, struct inode *, uint16_t,
uint32_t, uint32_t);
extern int udf_new_block(struct super_block *, struct inode *, uint16_t,
uint32_t, int *);
/* fsync.c */ /* fsync.c */
extern int udf_fsync_file(struct file *, struct dentry *, int); extern int udf_fsync_file(struct file *, struct dentry *, int);
/* directory.c */ /* directory.c */
extern struct fileIdentDesc * udf_fileident_read(struct inode *, loff_t *, struct udf_fileident_bh *, struct fileIdentDesc *, struct extent_position *, kernel_lb_addr *, uint32_t *, sector_t *); extern struct fileIdentDesc *udf_fileident_read(struct inode *, loff_t *,
extern struct fileIdentDesc * udf_get_fileident(void * buffer, int bufsize, int * offset); struct udf_fileident_bh *,
struct fileIdentDesc *,
struct extent_position *,
kernel_lb_addr *, uint32_t *,
sector_t *);
extern struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize,
int *offset);
extern long_ad *udf_get_filelongad(uint8_t *, int, int *, int); extern long_ad *udf_get_filelongad(uint8_t *, int, int *, int);
extern short_ad *udf_get_fileshortad(uint8_t *, int, int *, int); extern short_ad *udf_get_fileshortad(uint8_t *, int, int *, int);

View file

@ -46,8 +46,7 @@
#endif #endif
/* How many days come before each month (0-12). */ /* How many days come before each month (0-12). */
static const unsigned short int __mon_yday[2][13] = static const unsigned short int __mon_yday[2][13] = {
{
/* Normal years. */ /* Normal years. */
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
/* Leap years. */ /* Leap years. */
@ -84,27 +83,23 @@ 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 * time_t *udf_stamp_to_time(time_t * dest, long *dest_usec, kernel_timestamp src)
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;
int16_t offset; int16_t offset;
if (type == 1) if (type == 1) {
{
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)) {
{
*dest = -1; *dest = -1;
*dest_usec = -1; *dest_usec = -1;
return NULL; return NULL;
@ -115,13 +110,13 @@ udf_stamp_to_time(time_t *dest, long *dest_usec, kernel_timestamp src)
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 = src.centiseconds * 10000 + src.hundredsOfMicroseconds * 100 + src.microseconds; *dest_usec =
src.centiseconds * 10000 + src.hundredsOfMicroseconds * 100 +
src.microseconds;
return dest; return dest;
} }
kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts)
kernel_timestamp *
udf_time_to_stamp(kernel_timestamp *dest, struct timespec ts)
{ {
long int days, rem, y; long int days, rem, y;
const unsigned short int *ip; const unsigned short int *ip;
@ -146,13 +141,11 @@ udf_time_to_stamp(kernel_timestamp *dest, struct timespec ts)
#define DIV(a,b) ((a) / (b) - ((a) % (b) < 0)) #define DIV(a,b) ((a) / (b) - ((a) % (b) < 0))
#define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400)) #define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400))
while (days < 0 || days >= (__isleap(y) ? 366 : 365)) while (days < 0 || days >= (__isleap(y) ? 366 : 365)) {
{
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 days -= ((yg - y) * 365 + LEAPS_THRU_END_OF(yg - 1)
+ LEAPS_THRU_END_OF (yg - 1)
- LEAPS_THRU_END_OF(y - 1)); - LEAPS_THRU_END_OF(y - 1));
y = yg; y = yg;
} }
@ -165,8 +158,10 @@ 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 = (ts.tv_nsec / 1000 - dest->centiseconds * 10000) / 100; dest->hundredsOfMicroseconds =
dest->microseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000 - (ts.tv_nsec / 1000 - dest->centiseconds * 10000) / 100;
dest->microseconds =
(ts.tv_nsec / 1000 - dest->centiseconds * 10000 -
dest->hundredsOfMicroseconds * 100); dest->hundredsOfMicroseconds * 100);
return dest; return dest;
} }

View file

@ -108,22 +108,20 @@ int udf_CS0toUTF8(struct ustr *utf_o, struct ustr *ocu_i)
cmp_id = ocu_i->u_cmpID; cmp_id = ocu_i->u_cmpID;
utf_o->u_len = 0; utf_o->u_len = 0;
if (ocu_len == 0) if (ocu_len == 0) {
{
memset(utf_o, 0, sizeof(struct ustr)); memset(utf_o, 0, sizeof(struct ustr));
utf_o->u_cmpID = 0; utf_o->u_cmpID = 0;
utf_o->u_len = 0; utf_o->u_len = 0;
return 0; return 0;
} }
if ((cmp_id != 8) && (cmp_id != 16)) if ((cmp_id != 8) && (cmp_id != 16)) {
{ printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n",
printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n", cmp_id, ocu_i->u_name); cmp_id, ocu_i->u_name);
return 0; return 0;
} }
for (i = 0; (i < ocu_len) && (utf_o->u_len <= (UDF_NAME_LEN-3)) ;) for (i = 0; (i < ocu_len) && (utf_o->u_len <= (UDF_NAME_LEN - 3));) {
{
/* Expand OSTA compressed Unicode to Unicode */ /* Expand OSTA compressed Unicode to Unicode */
c = ocu[i++]; c = ocu[i++];
@ -133,16 +131,18 @@ int udf_CS0toUTF8(struct ustr *utf_o, struct ustr *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;
@ -186,49 +186,34 @@ 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) {
{
utf_char = (utf_char << 6) | (c & 0x3fU); utf_char = (utf_char << 6) | (c & 0x3fU);
if (--utf_cnt) if (--utf_cnt)
continue; continue;
} } else {
else
{
/* Check for a multi-byte UTF-8 character */ /* Check for a multi-byte UTF-8 character */
if (c & 0x80U) if (c & 0x80U) {
{
/* Start a multi-byte UTF-8 character */ /* Start a multi-byte UTF-8 character */
if ((c & 0xe0U) == 0xc0U) if ((c & 0xe0U) == 0xc0U) {
{
utf_char = c & 0x1fU; utf_char = c & 0x1fU;
utf_cnt = 1; utf_cnt = 1;
} } else if ((c & 0xf0U) == 0xe0U) {
else if ((c & 0xf0U) == 0xe0U)
{
utf_char = c & 0x0fU; utf_char = c & 0x0fU;
utf_cnt = 2; utf_cnt = 2;
} } else if ((c & 0xf8U) == 0xf0U) {
else if ((c & 0xf8U) == 0xf0U)
{
utf_char = c & 0x07U; utf_char = c & 0x07U;
utf_cnt = 3; utf_cnt = 3;
} } else if ((c & 0xfcU) == 0xf8U) {
else if ((c & 0xfcU) == 0xf8U)
{
utf_char = c & 0x03U; utf_char = c & 0x03U;
utf_cnt = 4; utf_cnt = 4;
} } 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
@ -237,10 +222,8 @@ try_again:
} }
/* 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 ( 0xffU == max_val )
{
max_val = 0xffffU; max_val = 0xffffU;
ocu[0] = (uint8_t) 0x10U; ocu[0] = (uint8_t) 0x10U;
goto try_again; goto try_again;
@ -248,16 +231,13 @@ 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");
@ -267,7 +247,8 @@ error_out:
return u_len + 1; return u_len + 1;
} }
static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o, struct ustr *ocu_i) static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
struct ustr *ocu_i)
{ {
uint8_t *ocu; uint8_t *ocu;
uint32_t c; uint32_t c;
@ -280,22 +261,20 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o, struct ustr *
cmp_id = ocu_i->u_cmpID; cmp_id = ocu_i->u_cmpID;
utf_o->u_len = 0; utf_o->u_len = 0;
if (ocu_len == 0) if (ocu_len == 0) {
{
memset(utf_o, 0, sizeof(struct ustr)); memset(utf_o, 0, sizeof(struct ustr));
utf_o->u_cmpID = 0; utf_o->u_cmpID = 0;
utf_o->u_len = 0; utf_o->u_len = 0;
return 0; return 0;
} }
if ((cmp_id != 8) && (cmp_id != 16)) if ((cmp_id != 8) && (cmp_id != 16)) {
{ printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n",
printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n", cmp_id, ocu_i->u_name); cmp_id, ocu_i->u_name);
return 0; return 0;
} }
for (i = 0; (i < ocu_len) && (utf_o->u_len <= (UDF_NAME_LEN-3)) ;) for (i = 0; (i < ocu_len) && (utf_o->u_len <= (UDF_NAME_LEN - 3));) {
{
/* Expand OSTA compressed Unicode to Unicode */ /* Expand OSTA compressed Unicode to Unicode */
c = ocu[i++]; c = ocu[i++];
if (cmp_id == 16) if (cmp_id == 16)
@ -309,7 +288,8 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o, struct ustr *
return utf_o->u_len; return utf_o->u_len;
} }
static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni, int length) static int udf_NLStoCS0(struct nls_table *nls, dstring * ocu, struct ustr *uni,
int length)
{ {
unsigned len, i, max_val; unsigned len, i, max_val;
uint16_t uni_char; uint16_t uni_char;
@ -321,14 +301,12 @@ static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni, i
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);
if (len <= 0) if (len <= 0)
continue; continue;
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;
@ -344,68 +322,64 @@ try_again:
return u_len + 1; return u_len + 1;
} }
int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname, int flen) int udf_get_filename(struct super_block *sb, uint8_t * sname, uint8_t * dname,
int flen)
{ {
struct ustr filename, unifilename; struct ustr filename, unifilename;
int len; int len;
if (udf_build_ustr_exact(&unifilename, sname, flen)) if (udf_build_ustr_exact(&unifilename, sname, flen)) {
{
return 0; return 0;
} }
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",
{ sname);
udf_debug("Failed in udf_get_filename: sname = %s\n", 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
{ (UDF_SB(sb)->s_nls_map, &filename, &unifilename)) {
if (!udf_CS0toNLS(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 = udf_translate_to_linux(dname, filename.u_name, filename.u_len, if ((len =
unifilename.u_name, unifilename.u_len))) udf_translate_to_linux(dname, filename.u_name, filename.u_len,
{ unifilename.u_name, unifilename.u_len))) {
return len; return len;
} }
return 0; return 0;
} }
int udf_put_filename(struct super_block *sb, const uint8_t *sname, uint8_t *dname, int flen) int udf_put_filename(struct super_block *sb, const uint8_t * sname,
uint8_t * dname, int flen)
{ {
struct ustr unifilename; struct ustr unifilename;
int namelen; int namelen;
if ( !(udf_char_to_ustr(&unifilename, sname, flen)) ) if (!(udf_char_to_ustr(&unifilename, sname, flen))) {
{
return 0; return 0;
} }
if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
{ if (!
if ( !(namelen = udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN)) ) (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 =
if ( !(namelen = udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname, &unifilename, UDF_NAME_LEN)) ) 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;
@ -416,7 +390,8 @@ int udf_put_filename(struct super_block *sb, const uint8_t *sname, uint8_t *dnam
#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, int udfLen, uint8_t *fidName, int fidNameLen) static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName,
int udfLen, 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;
@ -425,31 +400,26 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen
const uint8_t hexChar[] = "0123456789ABCDEF"; const uint8_t hexChar[] = "0123456789ABCDEF";
if (udfName[0] == '.' && (udfLen == 1 || if (udfName[0] == '.' && (udfLen == 1 ||
(udfLen == 2 && udfName[1] == '.'))) (udfLen == 2 && udfName[1] == '.'))) {
{
needsCRC = 1; needsCRC = 1;
newIndex = udfLen; newIndex = udfLen;
memcpy(newName, udfName, udfLen); memcpy(newName, udfName, udfLen);
} } else {
else for (index = 0; index < udfLen; index++) {
{
for (index = 0; index < udfLen; index++)
{
curr = udfName[index]; curr = udfName[index];
if (curr == '/' || curr == 0) if (curr == '/' || curr == 0) {
{
needsCRC = 1; needsCRC = 1;
curr = ILLEGAL_CHAR_MARK; curr = ILLEGAL_CHAR_MARK;
while (index+1 < udfLen && (udfName[index+1] == '/' || while (index + 1 < udfLen
udfName[index+1] == 0)) && (udfName[index + 1] == '/'
|| udfName[index + 1] == 0))
index++; index++;
} }
if (curr == EXT_MARK && (udfLen - index - 1) <= EXT_SIZE) if (curr == EXT_MARK
{ && (udfLen - index - 1) <= EXT_SIZE) {
if (udfLen == index + 1) if (udfLen == index + 1)
hasExt = 0; hasExt = 0;
else else {
{
hasExt = 1; hasExt = 1;
extIndex = index; extIndex = index;
newExtIndex = newIndex; newExtIndex = newIndex;
@ -461,26 +431,29 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen
needsCRC = 1; needsCRC = 1;
} }
} }
if (needsCRC) if (needsCRC) {
{
uint8_t ext[EXT_SIZE]; uint8_t ext[EXT_SIZE];
int localExtIndex = 0; int localExtIndex = 0;
if (hasExt) if (hasExt) {
{
int maxFilenameLen; int maxFilenameLen;
for(index = 0; index<EXT_SIZE && extIndex + index +1 < udfLen; for (index = 0;
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 && (index + 1 < EXT_SIZE while (extIndex + index + 2 < udfLen
&& (udfName[extIndex + index + 2] == '/' || && (index + 1 < EXT_SIZE
udfName[extIndex + index + 2] == 0))) &&
(udfName
[extIndex + index + 2] ==
'/'
|| udfName[extIndex +
index + 2] ==
0)))
index++; index++;
} }
ext[localExtIndex++] = curr; ext[localExtIndex++] = curr;
@ -490,8 +463,7 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen
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);
@ -500,8 +472,7 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen
newName[newIndex++] = hexChar[(valueCRC & 0x00f0) >> 4]; newName[newIndex++] = hexChar[(valueCRC & 0x00f0) >> 4];
newName[newIndex++] = hexChar[(valueCRC & 0x000f)]; newName[newIndex++] = hexChar[(valueCRC & 0x000f)];
if (hasExt) if (hasExt) {
{
newName[newIndex++] = EXT_MARK; newName[newIndex++] = EXT_MARK;
for (index = 0; index < localExtIndex; index++) for (index = 0; index < localExtIndex; index++)
newName[newIndex++] = ext[index]; newName[newIndex++] = ext[index];