Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for_v5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs

Pull ext2, quota, udf fixes and cleanups from Jan Kara:

- two small quota fixes (in grace time handling and possible missed
accounting of preallocated blocks beyond EOF).

- some ext2 cleanups

- udf fixes for better compatibility with Windows 10 generated media
(named streams, write-protection using domain-identifier, placement
of volume recognition sequence)

- some udf cleanups

* tag 'for_v5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
quota: fix wrong condition in is_quota_modification()
fs-udf: Delete an unnecessary check before brelse()
ext2: Delete an unnecessary check before brelse()
udf: Drop forward function declarations
udf: Verify domain identifier fields
udf: augment UDF permissions on new inodes
udf: Use dynamic debug infrastructure
udf: reduce leakage of blocks related to named streams
udf: prevent allocation beyond UDF partition
quota: fix condition for resetting time limit in do_set_dqblk()
ext2: code cleanup for ext2_free_blocks()
ext2: fix block range in ext2_data_block_valid()
udf: support 2048-byte spacing of VRS descriptors on 4K media
udf: refactor VRS descriptor identification

+249 -136
+4 -6
fs/ext2/balloc.c
··· 490 490 struct ext2_super_block * es = sbi->s_es; 491 491 unsigned freed = 0, group_freed; 492 492 493 - if (block < le32_to_cpu(es->s_first_data_block) || 494 - block + count < block || 495 - block + count > le32_to_cpu(es->s_blocks_count)) { 493 + if (!ext2_data_block_valid(sbi, block, count)) { 496 494 ext2_error (sb, "ext2_free_blocks", 497 495 "Freeing blocks not in datazone - " 498 496 "block = %lu, count = %lu", block, count); ··· 1201 1203 unsigned int count) 1202 1204 { 1203 1205 if ((start_blk <= le32_to_cpu(sbi->s_es->s_first_data_block)) || 1204 - (start_blk + count < start_blk) || 1205 - (start_blk > le32_to_cpu(sbi->s_es->s_blocks_count))) 1206 + (start_blk + count - 1 < start_blk) || 1207 + (start_blk + count - 1 >= le32_to_cpu(sbi->s_es->s_blocks_count))) 1206 1208 return 0; 1207 1209 1208 1210 /* Ensure we do not step over superblock */ 1209 1211 if ((start_blk <= sbi->s_sb_block) && 1210 - (start_blk + count >= sbi->s_sb_block)) 1212 + (start_blk + count - 1 >= sbi->s_sb_block)) 1211 1213 return 0; 1212 1214 1213 1215 return 1;
+1 -2
fs/ext2/super.c
··· 162 162 } 163 163 db_count = sbi->s_gdb_count; 164 164 for (i = 0; i < db_count; i++) 165 - if (sbi->s_group_desc[i]) 166 - brelse (sbi->s_group_desc[i]); 165 + brelse(sbi->s_group_desc[i]); 167 166 kfree(sbi->s_group_desc); 168 167 kfree(sbi->s_debts); 169 168 percpu_counter_destroy(&sbi->s_freeblocks_counter);
+1 -1
fs/ext2/xattr.c
··· 794 794 if (!EXT2_I(inode)->i_file_acl) 795 795 goto cleanup; 796 796 797 - if (!ext2_data_block_valid(sbi, EXT2_I(inode)->i_file_acl, 0)) { 797 + if (!ext2_data_block_valid(sbi, EXT2_I(inode)->i_file_acl, 1)) { 798 798 ext2_error(inode->i_sb, "ext2_xattr_delete_inode", 799 799 "inode %ld: xattr block %d is out of data blocks range", 800 800 inode->i_ino, EXT2_I(inode)->i_file_acl);
+2 -2
fs/quota/dquot.c
··· 2731 2731 2732 2732 if (check_blim) { 2733 2733 if (!dm->dqb_bsoftlimit || 2734 - dm->dqb_curspace + dm->dqb_rsvspace < dm->dqb_bsoftlimit) { 2734 + dm->dqb_curspace + dm->dqb_rsvspace <= dm->dqb_bsoftlimit) { 2735 2735 dm->dqb_btime = 0; 2736 2736 clear_bit(DQ_BLKS_B, &dquot->dq_flags); 2737 2737 } else if (!(di->d_fieldmask & QC_SPC_TIMER)) ··· 2740 2740 } 2741 2741 if (check_ilim) { 2742 2742 if (!dm->dqb_isoftlimit || 2743 - dm->dqb_curinodes < dm->dqb_isoftlimit) { 2743 + dm->dqb_curinodes <= dm->dqb_isoftlimit) { 2744 2744 dm->dqb_itime = 0; 2745 2745 clear_bit(DQ_INODES_B, &dquot->dq_flags); 2746 2746 } else if (!(di->d_fieldmask & QC_INO_TIMER))
+11
fs/udf/balloc.c
··· 325 325 newblock = bit + (block_group << (sb->s_blocksize_bits + 3)) - 326 326 (sizeof(struct spaceBitmapDesc) << 3); 327 327 328 + if (newblock >= sbi->s_partmaps[partition].s_partition_len) { 329 + /* 330 + * Ran off the end of the bitmap, and bits following are 331 + * non-compliant (not all zero) 332 + */ 333 + udf_err(sb, "bitmap for partition %d corrupted (block %u marked" 334 + " as free, partition length is %u)\n", partition, 335 + newblock, sbi->s_partmaps[partition].s_partition_len); 336 + goto error_return; 337 + } 338 + 328 339 if (!udf_clear_bit(bit, bh->b_data)) { 329 340 udf_debug("bit already cleared for block %d\n", bit); 330 341 goto repeat;
+14
fs/udf/ecma_167.h
··· 88 88 #define ENTITYID_FLAGS_DIRTY 0x00 89 89 #define ENTITYID_FLAGS_PROTECTED 0x01 90 90 91 + /* OSTA UDF 2.1.5.2 */ 92 + #define UDF_ID_COMPLIANT "*OSTA UDF Compliant" 93 + 94 + /* OSTA UDF 2.1.5.3 */ 95 + struct domainEntityIDSuffix { 96 + uint16_t revision; 97 + uint8_t flags; 98 + uint8_t reserved[5]; 99 + }; 100 + 101 + /* OSTA UDF 2.1.5.3 */ 102 + #define ENTITYIDSUFFIX_FLAGS_HARDWRITEPROTECT 0 103 + #define ENTITYIDSUFFIX_FLAGS_SOFTWRITEPROTECT 1 104 + 91 105 /* Volume Structure Descriptor (ECMA 167r3 2/9.1) */ 92 106 #define VSD_STD_ID_LEN 5 93 107 struct volStructDesc {
+3
fs/udf/file.c
··· 280 280 return error; 281 281 } 282 282 283 + if (attr->ia_valid & ATTR_MODE) 284 + udf_update_extra_perms(inode, attr->ia_mode); 285 + 283 286 setattr_copy(inode, attr); 284 287 mark_inode_dirty(inode); 285 288 return 0;
+3
fs/udf/ialloc.c
··· 118 118 iinfo->i_lenAlloc = 0; 119 119 iinfo->i_use = 0; 120 120 iinfo->i_checkpoint = 1; 121 + iinfo->i_extraPerms = FE_PERM_U_CHATTR; 122 + udf_update_extra_perms(inode, mode); 123 + 121 124 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB)) 122 125 iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB; 123 126 else if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))
+50 -5
fs/udf/inode.c
··· 45 45 46 46 #define EXTENT_MERGE_SIZE 5 47 47 48 + #define FE_MAPPED_PERMS (FE_PERM_U_READ | FE_PERM_U_WRITE | FE_PERM_U_EXEC | \ 49 + FE_PERM_G_READ | FE_PERM_G_WRITE | FE_PERM_G_EXEC | \ 50 + FE_PERM_O_READ | FE_PERM_O_WRITE | FE_PERM_O_EXEC) 51 + 52 + #define FE_DELETE_PERMS (FE_PERM_U_DELETE | FE_PERM_G_DELETE | \ 53 + FE_PERM_O_DELETE) 54 + 48 55 static umode_t udf_convert_permissions(struct fileEntry *); 49 56 static int udf_update_inode(struct inode *, int); 50 57 static int udf_sync_inode(struct inode *inode); ··· 1465 1458 else 1466 1459 inode->i_mode = udf_convert_permissions(fe); 1467 1460 inode->i_mode &= ~sbi->s_umask; 1461 + iinfo->i_extraPerms = le32_to_cpu(fe->permissions) & ~FE_MAPPED_PERMS; 1462 + 1468 1463 read_unlock(&sbi->s_cred_lock); 1469 1464 1470 1465 link_count = le16_to_cpu(fe->fileLinkCount); ··· 1494 1485 iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr); 1495 1486 iinfo->i_lenAlloc = le32_to_cpu(fe->lengthAllocDescs); 1496 1487 iinfo->i_checkpoint = le32_to_cpu(fe->checkpoint); 1488 + iinfo->i_streamdir = 0; 1489 + iinfo->i_lenStreams = 0; 1497 1490 } else { 1498 1491 inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) << 1499 1492 (inode->i_sb->s_blocksize_bits - 9); ··· 1509 1498 iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr); 1510 1499 iinfo->i_lenAlloc = le32_to_cpu(efe->lengthAllocDescs); 1511 1500 iinfo->i_checkpoint = le32_to_cpu(efe->checkpoint); 1501 + 1502 + /* Named streams */ 1503 + iinfo->i_streamdir = (efe->streamDirectoryICB.extLength != 0); 1504 + iinfo->i_locStreamdir = 1505 + lelb_to_cpu(efe->streamDirectoryICB.extLocation); 1506 + iinfo->i_lenStreams = le64_to_cpu(efe->objectSize); 1507 + if (iinfo->i_lenStreams >= inode->i_size) 1508 + iinfo->i_lenStreams -= inode->i_size; 1509 + else 1510 + iinfo->i_lenStreams = 0; 1512 1511 } 1513 1512 inode->i_generation = iinfo->i_unique; 1514 1513 ··· 1640 1619 return mode; 1641 1620 } 1642 1621 1622 + void udf_update_extra_perms(struct inode *inode, umode_t mode) 1623 + { 1624 + struct udf_inode_info *iinfo = UDF_I(inode); 1625 + 1626 + /* 1627 + * UDF 2.01 sec. 3.3.3.3 Note 2: 1628 + * In Unix, delete permission tracks write 1629 + */ 1630 + iinfo->i_extraPerms &= ~FE_DELETE_PERMS; 1631 + if (mode & 0200) 1632 + iinfo->i_extraPerms |= FE_PERM_U_DELETE; 1633 + if (mode & 0020) 1634 + iinfo->i_extraPerms |= FE_PERM_G_DELETE; 1635 + if (mode & 0002) 1636 + iinfo->i_extraPerms |= FE_PERM_O_DELETE; 1637 + } 1638 + 1643 1639 int udf_write_inode(struct inode *inode, struct writeback_control *wbc) 1644 1640 { 1645 1641 return udf_update_inode(inode, wbc->sync_mode == WB_SYNC_ALL); ··· 1729 1691 ((inode->i_mode & 0070) << 2) | 1730 1692 ((inode->i_mode & 0700) << 4); 1731 1693 1732 - udfperms |= (le32_to_cpu(fe->permissions) & 1733 - (FE_PERM_O_DELETE | FE_PERM_O_CHATTR | 1734 - FE_PERM_G_DELETE | FE_PERM_G_CHATTR | 1735 - FE_PERM_U_DELETE | FE_PERM_U_CHATTR)); 1694 + udfperms |= iinfo->i_extraPerms; 1736 1695 fe->permissions = cpu_to_le32(udfperms); 1737 1696 1738 1697 if (S_ISDIR(inode->i_mode) && inode->i_nlink > 0) ··· 1795 1760 iinfo->i_ext.i_data, 1796 1761 inode->i_sb->s_blocksize - 1797 1762 sizeof(struct extendedFileEntry)); 1798 - efe->objectSize = cpu_to_le64(inode->i_size); 1763 + efe->objectSize = 1764 + cpu_to_le64(inode->i_size + iinfo->i_lenStreams); 1799 1765 efe->logicalBlocksRecorded = cpu_to_le64(lb_recorded); 1766 + 1767 + if (iinfo->i_streamdir) { 1768 + struct long_ad *icb_lad = &efe->streamDirectoryICB; 1769 + 1770 + icb_lad->extLocation = 1771 + cpu_to_lelb(iinfo->i_locStreamdir); 1772 + icb_lad->extLength = 1773 + cpu_to_le32(inode->i_sb->s_blocksize); 1774 + } 1800 1775 1801 1776 udf_adjust_time(iinfo, inode->i_atime); 1802 1777 udf_adjust_time(iinfo, inode->i_mtime);
+152 -109
fs/udf/super.c
··· 92 92 static int udf_sync_fs(struct super_block *, int); 93 93 static int udf_remount_fs(struct super_block *, int *, char *); 94 94 static void udf_load_logicalvolint(struct super_block *, struct kernel_extent_ad); 95 - static int udf_find_fileset(struct super_block *, struct kernel_lb_addr *, 96 - struct kernel_lb_addr *); 97 - static void udf_load_fileset(struct super_block *, struct buffer_head *, 98 - struct kernel_lb_addr *); 99 95 static void udf_open_lvid(struct super_block *); 100 96 static void udf_close_lvid(struct super_block *); 101 97 static unsigned int udf_count_free(struct super_block *); ··· 147 151 148 152 ei->i_unique = 0; 149 153 ei->i_lenExtents = 0; 154 + ei->i_lenStreams = 0; 150 155 ei->i_next_alloc_block = 0; 151 156 ei->i_next_alloc_goal = 0; 152 157 ei->i_strat4096 = 0; 158 + ei->i_streamdir = 0; 153 159 init_rwsem(&ei->i_data_sem); 154 160 ei->cached_extent.lstart = -1; 155 161 spin_lock_init(&ei->i_extent_cache_lock); ··· 269 271 int nr_groups = bitmap->s_nr_groups; 270 272 271 273 for (i = 0; i < nr_groups; i++) 272 - if (bitmap->s_block_bitmap[i]) 273 - brelse(bitmap->s_block_bitmap[i]); 274 + brelse(bitmap->s_block_bitmap[i]); 274 275 275 276 kvfree(bitmap); 276 277 } ··· 643 646 return error; 644 647 } 645 648 646 - /* Check Volume Structure Descriptors (ECMA 167 2/9.1) */ 647 - /* We also check any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */ 648 - static loff_t udf_check_vsd(struct super_block *sb) 649 + /* 650 + * Check VSD descriptor. Returns -1 in case we are at the end of volume 651 + * recognition area, 0 if the descriptor is valid but non-interesting, 1 if 652 + * we found one of NSR descriptors we are looking for. 653 + */ 654 + static int identify_vsd(const struct volStructDesc *vsd) 655 + { 656 + int ret = 0; 657 + 658 + if (!memcmp(vsd->stdIdent, VSD_STD_ID_CD001, VSD_STD_ID_LEN)) { 659 + switch (vsd->structType) { 660 + case 0: 661 + udf_debug("ISO9660 Boot Record found\n"); 662 + break; 663 + case 1: 664 + udf_debug("ISO9660 Primary Volume Descriptor found\n"); 665 + break; 666 + case 2: 667 + udf_debug("ISO9660 Supplementary Volume Descriptor found\n"); 668 + break; 669 + case 3: 670 + udf_debug("ISO9660 Volume Partition Descriptor found\n"); 671 + break; 672 + case 255: 673 + udf_debug("ISO9660 Volume Descriptor Set Terminator found\n"); 674 + break; 675 + default: 676 + udf_debug("ISO9660 VRS (%u) found\n", vsd->structType); 677 + break; 678 + } 679 + } else if (!memcmp(vsd->stdIdent, VSD_STD_ID_BEA01, VSD_STD_ID_LEN)) 680 + ; /* ret = 0 */ 681 + else if (!memcmp(vsd->stdIdent, VSD_STD_ID_NSR02, VSD_STD_ID_LEN)) 682 + ret = 1; 683 + else if (!memcmp(vsd->stdIdent, VSD_STD_ID_NSR03, VSD_STD_ID_LEN)) 684 + ret = 1; 685 + else if (!memcmp(vsd->stdIdent, VSD_STD_ID_BOOT2, VSD_STD_ID_LEN)) 686 + ; /* ret = 0 */ 687 + else if (!memcmp(vsd->stdIdent, VSD_STD_ID_CDW02, VSD_STD_ID_LEN)) 688 + ; /* ret = 0 */ 689 + else { 690 + /* TEA01 or invalid id : end of volume recognition area */ 691 + ret = -1; 692 + } 693 + 694 + return ret; 695 + } 696 + 697 + /* 698 + * Check Volume Structure Descriptors (ECMA 167 2/9.1) 699 + * We also check any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) 700 + * @return 1 if NSR02 or NSR03 found, 701 + * -1 if first sector read error, 0 otherwise 702 + */ 703 + static int udf_check_vsd(struct super_block *sb) 649 704 { 650 705 struct volStructDesc *vsd = NULL; 651 706 loff_t sector = VSD_FIRST_SECTOR_OFFSET; 652 707 int sectorsize; 653 708 struct buffer_head *bh = NULL; 654 - int nsr02 = 0; 655 - int nsr03 = 0; 709 + int nsr = 0; 656 710 struct udf_sb_info *sbi; 657 711 658 712 sbi = UDF_SB(sb); ··· 727 679 * activity. This actually happened with uninitialised SSD partitions 728 680 * (all 0xFF) before the check for the limit and all valid IDs were 729 681 * added */ 730 - for (; !nsr02 && !nsr03 && sector < VSD_MAX_SECTOR_OFFSET; 731 - sector += sectorsize) { 682 + for (; !nsr && sector < VSD_MAX_SECTOR_OFFSET; sector += sectorsize) { 732 683 /* Read a block */ 733 684 bh = udf_tread(sb, sector >> sb->s_blocksize_bits); 734 685 if (!bh) 735 686 break; 736 687 737 - /* Look for ISO descriptors */ 738 688 vsd = (struct volStructDesc *)(bh->b_data + 739 689 (sector & (sb->s_blocksize - 1))); 740 - 741 - if (!strncmp(vsd->stdIdent, VSD_STD_ID_CD001, 742 - VSD_STD_ID_LEN)) { 743 - switch (vsd->structType) { 744 - case 0: 745 - udf_debug("ISO9660 Boot Record found\n"); 746 - break; 747 - case 1: 748 - udf_debug("ISO9660 Primary Volume Descriptor found\n"); 749 - break; 750 - case 2: 751 - udf_debug("ISO9660 Supplementary Volume Descriptor found\n"); 752 - break; 753 - case 3: 754 - udf_debug("ISO9660 Volume Partition Descriptor found\n"); 755 - break; 756 - case 255: 757 - udf_debug("ISO9660 Volume Descriptor Set Terminator found\n"); 758 - break; 759 - default: 760 - udf_debug("ISO9660 VRS (%u) found\n", 761 - vsd->structType); 762 - break; 763 - } 764 - } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_BEA01, 765 - VSD_STD_ID_LEN)) 766 - ; /* nothing */ 767 - else if (!strncmp(vsd->stdIdent, VSD_STD_ID_TEA01, 768 - VSD_STD_ID_LEN)) { 690 + nsr = identify_vsd(vsd); 691 + /* Found NSR or end? */ 692 + if (nsr) { 769 693 brelse(bh); 770 694 break; 771 - } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR02, 772 - VSD_STD_ID_LEN)) 773 - nsr02 = sector; 774 - else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR03, 775 - VSD_STD_ID_LEN)) 776 - nsr03 = sector; 777 - else if (!strncmp(vsd->stdIdent, VSD_STD_ID_BOOT2, 778 - VSD_STD_ID_LEN)) 779 - ; /* nothing */ 780 - else if (!strncmp(vsd->stdIdent, VSD_STD_ID_CDW02, 781 - VSD_STD_ID_LEN)) 782 - ; /* nothing */ 783 - else { 784 - /* invalid id : end of volume recognition area */ 785 - brelse(bh); 786 - break; 695 + } 696 + /* 697 + * Special handling for improperly formatted VRS (e.g., Win10) 698 + * where components are separated by 2048 bytes even though 699 + * sectors are 4K 700 + */ 701 + if (sb->s_blocksize == 4096) { 702 + nsr = identify_vsd(vsd + 1); 703 + /* Ignore unknown IDs... */ 704 + if (nsr < 0) 705 + nsr = 0; 787 706 } 788 707 brelse(bh); 789 708 } 790 709 791 - if (nsr03) 792 - return nsr03; 793 - else if (nsr02) 794 - return nsr02; 710 + if (nsr > 0) 711 + return 1; 795 712 else if (!bh && sector - (sbi->s_session << sb->s_blocksize_bits) == 796 713 VSD_FIRST_SECTOR_OFFSET) 797 714 return -1; 798 715 else 799 716 return 0; 717 + } 718 + 719 + static int udf_verify_domain_identifier(struct super_block *sb, 720 + struct regid *ident, char *dname) 721 + { 722 + struct domainEntityIDSuffix *suffix; 723 + 724 + if (memcmp(ident->ident, UDF_ID_COMPLIANT, strlen(UDF_ID_COMPLIANT))) { 725 + udf_warn(sb, "Not OSTA UDF compliant %s descriptor.\n", dname); 726 + goto force_ro; 727 + } 728 + if (ident->flags & (1 << ENTITYID_FLAGS_DIRTY)) { 729 + udf_warn(sb, "Possibly not OSTA UDF compliant %s descriptor.\n", 730 + dname); 731 + goto force_ro; 732 + } 733 + suffix = (struct domainEntityIDSuffix *)ident->identSuffix; 734 + if (suffix->flags & (1 << ENTITYIDSUFFIX_FLAGS_HARDWRITEPROTECT) || 735 + suffix->flags & (1 << ENTITYIDSUFFIX_FLAGS_SOFTWRITEPROTECT)) { 736 + if (!sb_rdonly(sb)) { 737 + udf_warn(sb, "Descriptor for %s marked write protected." 738 + " Forcing read only mount.\n", dname); 739 + } 740 + goto force_ro; 741 + } 742 + return 0; 743 + 744 + force_ro: 745 + if (!sb_rdonly(sb)) 746 + return -EACCES; 747 + UDF_SET_FLAG(sb, UDF_FLAG_RW_INCOMPAT); 748 + return 0; 749 + } 750 + 751 + static int udf_load_fileset(struct super_block *sb, struct fileSetDesc *fset, 752 + struct kernel_lb_addr *root) 753 + { 754 + int ret; 755 + 756 + ret = udf_verify_domain_identifier(sb, &fset->domainIdent, "file set"); 757 + if (ret < 0) 758 + return ret; 759 + 760 + *root = lelb_to_cpu(fset->rootDirectoryICB.extLocation); 761 + UDF_SB(sb)->s_serial_number = le16_to_cpu(fset->descTag.tagSerialNum); 762 + 763 + udf_debug("Rootdir at block=%u, partition=%u\n", 764 + root->logicalBlockNum, root->partitionReferenceNum); 765 + return 0; 800 766 } 801 767 802 768 static int udf_find_fileset(struct super_block *sb, ··· 819 757 { 820 758 struct buffer_head *bh = NULL; 821 759 uint16_t ident; 760 + int ret; 822 761 823 - if (fileset->logicalBlockNum != 0xFFFFFFFF || 824 - fileset->partitionReferenceNum != 0xFFFF) { 825 - bh = udf_read_ptagged(sb, fileset, 0, &ident); 762 + if (fileset->logicalBlockNum == 0xFFFFFFFF && 763 + fileset->partitionReferenceNum == 0xFFFF) 764 + return -EINVAL; 826 765 827 - if (!bh) { 828 - return 1; 829 - } else if (ident != TAG_IDENT_FSD) { 830 - brelse(bh); 831 - return 1; 832 - } 833 - 834 - udf_debug("Fileset at block=%u, partition=%u\n", 835 - fileset->logicalBlockNum, 836 - fileset->partitionReferenceNum); 837 - 838 - UDF_SB(sb)->s_partition = fileset->partitionReferenceNum; 839 - udf_load_fileset(sb, bh, root); 766 + bh = udf_read_ptagged(sb, fileset, 0, &ident); 767 + if (!bh) 768 + return -EIO; 769 + if (ident != TAG_IDENT_FSD) { 840 770 brelse(bh); 841 - return 0; 771 + return -EINVAL; 842 772 } 843 - return 1; 773 + 774 + udf_debug("Fileset at block=%u, partition=%u\n", 775 + fileset->logicalBlockNum, fileset->partitionReferenceNum); 776 + 777 + UDF_SB(sb)->s_partition = fileset->partitionReferenceNum; 778 + ret = udf_load_fileset(sb, (struct fileSetDesc *)bh->b_data, root); 779 + brelse(bh); 780 + return ret; 844 781 } 845 782 846 783 /* ··· 855 794 struct buffer_head *bh; 856 795 uint16_t ident; 857 796 int ret = -ENOMEM; 858 - #ifdef UDFFS_DEBUG 859 797 struct timestamp *ts; 860 - #endif 861 798 862 799 outstr = kmalloc(128, GFP_NOFS); 863 800 if (!outstr) ··· 876 817 877 818 udf_disk_stamp_to_time(&UDF_SB(sb)->s_record_time, 878 819 pvoldesc->recordingDateAndTime); 879 - #ifdef UDFFS_DEBUG 880 820 ts = &pvoldesc->recordingDateAndTime; 881 821 udf_debug("recording time %04u/%02u/%02u %02u:%02u (%x)\n", 882 822 le16_to_cpu(ts->year), ts->month, ts->day, ts->hour, 883 823 ts->minute, le16_to_cpu(ts->typeAndTimezone)); 884 - #endif 885 - 886 824 887 825 ret = udf_dstrCS0toChar(sb, outstr, 31, pvoldesc->volIdent, 32); 888 826 if (ret < 0) { ··· 993 937 994 938 udf_debug("udf_load_metadata_files Ok\n"); 995 939 return 0; 996 - } 997 - 998 - static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh, 999 - struct kernel_lb_addr *root) 1000 - { 1001 - struct fileSetDesc *fset; 1002 - 1003 - fset = (struct fileSetDesc *)bh->b_data; 1004 - 1005 - *root = lelb_to_cpu(fset->rootDirectoryICB.extLocation); 1006 - 1007 - UDF_SB(sb)->s_serial_number = le16_to_cpu(fset->descTag.tagSerialNum); 1008 - 1009 - udf_debug("Rootdir at block=%u, partition=%u\n", 1010 - root->logicalBlockNum, root->partitionReferenceNum); 1011 940 } 1012 941 1013 942 int udf_compute_nr_groups(struct super_block *sb, u32 partition) ··· 1279 1238 * PHYSICAL partitions are already set up 1280 1239 */ 1281 1240 type1_idx = i; 1282 - #ifdef UDFFS_DEBUG 1283 1241 map = NULL; /* supress 'maybe used uninitialized' warning */ 1284 - #endif 1285 1242 for (i = 0; i < sbi->s_partitions; i++) { 1286 1243 map = &sbi->s_partmaps[i]; 1287 1244 ··· 1403 1364 goto out_bh; 1404 1365 } 1405 1366 1367 + ret = udf_verify_domain_identifier(sb, &lvd->domainIdent, 1368 + "logical volume"); 1369 + if (ret) 1370 + goto out_bh; 1406 1371 ret = udf_sb_alloc_partition_maps(sb, le32_to_cpu(lvd->numPartitionMaps)); 1407 1372 if (ret) 1408 1373 goto out_bh; ··· 1958 1915 int silent, struct kernel_lb_addr *fileset) 1959 1916 { 1960 1917 struct udf_sb_info *sbi = UDF_SB(sb); 1961 - loff_t nsr_off; 1918 + int nsr = 0; 1962 1919 int ret; 1963 1920 1964 1921 if (!sb_set_blocksize(sb, uopt->blocksize)) { ··· 1969 1926 sbi->s_last_block = uopt->lastblock; 1970 1927 if (!uopt->novrs) { 1971 1928 /* Check that it is NSR02 compliant */ 1972 - nsr_off = udf_check_vsd(sb); 1973 - if (!nsr_off) { 1929 + nsr = udf_check_vsd(sb); 1930 + if (!nsr) { 1974 1931 if (!silent) 1975 1932 udf_warn(sb, "No VRS found\n"); 1976 1933 return -EINVAL; 1977 1934 } 1978 - if (nsr_off == -1) 1935 + if (nsr == -1) 1979 1936 udf_debug("Failed to read sector at offset %d. " 1980 1937 "Assuming open disc. Skipping validity " 1981 1938 "check\n", VSD_FIRST_SECTOR_OFFSET); ··· 2259 2216 UDF_SET_FLAG(sb, UDF_FLAG_RW_INCOMPAT); 2260 2217 } 2261 2218 2262 - if (udf_find_fileset(sb, &fileset, &rootdir)) { 2219 + ret = udf_find_fileset(sb, &fileset, &rootdir); 2220 + if (ret < 0) { 2263 2221 udf_warn(sb, "No fileset found\n"); 2264 - ret = -EINVAL; 2265 2222 goto error_out; 2266 2223 } 2267 2224
+5 -1
fs/udf/udf_i.h
··· 38 38 __u32 i_next_alloc_block; 39 39 __u32 i_next_alloc_goal; 40 40 __u32 i_checkpoint; 41 + __u32 i_extraPerms; 41 42 unsigned i_alloc_type : 3; 42 43 unsigned i_efe : 1; /* extendedFileEntry */ 43 44 unsigned i_use : 1; /* unallocSpaceEntry */ 44 45 unsigned i_strat4096 : 1; 45 - unsigned reserved : 26; 46 + unsigned i_streamdir : 1; 47 + unsigned reserved : 25; 46 48 union { 47 49 struct short_ad *i_sad; 48 50 struct long_ad *i_lad; 49 51 __u8 *i_data; 50 52 } i_ext; 53 + struct kernel_lb_addr i_locStreamdir; 54 + __u64 i_lenStreams; 51 55 struct rw_semaphore i_data_sem; 52 56 struct udf_ext_cache cached_extent; 53 57 /* Spinlock for protecting extent cache */
+2 -9
fs/udf/udfdecl.h
··· 31 31 #define udf_info(fmt, ...) \ 32 32 pr_info("INFO " fmt, ##__VA_ARGS__) 33 33 34 - #undef UDFFS_DEBUG 35 - 36 - #ifdef UDFFS_DEBUG 37 34 #define udf_debug(fmt, ...) \ 38 - printk(KERN_DEBUG pr_fmt("%s:%d:%s: " fmt), \ 39 - __FILE__, __LINE__, __func__, ##__VA_ARGS__) 40 - #else 41 - #define udf_debug(fmt, ...) \ 42 - no_printk(fmt, ##__VA_ARGS__) 43 - #endif 35 + pr_debug("%s:%d:%s: " fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__) 44 36 45 37 #define udf_fixed_to_variable(x) ( ( ( (x) >> 5 ) * 39 ) + ( (x) & 0x0000001F ) ) 46 38 #define udf_variable_to_fixed(x) ( ( ( (x) / 39 ) << 5 ) + ( (x) % 39 ) ) ··· 170 178 struct kernel_lb_addr *, uint32_t *, int); 171 179 extern int8_t udf_current_aext(struct inode *, struct extent_position *, 172 180 struct kernel_lb_addr *, uint32_t *, int); 181 + extern void udf_update_extra_perms(struct inode *inode, umode_t mode); 173 182 174 183 /* misc.c */ 175 184 extern struct buffer_head *udf_tgetblk(struct super_block *sb,
+1 -1
include/linux/quotaops.h
··· 22 22 /* i_mutex must being held */ 23 23 static inline bool is_quota_modification(struct inode *inode, struct iattr *ia) 24 24 { 25 - return (ia->ia_valid & ATTR_SIZE && ia->ia_size != inode->i_size) || 25 + return (ia->ia_valid & ATTR_SIZE) || 26 26 (ia->ia_valid & ATTR_UID && !uid_eq(ia->ia_uid, inode->i_uid)) || 27 27 (ia->ia_valid & ATTR_GID && !gid_eq(ia->ia_gid, inode->i_gid)); 28 28 }