aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/udf/inode.c15
-rw-r--r--fs/udf/misc.c35
-rw-r--r--fs/udf/namei.c9
-rw-r--r--fs/udf/super.c16
-rw-r--r--fs/udf/udfdecl.h3
5 files changed, 22 insertions, 56 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 3ce2f6d1aafa..42783da9cfe3 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1440,7 +1440,6 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1440 uint32_t udfperms; 1440 uint32_t udfperms;
1441 uint16_t icbflags; 1441 uint16_t icbflags;
1442 uint16_t crclen; 1442 uint16_t crclen;
1443 int i;
1444 kernel_timestamp cpu_time; 1443 kernel_timestamp cpu_time;
1445 int err = 0; 1444 int err = 0;
1446 struct udf_sb_info *sbi = UDF_SB(inode->i_sb); 1445 struct udf_sb_info *sbi = UDF_SB(inode->i_sb);
@@ -1476,12 +1475,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1476 use->descTag.descCRC = cpu_to_le16(udf_crc((char *)use + 1475 use->descTag.descCRC = cpu_to_le16(udf_crc((char *)use +
1477 sizeof(tag), crclen, 1476 sizeof(tag), crclen,
1478 0)); 1477 0));
1479 1478 use->descTag.tagChecksum = udf_tag_checksum(&use->descTag);
1480 use->descTag.tagChecksum = 0;
1481 for (i = 0; i < 16; i++)
1482 if (i != 4)
1483 use->descTag.tagChecksum +=
1484 ((uint8_t *)&(use->descTag))[i];
1485 1479
1486 mark_buffer_dirty(bh); 1480 mark_buffer_dirty(bh);
1487 brelse(bh); 1481 brelse(bh);
@@ -1650,12 +1644,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1650 fe->descTag.descCRCLength = cpu_to_le16(crclen); 1644 fe->descTag.descCRCLength = cpu_to_le16(crclen);
1651 fe->descTag.descCRC = cpu_to_le16(udf_crc((char *)fe + sizeof(tag), 1645 fe->descTag.descCRC = cpu_to_le16(udf_crc((char *)fe + sizeof(tag),
1652 crclen, 0)); 1646 crclen, 0));
1653 1647 fe->descTag.tagChecksum = udf_tag_checksum(&fe->descTag);
1654 fe->descTag.tagChecksum = 0;
1655 for (i = 0; i < 16; i++)
1656 if (i != 4)
1657 fe->descTag.tagChecksum +=
1658 ((uint8_t *)&(fe->descTag))[i];
1659 1648
1660 /* write the data blocks */ 1649 /* write the data blocks */
1661 mark_buffer_dirty(bh); 1650 mark_buffer_dirty(bh);
diff --git a/fs/udf/misc.c b/fs/udf/misc.c
index a0bf4158f1f1..585e4eaed254 100644
--- a/fs/udf/misc.c
+++ b/fs/udf/misc.c
@@ -51,7 +51,6 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
51 uint8_t *ea = NULL, *ad = NULL; 51 uint8_t *ea = NULL, *ad = NULL;
52 int offset; 52 int offset;
53 uint16_t crclen; 53 uint16_t crclen;
54 int i;
55 54
56 ea = UDF_I_DATA(inode); 55 ea = UDF_I_DATA(inode);
57 if (UDF_I_LENEATTR(inode)) { 56 if (UDF_I_LENEATTR(inode)) {
@@ -138,11 +137,7 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
138 eahd->descTag.descCRCLength = cpu_to_le16(crclen); 137 eahd->descTag.descCRCLength = cpu_to_le16(crclen);
139 eahd->descTag.descCRC = cpu_to_le16(udf_crc((char *)eahd + 138 eahd->descTag.descCRC = cpu_to_le16(udf_crc((char *)eahd +
140 sizeof(tag), crclen, 0)); 139 sizeof(tag), crclen, 0));
141 eahd->descTag.tagChecksum = 0; 140 eahd->descTag.tagChecksum = udf_tag_checksum(&eahd->descTag);
142 for (i = 0; i < 16; i++)
143 if (i != 4)
144 eahd->descTag.tagChecksum +=
145 ((uint8_t *)&(eahd->descTag))[i];
146 UDF_I_LENEATTR(inode) += size; 141 UDF_I_LENEATTR(inode) += size;
147 return (struct genericFormat *)&ea[offset]; 142 return (struct genericFormat *)&ea[offset];
148 } 143 }
@@ -207,8 +202,6 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
207{ 202{
208 tag *tag_p; 203 tag *tag_p;
209 struct buffer_head *bh = NULL; 204 struct buffer_head *bh = NULL;
210 register uint8_t checksum;
211 register int i;
212 struct udf_sb_info *sbi = UDF_SB(sb); 205 struct udf_sb_info *sbi = UDF_SB(sb);
213 206
214 /* Read the block */ 207 /* Read the block */
@@ -234,12 +227,7 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
234 } 227 }
235 228
236 /* Verify the tag checksum */ 229 /* Verify the tag checksum */
237 checksum = 0U; 230 if (udf_tag_checksum(tag_p) != tag_p->tagChecksum) {
238 for (i = 0; i < 4; i++)
239 checksum += (uint8_t)(bh->b_data[i]);
240 for (i = 5; i < 16; i++)
241 checksum += (uint8_t)(bh->b_data[i]);
242 if (checksum != tag_p->tagChecksum) {
243 printk(KERN_ERR "udf: tag checksum failed block %d\n", block); 231 printk(KERN_ERR "udf: tag checksum failed block %d\n", block);
244 goto error_out; 232 goto error_out;
245 } 233 }
@@ -277,17 +265,11 @@ struct buffer_head *udf_read_ptagged(struct super_block *sb, kernel_lb_addr loc,
277void udf_update_tag(char *data, int length) 265void udf_update_tag(char *data, int length)
278{ 266{
279 tag *tptr = (tag *)data; 267 tag *tptr = (tag *)data;
280 int i;
281
282 length -= sizeof(tag); 268 length -= sizeof(tag);
283 269
284 tptr->tagChecksum = 0;
285 tptr->descCRCLength = cpu_to_le16(length); 270 tptr->descCRCLength = cpu_to_le16(length);
286 tptr->descCRC = cpu_to_le16(udf_crc(data + sizeof(tag), length, 0)); 271 tptr->descCRC = cpu_to_le16(udf_crc(data + sizeof(tag), length, 0));
287 272 tptr->tagChecksum = udf_tag_checksum(tptr);
288 for (i = 0; i < 16; i++)
289 if (i != 4)
290 tptr->tagChecksum += (uint8_t)(data[i]);
291} 273}
292 274
293void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum, 275void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
@@ -300,3 +282,14 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
300 tptr->tagLocation = cpu_to_le32(loc); 282 tptr->tagLocation = cpu_to_le32(loc);
301 udf_update_tag(data, length); 283 udf_update_tag(data, length);
302} 284}
285
286u8 udf_tag_checksum(const tag *t)
287{
288 u8 *data = (u8 *)t;
289 u8 checksum = 0;
290 int i;
291 for (i = 0; i < sizeof(tag); ++i)
292 if (i != 4) /* position of checksum */
293 checksum += data[i];
294 return checksum;
295}
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index a126950d79e6..9b5cfc5f725c 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -47,8 +47,6 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi,
47{ 47{
48 uint16_t crclen = fibh->eoffset - fibh->soffset - sizeof(tag); 48 uint16_t crclen = fibh->eoffset - fibh->soffset - sizeof(tag);
49 uint16_t crc; 49 uint16_t crc;
50 uint8_t checksum = 0;
51 int i;
52 int offset; 50 int offset;
53 uint16_t liu = le16_to_cpu(cfi->lengthOfImpUse); 51 uint16_t liu = le16_to_cpu(cfi->lengthOfImpUse);
54 uint8_t lfi = cfi->lengthFileIdent; 52 uint8_t lfi = cfi->lengthFileIdent;
@@ -122,13 +120,8 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi,
122 120
123 cfi->descTag.descCRC = cpu_to_le16(crc); 121 cfi->descTag.descCRC = cpu_to_le16(crc);
124 cfi->descTag.descCRCLength = cpu_to_le16(crclen); 122 cfi->descTag.descCRCLength = cpu_to_le16(crclen);
123 cfi->descTag.tagChecksum = udf_tag_checksum(&cfi->descTag);
125 124
126 for (i = 0; i < 16; i++) {
127 if (i != 4)
128 checksum += ((uint8_t *)&cfi->descTag)[i];
129 }
130
131 cfi->descTag.tagChecksum = checksum;
132 if (adinicb || (sizeof(struct fileIdentDesc) <= -fibh->soffset)) { 125 if (adinicb || (sizeof(struct fileIdentDesc) <= -fibh->soffset)) {
133 memcpy((uint8_t *)sfi, (uint8_t *)cfi, 126 memcpy((uint8_t *)sfi, (uint8_t *)cfi,
134 sizeof(struct fileIdentDesc)); 127 sizeof(struct fileIdentDesc));
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 7f75a949e152..12fb91d23a83 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1564,7 +1564,6 @@ static void udf_open_lvid(struct super_block *sb)
1564 struct udf_sb_info *sbi = UDF_SB(sb); 1564 struct udf_sb_info *sbi = UDF_SB(sb);
1565 struct buffer_head *bh = sbi->s_lvid_bh; 1565 struct buffer_head *bh = sbi->s_lvid_bh;
1566 if (bh) { 1566 if (bh) {
1567 int i;
1568 kernel_timestamp cpu_time; 1567 kernel_timestamp cpu_time;
1569 struct logicalVolIntegrityDesc *lvid = 1568 struct logicalVolIntegrityDesc *lvid =
1570 (struct logicalVolIntegrityDesc *)bh->b_data; 1569 (struct logicalVolIntegrityDesc *)bh->b_data;
@@ -1582,12 +1581,7 @@ static void udf_open_lvid(struct super_block *sb)
1582 le16_to_cpu(lvid->descTag.descCRCLength), 1581 le16_to_cpu(lvid->descTag.descCRCLength),
1583 0)); 1582 0));
1584 1583
1585 lvid->descTag.tagChecksum = 0; 1584 lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag);
1586 for (i = 0; i < 16; i++)
1587 if (i != 4)
1588 lvid->descTag.tagChecksum +=
1589 ((uint8_t *) &(lvid->descTag))[i];
1590
1591 mark_buffer_dirty(bh); 1585 mark_buffer_dirty(bh);
1592 } 1586 }
1593} 1587}
@@ -1595,7 +1589,6 @@ static void udf_open_lvid(struct super_block *sb)
1595static void udf_close_lvid(struct super_block *sb) 1589static void udf_close_lvid(struct super_block *sb)
1596{ 1590{
1597 kernel_timestamp cpu_time; 1591 kernel_timestamp cpu_time;
1598 int i;
1599 struct udf_sb_info *sbi = UDF_SB(sb); 1592 struct udf_sb_info *sbi = UDF_SB(sb);
1600 struct buffer_head *bh = sbi->s_lvid_bh; 1593 struct buffer_head *bh = sbi->s_lvid_bh;
1601 struct logicalVolIntegrityDesc *lvid; 1594 struct logicalVolIntegrityDesc *lvid;
@@ -1626,12 +1619,7 @@ static void udf_close_lvid(struct super_block *sb)
1626 le16_to_cpu(lvid->descTag.descCRCLength), 1619 le16_to_cpu(lvid->descTag.descCRCLength),
1627 0)); 1620 0));
1628 1621
1629 lvid->descTag.tagChecksum = 0; 1622 lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag);
1630 for (i = 0; i < 16; i++)
1631 if (i != 4)
1632 lvid->descTag.tagChecksum +=
1633 ((uint8_t *)&(lvid->descTag))[i];
1634
1635 mark_buffer_dirty(bh); 1623 mark_buffer_dirty(bh);
1636 } 1624 }
1637} 1625}
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index c8016cc9e7e6..bed0a0251389 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -36,6 +36,9 @@
36 36
37#define udf_get_lb_pblock(sb,loc,offset) udf_get_pblock((sb), (loc).logicalBlockNum, (loc).partitionReferenceNum, (offset)) 37#define udf_get_lb_pblock(sb,loc,offset) udf_get_pblock((sb), (loc).logicalBlockNum, (loc).partitionReferenceNum, (offset))
38 38
39/* computes tag checksum */
40u8 udf_tag_checksum(const tag *t);
41
39struct dentry; 42struct dentry;
40struct inode; 43struct inode;
41struct task_struct; 44struct task_struct;