summaryrefslogtreecommitdiff
path: root/fs/udf/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/udf/misc.c')
-rw-r--r--fs/udf/misc.c76
1 files changed, 46 insertions, 30 deletions
diff --git a/fs/udf/misc.c b/fs/udf/misc.c
index 7cecb3098061..a0bf4158f1f1 100644
--- a/fs/udf/misc.c
+++ b/fs/udf/misc.c
@@ -70,71 +70,84 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
struct extendedAttrHeaderDesc *eahd;
eahd = (struct extendedAttrHeaderDesc *)ea;
- if (UDF_I_LENALLOC(inode)) {
+ if (UDF_I_LENALLOC(inode))
memmove(&ad[size], ad, UDF_I_LENALLOC(inode));
- }
if (UDF_I_LENEATTR(inode)) {
/* check checksum/crc */
- if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD ||
- le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum) {
+ if (le16_to_cpu(eahd->descTag.tagIdent) !=
+ TAG_IDENT_EAHD ||
+ le32_to_cpu(eahd->descTag.tagLocation) !=
+ UDF_I_LOCATION(inode).logicalBlockNum)
return NULL;
- }
} else {
struct udf_sb_info *sbi = UDF_SB(inode->i_sb);
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);
if (sbi->s_udfrev >= 0x0200)
eahd->descTag.descVersion = cpu_to_le16(3);
else
eahd->descTag.descVersion = cpu_to_le16(2);
- eahd->descTag.tagSerialNum = cpu_to_le16(sbi->s_serial_number);
- eahd->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
+ eahd->descTag.tagSerialNum =
+ cpu_to_le16(sbi->s_serial_number);
+ eahd->descTag.tagLocation = cpu_to_le32(
+ UDF_I_LOCATION(inode).logicalBlockNum);
eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF);
eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF);
}
offset = UDF_I_LENEATTR(inode);
if (type < 2048) {
- if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode)) {
- uint32_t aal = le32_to_cpu(eahd->appAttrLocation);
+ if (le32_to_cpu(eahd->appAttrLocation) <
+ UDF_I_LENEATTR(inode)) {
+ uint32_t aal =
+ le32_to_cpu(eahd->appAttrLocation);
memmove(&ea[offset - aal + size],
&ea[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)) {
- uint32_t ial = le32_to_cpu(eahd->impAttrLocation);
+ if (le32_to_cpu(eahd->impAttrLocation) <
+ UDF_I_LENEATTR(inode)) {
+ uint32_t ial =
+ le32_to_cpu(eahd->impAttrLocation);
memmove(&ea[offset - ial + size],
&ea[ial], offset - ial);
offset -= ial;
- eahd->impAttrLocation = cpu_to_le32(ial + size);
+ eahd->impAttrLocation =
+ cpu_to_le32(ial + size);
}
} else if (type < 65536) {
- if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode)) {
- uint32_t aal = le32_to_cpu(eahd->appAttrLocation);
+ if (le32_to_cpu(eahd->appAttrLocation) <
+ UDF_I_LENEATTR(inode)) {
+ uint32_t aal =
+ le32_to_cpu(eahd->appAttrLocation);
memmove(&ea[offset - aal + size],
&ea[aal], offset - aal);
offset -= aal;
- eahd->appAttrLocation = cpu_to_le32(aal + size);
+ eahd->appAttrLocation =
+ cpu_to_le32(aal + size);
}
}
/* rewrite CRC + checksum of eahd */
crclen = sizeof(struct extendedAttrHeaderDesc) - sizeof(tag);
eahd->descTag.descCRCLength = cpu_to_le16(crclen);
eahd->descTag.descCRC = cpu_to_le16(udf_crc((char *)eahd +
- sizeof(tag), crclen, 0));
+ sizeof(tag), crclen, 0));
eahd->descTag.tagChecksum = 0;
for (i = 0; i < 16; i++)
if (i != 4)
- eahd->descTag.tagChecksum += ((uint8_t *)&(eahd->descTag))[i];
+ eahd->descTag.tagChecksum +=
+ ((uint8_t *)&(eahd->descTag))[i];
UDF_I_LENEATTR(inode) += size;
return (struct genericFormat *)&ea[offset];
}
- if (loc & 0x02) {
- }
+ if (loc & 0x02)
+ ;
return NULL;
}
@@ -153,10 +166,11 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
eahd = (struct extendedAttrHeaderDesc *)ea;
/* check checksum/crc */
- if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD ||
- le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum) {
+ if (le16_to_cpu(eahd->descTag.tagIdent) !=
+ TAG_IDENT_EAHD ||
+ le32_to_cpu(eahd->descTag.tagLocation) !=
+ UDF_I_LOCATION(inode).logicalBlockNum)
return NULL;
- }
if (type < 2048)
offset = sizeof(struct extendedAttrHeaderDesc);
@@ -167,7 +181,8 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
while (offset < UDF_I_LENEATTR(inode)) {
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;
else
offset += le32_to_cpu(gaf->attrLength);
@@ -188,7 +203,7 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
* Written, tested, and released.
*/
struct buffer_head *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;
struct buffer_head *bh = NULL;
@@ -213,7 +228,8 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
if (location != le32_to_cpu(tag_p->tagLocation)) {
udf_debug("location mismatch block %u, tag %u != %u\n",
- block + sbi->s_session, le32_to_cpu(tag_p->tagLocation), location);
+ block + sbi->s_session,
+ le32_to_cpu(tag_p->tagLocation), location);
goto error_out;
}
@@ -239,9 +255,9 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
/* Verify the descriptor CRC */
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->descCRCLength), 0)) {
+ le16_to_cpu(tag_p->descCRCLength), 0))
return bh;
- }
+
udf_debug("Crc failure block %d: crc = %d, crclen = %d\n",
block + sbi->s_session, le16_to_cpu(tag_p->descCRC),
le16_to_cpu(tag_p->descCRCLength));
@@ -252,7 +268,7 @@ error_out:
}
struct buffer_head *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),
loc.logicalBlockNum + offset, ident);