Commit 572804f9 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] UDF endianness fixes

Lots of crap.  It looks like the thing had never been really tested on
big-endian boxen...  Aside of usual "forgot to convert" bugs there's a cute
one - foo->le16field = cpu_to_le32(bar) does not work on big-endian...
Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ec5995e8
......@@ -268,12 +268,12 @@ struct buffer_head * udf_expand_dir_adinicb(struct inode *inode, int *block, int
return NULL;
}
UDF_I_ALLOCTYPE(inode) = alloctype;
sfi->descTag.tagLocation = *block;
sfi->descTag.tagLocation = cpu_to_le32(*block);
dfibh.soffset = dfibh.eoffset;
dfibh.eoffset += (sfibh.eoffset - sfibh.soffset);
dfi = (struct fileIdentDesc *)(dbh->b_data + dfibh.soffset);
if (udf_write_fi(inode, sfi, dfi, &dfibh, sfi->impUse,
sfi->fileIdent + sfi->lengthOfImpUse))
sfi->fileIdent + le16_to_cpu(sfi->lengthOfImpUse)))
{
UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB;
udf_release_data(dbh);
......@@ -1411,11 +1411,11 @@ udf_update_inode(struct inode *inode, int do_sync)
udf_add_extendedattr(inode,
sizeof(struct deviceSpec) +
sizeof(regid), 12, 0x3);
dsea->attrType = 12;
dsea->attrType = cpu_to_le32(12);
dsea->attrSubtype = 1;
dsea->attrLength = sizeof(struct deviceSpec) +
sizeof(regid);
dsea->impUseLength = sizeof(regid);
dsea->attrLength = cpu_to_le32(sizeof(struct deviceSpec) +
sizeof(regid));
dsea->impUseLength = cpu_to_le32(sizeof(regid));
}
eid = (regid *)dsea->impUse;
memset(eid, 0, sizeof(regid));
......
......@@ -119,7 +119,7 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi,
crc = udf_crc(fibh->ebh->b_data, fibh->eoffset, crc);
}
cfi->descTag.descCRC = cpu_to_le32(crc);
cfi->descTag.descCRC = cpu_to_le16(crc);
cfi->descTag.descCRCLength = cpu_to_le16(crclen);
for (i=0; i<16; i++)
......
......@@ -119,7 +119,7 @@ uint32_t udf_get_pblock_spar15(struct super_block *sb, uint32_t block, uint16_t
if (st)
{
for (i=0; i<st->reallocationTableLen; i++)
for (i=0; i<le16_to_cpu(st->reallocationTableLen); i++)
{
if (le32_to_cpu(st->mapEntry[i].origLocation) >= 0xFFFFFFF0)
break;
......@@ -163,7 +163,7 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
if (!st)
return 1;
for (k=0; k<st->reallocationTableLen; k++)
for (k=0; k<le16_to_cpu(st->reallocationTableLen); k++)
{
if (le32_to_cpu(st->mapEntry[k].origLocation) == 0xFFFFFFFF)
{
......@@ -173,7 +173,7 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
{
st = (struct sparingTable *)sdata->s_spar_map[j]->b_data;
st->mapEntry[k].origLocation = cpu_to_le32(packet);
udf_update_tag((char *)st, sizeof(struct sparingTable) + st->reallocationTableLen * sizeof(struct sparingEntry));
udf_update_tag((char *)st, sizeof(struct sparingTable) + le16_to_cpu(st->reallocationTableLen) * sizeof(struct sparingEntry));
mark_buffer_dirty(sdata->s_spar_map[j]);
}
}
......@@ -190,7 +190,7 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
else if (le32_to_cpu(st->mapEntry[k].origLocation) > packet)
break;
}
for (l=k; l<st->reallocationTableLen; l++)
for (l=k; l<le16_to_cpu(st->reallocationTableLen); l++)
{
if (le32_to_cpu(st->mapEntry[l].origLocation) == 0xFFFFFFFF)
{
......@@ -203,7 +203,7 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
mapEntry.origLocation = cpu_to_le32(packet);
memmove(&st->mapEntry[k+1], &st->mapEntry[k], (l-k)*sizeof(struct sparingEntry));
st->mapEntry[k] = mapEntry;
udf_update_tag((char *)st, sizeof(struct sparingTable) + st->reallocationTableLen * sizeof(struct sparingEntry));
udf_update_tag((char *)st, sizeof(struct sparingTable) + le16_to_cpu(st->reallocationTableLen) * sizeof(struct sparingEntry));
mark_buffer_dirty(sdata->s_spar_map[j]);
}
}
......
......@@ -1455,7 +1455,7 @@ static void udf_close_lvid(struct super_block *sb)
UDF_SB_LVIDIU(sb)->minUDFReadRev = cpu_to_le16(UDF_SB_UDFREV(sb));
if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev))
UDF_SB_LVIDIU(sb)->minUDFWriteRev = cpu_to_le16(UDF_SB_UDFREV(sb));
UDF_SB_LVID(sb)->integrityType = LVID_INTEGRITY_TYPE_CLOSE;
UDF_SB_LVID(sb)->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
UDF_SB_LVID(sb)->descTag.descCRC =
cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag),
......@@ -1585,7 +1585,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
if (minUDFReadRev > UDF_MAX_READ_VERSION)
{
printk("UDF-fs: minUDFReadRev=%x (max is %x)\n",
UDF_SB_LVIDIU(sb)->minUDFReadRev, UDF_MAX_READ_VERSION);
le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev),
UDF_MAX_READ_VERSION);
goto error_out;
}
else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION)
......@@ -1824,7 +1825,7 @@ udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap)
}
bm = (struct spaceBitmapDesc *)bh->b_data;
bytes = bm->numOfBytes;
bytes = le32_to_cpu(bm->numOfBytes);
index = sizeof(struct spaceBitmapDesc); /* offset in first block only */
ptr = (uint8_t *)bh->b_data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment