diff options
author | Jan Kara <jack@suse.cz> | 2009-03-19 11:21:38 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2009-04-02 06:29:56 -0400 |
commit | 40346005166329bc4b53e0c564aff3968c1ddaa0 (patch) | |
tree | af6440a2aeff69ed6cccd93c663eb564e7cf6411 /fs/udf/super.c | |
parent | 225feded89d447c2ab76e38e67ef56860c5bb60f (diff) |
udf: Try anchor in block 256 first
Anchor block can be located at several places on the medium. Two of the
locations are relative to media end which is problematic to detect. Also
some drives report some block as last but are not able to read it or any
block nearby before it. So let's first try block 256 and if it is all fine,
don't look at other possible locations of anchor blocks to avoid IO errors.
This change required a larger reorganization of code but the new code is
hopefully more readable and definitely shorter.
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf/super.c')
-rw-r--r-- | fs/udf/super.c | 432 |
1 files changed, 185 insertions, 247 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c index f4ef5560675f..cae079eb5dd9 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
@@ -289,14 +289,8 @@ static int udf_show_options(struct seq_file *seq, struct vfsmount *mnt) | |||
289 | seq_printf(seq, ",session=%u", sbi->s_session); | 289 | seq_printf(seq, ",session=%u", sbi->s_session); |
290 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_LASTBLOCK_SET)) | 290 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_LASTBLOCK_SET)) |
291 | seq_printf(seq, ",lastblock=%u", sbi->s_last_block); | 291 | seq_printf(seq, ",lastblock=%u", sbi->s_last_block); |
292 | /* | 292 | if (sbi->s_anchor != 0) |
293 | * s_anchor[2] could be zeroed out in case there is no anchor | 293 | seq_printf(seq, ",anchor=%u", sbi->s_anchor); |
294 | * in the specified block, but then the "anchor=N" option | ||
295 | * originally given by the user wasn't effective, so it's OK | ||
296 | * if we don't show it. | ||
297 | */ | ||
298 | if (sbi->s_anchor[2] != 0) | ||
299 | seq_printf(seq, ",anchor=%u", sbi->s_anchor[2]); | ||
300 | /* | 294 | /* |
301 | * volume, partition, fileset and rootdir seem to be ignored | 295 | * volume, partition, fileset and rootdir seem to be ignored |
302 | * currently | 296 | * currently |
@@ -608,22 +602,19 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options) | |||
608 | return 0; | 602 | return 0; |
609 | } | 603 | } |
610 | 604 | ||
611 | static loff_t udf_vrs(struct super_block *sb, int silent) | 605 | /* Check Volume Structure Descriptors (ECMA 167 2/9.1) */ |
606 | /* We also check any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */ | ||
607 | static loff_t udf_check_vsd(struct super_block *sb) | ||
612 | { | 608 | { |
613 | struct volStructDesc *vsd = NULL; | 609 | struct volStructDesc *vsd = NULL; |
614 | loff_t sector = 32768; | 610 | loff_t sector = 32768; |
615 | int sectorsize; | 611 | int sectorsize; |
616 | struct buffer_head *bh = NULL; | 612 | struct buffer_head *bh = NULL; |
617 | int iso9660 = 0; | ||
618 | int nsr02 = 0; | 613 | int nsr02 = 0; |
619 | int nsr03 = 0; | 614 | int nsr03 = 0; |
620 | struct udf_sb_info *sbi; | 615 | struct udf_sb_info *sbi; |
621 | 616 | ||
622 | /* Block size must be a multiple of 512 */ | ||
623 | if (sb->s_blocksize & 511) | ||
624 | return 0; | ||
625 | sbi = UDF_SB(sb); | 617 | sbi = UDF_SB(sb); |
626 | |||
627 | if (sb->s_blocksize < sizeof(struct volStructDesc)) | 618 | if (sb->s_blocksize < sizeof(struct volStructDesc)) |
628 | sectorsize = sizeof(struct volStructDesc); | 619 | sectorsize = sizeof(struct volStructDesc); |
629 | else | 620 | else |
@@ -650,7 +641,6 @@ static loff_t udf_vrs(struct super_block *sb, int silent) | |||
650 | break; | 641 | break; |
651 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_CD001, | 642 | } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_CD001, |
652 | VSD_STD_ID_LEN)) { | 643 | VSD_STD_ID_LEN)) { |
653 | iso9660 = sector; | ||
654 | switch (vsd->structType) { | 644 | switch (vsd->structType) { |
655 | case 0: | 645 | case 0: |
656 | udf_debug("ISO9660 Boot Record found\n"); | 646 | udf_debug("ISO9660 Boot Record found\n"); |
@@ -702,143 +692,6 @@ static loff_t udf_vrs(struct super_block *sb, int silent) | |||
702 | return 0; | 692 | return 0; |
703 | } | 693 | } |
704 | 694 | ||
705 | /* | ||
706 | * Check whether there is an anchor block in the given block | ||
707 | */ | ||
708 | static int udf_check_anchor_block(struct super_block *sb, sector_t block) | ||
709 | { | ||
710 | struct buffer_head *bh; | ||
711 | uint16_t ident; | ||
712 | |||
713 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_VARCONV) && | ||
714 | udf_fixed_to_variable(block) >= | ||
715 | sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits) | ||
716 | return 0; | ||
717 | |||
718 | bh = udf_read_tagged(sb, block, block, &ident); | ||
719 | if (!bh) | ||
720 | return 0; | ||
721 | brelse(bh); | ||
722 | |||
723 | return ident == TAG_IDENT_AVDP; | ||
724 | } | ||
725 | |||
726 | /* Search for an anchor volume descriptor pointer */ | ||
727 | static sector_t udf_scan_anchors(struct super_block *sb, sector_t lastblock) | ||
728 | { | ||
729 | sector_t last[6]; | ||
730 | int i; | ||
731 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
732 | int last_count = 0; | ||
733 | |||
734 | last[last_count++] = lastblock; | ||
735 | if (lastblock >= 1) | ||
736 | last[last_count++] = lastblock - 1; | ||
737 | last[last_count++] = lastblock + 1; | ||
738 | if (lastblock >= 2) | ||
739 | last[last_count++] = lastblock - 2; | ||
740 | if (lastblock >= 150) | ||
741 | last[last_count++] = lastblock - 150; | ||
742 | if (lastblock >= 152) | ||
743 | last[last_count++] = lastblock - 152; | ||
744 | |||
745 | /* according to spec, anchor is in either: | ||
746 | * block 256 | ||
747 | * lastblock-256 | ||
748 | * lastblock | ||
749 | * however, if the disc isn't closed, it could be 512 */ | ||
750 | |||
751 | for (i = 0; i < last_count; i++) { | ||
752 | if (last[i] >= sb->s_bdev->bd_inode->i_size >> | ||
753 | sb->s_blocksize_bits) | ||
754 | continue; | ||
755 | |||
756 | if (udf_check_anchor_block(sb, last[i])) { | ||
757 | sbi->s_anchor[0] = last[i]; | ||
758 | sbi->s_anchor[1] = last[i] - 256; | ||
759 | return last[i]; | ||
760 | } | ||
761 | |||
762 | if (last[i] < 256) | ||
763 | continue; | ||
764 | |||
765 | if (udf_check_anchor_block(sb, last[i] - 256)) { | ||
766 | sbi->s_anchor[1] = last[i] - 256; | ||
767 | return last[i]; | ||
768 | } | ||
769 | } | ||
770 | |||
771 | if (udf_check_anchor_block(sb, sbi->s_session + 256)) { | ||
772 | sbi->s_anchor[0] = sbi->s_session + 256; | ||
773 | return last[0]; | ||
774 | } | ||
775 | if (udf_check_anchor_block(sb, sbi->s_session + 512)) { | ||
776 | sbi->s_anchor[0] = sbi->s_session + 512; | ||
777 | return last[0]; | ||
778 | } | ||
779 | return 0; | ||
780 | } | ||
781 | |||
782 | /* | ||
783 | * Find an anchor volume descriptor. The function expects sbi->s_lastblock to | ||
784 | * be the last block on the media. | ||
785 | * | ||
786 | * Return 1 if not found, 0 if ok | ||
787 | * | ||
788 | */ | ||
789 | static int udf_find_anchor(struct super_block *sb) | ||
790 | { | ||
791 | sector_t lastblock; | ||
792 | struct buffer_head *bh = NULL; | ||
793 | uint16_t ident; | ||
794 | int i; | ||
795 | int anchor_found = 0; | ||
796 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
797 | |||
798 | lastblock = udf_scan_anchors(sb, sbi->s_last_block); | ||
799 | if (lastblock) | ||
800 | goto check_anchor; | ||
801 | |||
802 | /* No anchor found? Try VARCONV conversion of block numbers */ | ||
803 | UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); | ||
804 | /* Firstly, we try to not convert number of the last block */ | ||
805 | lastblock = udf_scan_anchors(sb, | ||
806 | udf_variable_to_fixed(sbi->s_last_block)); | ||
807 | if (lastblock) | ||
808 | goto check_anchor; | ||
809 | |||
810 | /* Secondly, we try with converted number of the last block */ | ||
811 | lastblock = udf_scan_anchors(sb, sbi->s_last_block); | ||
812 | if (!lastblock) { | ||
813 | /* VARCONV didn't help. Clear it. */ | ||
814 | UDF_CLEAR_FLAG(sb, UDF_FLAG_VARCONV); | ||
815 | } | ||
816 | |||
817 | check_anchor: | ||
818 | /* | ||
819 | * Check located anchors and the anchor block supplied via | ||
820 | * mount options | ||
821 | */ | ||
822 | for (i = 0; i < ARRAY_SIZE(sbi->s_anchor); i++) { | ||
823 | if (!sbi->s_anchor[i]) | ||
824 | continue; | ||
825 | bh = udf_read_tagged(sb, sbi->s_anchor[i], | ||
826 | sbi->s_anchor[i], &ident); | ||
827 | if (!bh) | ||
828 | sbi->s_anchor[i] = 0; | ||
829 | else { | ||
830 | brelse(bh); | ||
831 | if (ident != TAG_IDENT_AVDP) | ||
832 | sbi->s_anchor[i] = 0; | ||
833 | else | ||
834 | anchor_found = 1; | ||
835 | } | ||
836 | } | ||
837 | |||
838 | sbi->s_last_block = lastblock; | ||
839 | return anchor_found; | ||
840 | } | ||
841 | |||
842 | static int udf_find_fileset(struct super_block *sb, | 695 | static int udf_find_fileset(struct super_block *sb, |
843 | struct kernel_lb_addr *fileset, | 696 | struct kernel_lb_addr *fileset, |
844 | struct kernel_lb_addr *root) | 697 | struct kernel_lb_addr *root) |
@@ -1699,111 +1552,199 @@ static noinline int udf_process_sequence(struct super_block *sb, long block, | |||
1699 | return 0; | 1552 | return 0; |
1700 | } | 1553 | } |
1701 | 1554 | ||
1702 | /* | 1555 | static int udf_load_sequence(struct super_block *sb, struct buffer_head *bh, |
1703 | * udf_check_valid() | 1556 | struct kernel_lb_addr *fileset) |
1704 | */ | ||
1705 | static int udf_check_valid(struct super_block *sb, int novrs, int silent) | ||
1706 | { | 1557 | { |
1707 | loff_t block; | 1558 | struct anchorVolDescPtr *anchor; |
1708 | struct udf_sb_info *sbi = UDF_SB(sb); | 1559 | long main_s, main_e, reserve_s, reserve_e; |
1560 | struct udf_sb_info *sbi; | ||
1709 | 1561 | ||
1710 | if (novrs) { | 1562 | sbi = UDF_SB(sb); |
1711 | udf_debug("Validity check skipped because of novrs option\n"); | 1563 | anchor = (struct anchorVolDescPtr *)bh->b_data; |
1712 | return 0; | 1564 | |
1713 | } | 1565 | /* Locate the main sequence */ |
1714 | /* Check that it is NSR02 compliant */ | 1566 | main_s = le32_to_cpu(anchor->mainVolDescSeqExt.extLocation); |
1715 | /* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */ | 1567 | main_e = le32_to_cpu(anchor->mainVolDescSeqExt.extLength); |
1716 | block = udf_vrs(sb, silent); | 1568 | main_e = main_e >> sb->s_blocksize_bits; |
1717 | if (block == -1) | 1569 | main_e += main_s; |
1718 | udf_debug("Failed to read byte 32768. Assuming open " | 1570 | |
1719 | "disc. Skipping validity check\n"); | 1571 | /* Locate the reserve sequence */ |
1720 | if (block && !sbi->s_last_block) | 1572 | reserve_s = le32_to_cpu(anchor->reserveVolDescSeqExt.extLocation); |
1721 | sbi->s_last_block = udf_get_last_block(sb); | 1573 | reserve_e = le32_to_cpu(anchor->reserveVolDescSeqExt.extLength); |
1722 | return !!block; | 1574 | reserve_e = reserve_e >> sb->s_blocksize_bits; |
1575 | reserve_e += reserve_s; | ||
1576 | |||
1577 | /* Process the main & reserve sequences */ | ||
1578 | /* responsible for finding the PartitionDesc(s) */ | ||
1579 | if (!udf_process_sequence(sb, main_s, main_e, fileset)) | ||
1580 | return 1; | ||
1581 | return !udf_process_sequence(sb, reserve_s, reserve_e, fileset); | ||
1723 | } | 1582 | } |
1724 | 1583 | ||
1725 | static int udf_check_volume(struct super_block *sb, | 1584 | /* |
1726 | struct udf_options *uopt, int silent) | 1585 | * Check whether there is an anchor block in the given block and |
1586 | * load Volume Descriptor Sequence if so. | ||
1587 | */ | ||
1588 | static int udf_check_anchor_block(struct super_block *sb, sector_t block, | ||
1589 | struct kernel_lb_addr *fileset) | ||
1727 | { | 1590 | { |
1728 | struct udf_sb_info *sbi = UDF_SB(sb); | 1591 | struct buffer_head *bh; |
1592 | uint16_t ident; | ||
1593 | int ret; | ||
1729 | 1594 | ||
1730 | if (!sb_set_blocksize(sb, uopt->blocksize)) { | 1595 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_VARCONV) && |
1731 | if (!silent) | 1596 | udf_fixed_to_variable(block) >= |
1732 | printk(KERN_WARNING "UDF-fs: Bad block size\n"); | 1597 | sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits) |
1733 | return 0; | 1598 | return 0; |
1734 | } | 1599 | |
1735 | sbi->s_last_block = uopt->lastblock; | 1600 | bh = udf_read_tagged(sb, block, block, &ident); |
1736 | if (!udf_check_valid(sb, uopt->novrs, silent)) { | 1601 | if (!bh) |
1737 | if (!silent) | ||
1738 | printk(KERN_WARNING "UDF-fs: No VRS found\n"); | ||
1739 | return 0; | 1602 | return 0; |
1740 | } | 1603 | if (ident != TAG_IDENT_AVDP) { |
1741 | sbi->s_anchor[0] = sbi->s_anchor[1] = 0; | 1604 | brelse(bh); |
1742 | sbi->s_anchor[2] = uopt->anchor; | ||
1743 | if (!udf_find_anchor(sb)) { | ||
1744 | if (!silent) | ||
1745 | printk(KERN_WARNING "UDF-fs: No anchor found\n"); | ||
1746 | return 0; | 1605 | return 0; |
1747 | } | 1606 | } |
1748 | return 1; | 1607 | ret = udf_load_sequence(sb, bh, fileset); |
1608 | brelse(bh); | ||
1609 | return ret; | ||
1749 | } | 1610 | } |
1750 | 1611 | ||
1751 | static int udf_load_sequence(struct super_block *sb, struct kernel_lb_addr *fileset) | 1612 | /* Search for an anchor volume descriptor pointer */ |
1613 | static sector_t udf_scan_anchors(struct super_block *sb, sector_t lastblock, | ||
1614 | struct kernel_lb_addr *fileset) | ||
1752 | { | 1615 | { |
1753 | struct anchorVolDescPtr *anchor; | 1616 | sector_t last[6]; |
1754 | uint16_t ident; | ||
1755 | struct buffer_head *bh; | ||
1756 | long main_s, main_e, reserve_s, reserve_e; | ||
1757 | int i; | 1617 | int i; |
1758 | struct udf_sb_info *sbi; | 1618 | struct udf_sb_info *sbi = UDF_SB(sb); |
1619 | int last_count = 0; | ||
1759 | 1620 | ||
1760 | if (!sb) | 1621 | /* First try user provided anchor */ |
1761 | return 1; | 1622 | if (sbi->s_anchor) { |
1762 | sbi = UDF_SB(sb); | 1623 | if (udf_check_anchor_block(sb, sbi->s_anchor, fileset)) |
1624 | return lastblock; | ||
1625 | } | ||
1626 | /* | ||
1627 | * according to spec, anchor is in either: | ||
1628 | * block 256 | ||
1629 | * lastblock-256 | ||
1630 | * lastblock | ||
1631 | * however, if the disc isn't closed, it could be 512. | ||
1632 | */ | ||
1633 | if (udf_check_anchor_block(sb, sbi->s_session + 256, fileset)) | ||
1634 | return lastblock; | ||
1635 | /* | ||
1636 | * The trouble is which block is the last one. Drives often misreport | ||
1637 | * this so we try various possibilities. | ||
1638 | */ | ||
1639 | last[last_count++] = lastblock; | ||
1640 | if (lastblock >= 1) | ||
1641 | last[last_count++] = lastblock - 1; | ||
1642 | last[last_count++] = lastblock + 1; | ||
1643 | if (lastblock >= 2) | ||
1644 | last[last_count++] = lastblock - 2; | ||
1645 | if (lastblock >= 150) | ||
1646 | last[last_count++] = lastblock - 150; | ||
1647 | if (lastblock >= 152) | ||
1648 | last[last_count++] = lastblock - 152; | ||
1763 | 1649 | ||
1764 | for (i = 0; i < ARRAY_SIZE(sbi->s_anchor); i++) { | 1650 | for (i = 0; i < last_count; i++) { |
1765 | if (!sbi->s_anchor[i]) | 1651 | if (last[i] >= sb->s_bdev->bd_inode->i_size >> |
1652 | sb->s_blocksize_bits) | ||
1766 | continue; | 1653 | continue; |
1767 | 1654 | if (udf_check_anchor_block(sb, last[i], fileset)) | |
1768 | bh = udf_read_tagged(sb, sbi->s_anchor[i], sbi->s_anchor[i], | 1655 | return last[i]; |
1769 | &ident); | 1656 | if (last[i] < 256) |
1770 | if (!bh) | ||
1771 | continue; | 1657 | continue; |
1658 | if (udf_check_anchor_block(sb, last[i] - 256, fileset)) | ||
1659 | return last[i]; | ||
1660 | } | ||
1772 | 1661 | ||
1773 | anchor = (struct anchorVolDescPtr *)bh->b_data; | 1662 | /* Finally try block 512 in case media is open */ |
1663 | if (udf_check_anchor_block(sb, sbi->s_session + 512, fileset)) | ||
1664 | return last[0]; | ||
1665 | return 0; | ||
1666 | } | ||
1774 | 1667 | ||
1775 | /* Locate the main sequence */ | 1668 | /* |
1776 | main_s = le32_to_cpu(anchor->mainVolDescSeqExt.extLocation); | 1669 | * Find an anchor volume descriptor and load Volume Descriptor Sequence from |
1777 | main_e = le32_to_cpu(anchor->mainVolDescSeqExt.extLength); | 1670 | * area specified by it. The function expects sbi->s_lastblock to be the last |
1778 | main_e = main_e >> sb->s_blocksize_bits; | 1671 | * block on the media. |
1779 | main_e += main_s; | 1672 | * |
1673 | * Return 1 if ok, 0 if not found. | ||
1674 | * | ||
1675 | */ | ||
1676 | static int udf_find_anchor(struct super_block *sb, | ||
1677 | struct kernel_lb_addr *fileset) | ||
1678 | { | ||
1679 | sector_t lastblock; | ||
1680 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
1780 | 1681 | ||
1781 | /* Locate the reserve sequence */ | 1682 | lastblock = udf_scan_anchors(sb, sbi->s_last_block, fileset); |
1782 | reserve_s = le32_to_cpu( | 1683 | if (lastblock) |
1783 | anchor->reserveVolDescSeqExt.extLocation); | 1684 | goto out; |
1784 | reserve_e = le32_to_cpu( | ||
1785 | anchor->reserveVolDescSeqExt.extLength); | ||
1786 | reserve_e = reserve_e >> sb->s_blocksize_bits; | ||
1787 | reserve_e += reserve_s; | ||
1788 | 1685 | ||
1789 | brelse(bh); | 1686 | /* No anchor found? Try VARCONV conversion of block numbers */ |
1687 | UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); | ||
1688 | /* Firstly, we try to not convert number of the last block */ | ||
1689 | lastblock = udf_scan_anchors(sb, | ||
1690 | udf_variable_to_fixed(sbi->s_last_block), | ||
1691 | fileset); | ||
1692 | if (lastblock) | ||
1693 | goto out; | ||
1790 | 1694 | ||
1791 | /* Process the main & reserve sequences */ | 1695 | /* Secondly, we try with converted number of the last block */ |
1792 | /* responsible for finding the PartitionDesc(s) */ | 1696 | lastblock = udf_scan_anchors(sb, sbi->s_last_block, fileset); |
1793 | if (!(udf_process_sequence(sb, main_s, main_e, | 1697 | if (!lastblock) { |
1794 | fileset) && | 1698 | /* VARCONV didn't help. Clear it. */ |
1795 | udf_process_sequence(sb, reserve_s, reserve_e, | 1699 | UDF_CLEAR_FLAG(sb, UDF_FLAG_VARCONV); |
1796 | fileset))) | 1700 | return 0; |
1797 | break; | ||
1798 | } | 1701 | } |
1702 | out: | ||
1703 | sbi->s_last_block = lastblock; | ||
1704 | return 1; | ||
1705 | } | ||
1799 | 1706 | ||
1800 | if (i == ARRAY_SIZE(sbi->s_anchor)) { | 1707 | /* |
1801 | udf_debug("No Anchor block found\n"); | 1708 | * Check Volume Structure Descriptor, find Anchor block and load Volume |
1802 | return 1; | 1709 | * Descriptor Sequence |
1710 | */ | ||
1711 | static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt, | ||
1712 | int silent, struct kernel_lb_addr *fileset) | ||
1713 | { | ||
1714 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
1715 | loff_t nsr_off; | ||
1716 | |||
1717 | if (!sb_set_blocksize(sb, uopt->blocksize)) { | ||
1718 | if (!silent) | ||
1719 | printk(KERN_WARNING "UDF-fs: Bad block size\n"); | ||
1720 | return 0; | ||
1721 | } | ||
1722 | sbi->s_last_block = uopt->lastblock; | ||
1723 | if (!uopt->novrs) { | ||
1724 | /* Check that it is NSR02 compliant */ | ||
1725 | nsr_off = udf_check_vsd(sb); | ||
1726 | if (!nsr_off) { | ||
1727 | if (!silent) | ||
1728 | printk(KERN_WARNING "UDF-fs: No VRS found\n"); | ||
1729 | return 0; | ||
1730 | } | ||
1731 | if (nsr_off == -1) | ||
1732 | udf_debug("Failed to read byte 32768. Assuming open " | ||
1733 | "disc. Skipping validity check\n"); | ||
1734 | if (!sbi->s_last_block) | ||
1735 | sbi->s_last_block = udf_get_last_block(sb); | ||
1736 | } else { | ||
1737 | udf_debug("Validity check skipped because of novrs option\n"); | ||
1803 | } | 1738 | } |
1804 | udf_debug("Using anchor in block %d\n", sbi->s_anchor[i]); | ||
1805 | 1739 | ||
1806 | return 0; | 1740 | /* Look for anchor block and load Volume Descriptor Sequence */ |
1741 | sbi->s_anchor = uopt->anchor; | ||
1742 | if (!udf_find_anchor(sb, fileset)) { | ||
1743 | if (!silent) | ||
1744 | printk(KERN_WARNING "UDF-fs: No anchor found\n"); | ||
1745 | return 0; | ||
1746 | } | ||
1747 | return 1; | ||
1807 | } | 1748 | } |
1808 | 1749 | ||
1809 | static void udf_open_lvid(struct super_block *sb) | 1750 | static void udf_open_lvid(struct super_block *sb) |
@@ -1916,7 +1857,7 @@ static void udf_free_partition(struct udf_part_map *map) | |||
1916 | static int udf_fill_super(struct super_block *sb, void *options, int silent) | 1857 | static int udf_fill_super(struct super_block *sb, void *options, int silent) |
1917 | { | 1858 | { |
1918 | int i; | 1859 | int i; |
1919 | int found_anchor; | 1860 | int ret; |
1920 | struct inode *inode = NULL; | 1861 | struct inode *inode = NULL; |
1921 | struct udf_options uopt; | 1862 | struct udf_options uopt; |
1922 | struct kernel_lb_addr rootdir, fileset; | 1863 | struct kernel_lb_addr rootdir, fileset; |
@@ -1976,32 +1917,29 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1976 | 1917 | ||
1977 | udf_debug("Multi-session=%d\n", sbi->s_session); | 1918 | udf_debug("Multi-session=%d\n", sbi->s_session); |
1978 | 1919 | ||
1920 | /* Fill in the rest of the superblock */ | ||
1921 | sb->s_op = &udf_sb_ops; | ||
1922 | sb->s_export_op = &udf_export_ops; | ||
1923 | sb->dq_op = NULL; | ||
1924 | sb->s_dirt = 0; | ||
1925 | sb->s_magic = UDF_SUPER_MAGIC; | ||
1926 | sb->s_time_gran = 1000; | ||
1927 | |||
1979 | if (uopt.flags & (1 << UDF_FLAG_BLOCKSIZE_SET)) { | 1928 | if (uopt.flags & (1 << UDF_FLAG_BLOCKSIZE_SET)) { |
1980 | found_anchor = udf_check_volume(sb, &uopt, silent); | 1929 | ret = udf_load_vrs(sb, &uopt, silent, &fileset); |
1981 | } else { | 1930 | } else { |
1982 | uopt.blocksize = bdev_hardsect_size(sb->s_bdev); | 1931 | uopt.blocksize = bdev_hardsect_size(sb->s_bdev); |
1983 | found_anchor = udf_check_volume(sb, &uopt, silent); | 1932 | ret = udf_load_vrs(sb, &uopt, silent, &fileset); |
1984 | if (!found_anchor && uopt.blocksize != UDF_DEFAULT_BLOCKSIZE) { | 1933 | if (!ret && uopt.blocksize != UDF_DEFAULT_BLOCKSIZE) { |
1985 | if (!silent) | 1934 | if (!silent) |
1986 | printk(KERN_NOTICE | 1935 | printk(KERN_NOTICE |
1987 | "UDF-fs: Rescanning with blocksize " | 1936 | "UDF-fs: Rescanning with blocksize " |
1988 | "%d\n", UDF_DEFAULT_BLOCKSIZE); | 1937 | "%d\n", UDF_DEFAULT_BLOCKSIZE); |
1989 | uopt.blocksize = UDF_DEFAULT_BLOCKSIZE; | 1938 | uopt.blocksize = UDF_DEFAULT_BLOCKSIZE; |
1990 | found_anchor = udf_check_volume(sb, &uopt, silent); | 1939 | ret = udf_load_vrs(sb, &uopt, silent, &fileset); |
1991 | } | 1940 | } |
1992 | } | 1941 | } |
1993 | if (!found_anchor) | 1942 | if (!ret) { |
1994 | goto error_out; | ||
1995 | |||
1996 | /* Fill in the rest of the superblock */ | ||
1997 | sb->s_op = &udf_sb_ops; | ||
1998 | sb->s_export_op = &udf_export_ops; | ||
1999 | sb->dq_op = NULL; | ||
2000 | sb->s_dirt = 0; | ||
2001 | sb->s_magic = UDF_SUPER_MAGIC; | ||
2002 | sb->s_time_gran = 1000; | ||
2003 | |||
2004 | if (udf_load_sequence(sb, &fileset)) { | ||
2005 | printk(KERN_WARNING "UDF-fs: No partition found (1)\n"); | 1943 | printk(KERN_WARNING "UDF-fs: No partition found (1)\n"); |
2006 | goto error_out; | 1944 | goto error_out; |
2007 | } | 1945 | } |