📄 1011.udf.patch
字号:
/* Block size must be a multiple of 512 */ if (sb->s_blocksize & 511)@@ -546,7 +551,7 @@ vsd = (struct volStructDesc *)(bh->b_data + (sector & (sb->s_blocksize - 1))); - if (vsd->stdIdent[0] == 0)+ if ((vsd->stdIdent[0] == 0) || (i++ > VRS_SECTOR_LIMIT)) { udf_release_data(bh); break;@@ -630,15 +635,14 @@ uint16_t ident; uint32_t location; int i;+ int varlastblock = udf_variable_to_fixed(lastblock);+ int last[] = { /* (UDF_SB_SESSION(sb) + 256), */ lastblock, lastblock - 1, lastblock + 1,+ lastblock - 2, lastblock - 150, lastblock - 152,+ varlastblock, varlastblock - 2,+ varlastblock - 150, varlastblock - 152 }; if (lastblock) {- int varlastblock = udf_variable_to_fixed(lastblock);- int last[] = { lastblock, lastblock - 2,- lastblock - 150, lastblock - 152,- varlastblock, varlastblock - 2,- varlastblock - 150, varlastblock - 152 };- lastblock = 0; /* Search for an anchor volume descriptor pointer */@@ -664,25 +668,40 @@ if (ident == TAG_IDENT_AVDP) {- if (location == last[i] - UDF_SB_SESSION(sb))+ if (location == last[i] /*- UDF_SB_SESSION(sb)*/) {- lastblock = UDF_SB_ANCHOR(sb)[0] = last[i] - UDF_SB_SESSION(sb);- UDF_SB_ANCHOR(sb)[1] = last[i] - 256 - UDF_SB_SESSION(sb);+ lastblock = UDF_SB_ANCHOR(sb)[0] = last[i] /*- UDF_SB_SESSION(sb)*/;+ UDF_SB_ANCHOR(sb)[1] = last[i] - 256 /*- UDF_SB_SESSION(sb)*/; }- else if (location == udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb))+ else if (location == udf_variable_to_fixed(last[i]) /*- UDF_SB_SESSION(sb)*/) { UDF_SET_FLAG(sb, UDF_FLAG_VARCONV);- lastblock = UDF_SB_ANCHOR(sb)[0] = udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb);- UDF_SB_ANCHOR(sb)[1] = lastblock - 256 - UDF_SB_SESSION(sb);+ lastblock = UDF_SB_ANCHOR(sb)[0] = udf_variable_to_fixed(last[i]) /*- UDF_SB_SESSION(sb)*/;+ UDF_SB_ANCHOR(sb)[1] = lastblock - 256 /*- UDF_SB_SESSION(sb)*/; } else udf_debug("Anchor found at block %d, location mismatch %d.\n", last[i], location); }- else if (ident == TAG_IDENT_FE || ident == TAG_IDENT_EFE)+ else if (UDF_SB_SESSION(sb)) /* multisession */ {- lastblock = last[i];- UDF_SB_ANCHOR(sb)[3] = 512;+ if (!(bh = sb_bread(sb, UDF_SB_SESSION(sb) + 256)))+ {+ ident = location = 0;+ }+ else+ {+ ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);+ location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);+ udf_release_data(bh);+ }++ if (ident == TAG_IDENT_AVDP &&+ location == UDF_SB_SESSION(sb) + 256)+ {+ lastblock = last[i];+ UDF_SB_ANCHOR(sb)[1] = UDF_SB_SESSION(sb) + 256;+ } } else {@@ -698,14 +717,14 @@ } if (ident == TAG_IDENT_AVDP &&- location == last[i] - 256 - UDF_SB_SESSION(sb))+ location == last[i] - 256 /*- UDF_SB_SESSION(sb)*/) { lastblock = last[i]; UDF_SB_ANCHOR(sb)[1] = last[i] - 256; } else {- if (last[i] < 312 + UDF_SB_SESSION(sb) || !(bh = sb_bread(sb, last[i] - 312 - UDF_SB_SESSION(sb))))+ if (last[i] < 312 + UDF_SB_SESSION(sb) || !(bh = sb_bread(sb, last[i] - 312 /*- UDF_SB_SESSION(sb)*/))) { ident = location = 0; }@@ -730,7 +749,42 @@ if (!lastblock) {- /* We havn't found the lastblock. check 312 */+ /* We haven't found the lastblock. Check for VAT presence and then at location 512 for AVDP */+ for (i = 0; !lastblock && i < ARRAY_SIZE(last); i++) {+ uint8_t fileType = 0xFF;++ if (last[i] < 0 || !(bh = sb_bread(sb, last[i])))+ {+ ident = location = 0;+ }+ else+ {+ ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);+ fileType = ((struct fileEntry *)bh->b_data)->icbTag.fileType;+ udf_release_data(bh);+ }++ if ((ident == TAG_IDENT_FE || ident == TAG_IDENT_EFE) &&+ (fileType == ICBTAG_FILE_TYPE_VAT20 || fileType == ICBTAG_FILE_TYPE_VAT15))+ {+ lastblock = last[i];+ /*+ Check if there's a valid AVDP at sector 256.+ If true, then ignore any AVDP at sector 512 (s. note from UDF 2.50 3/2.2.3)+ */+ if ((bh = udf_read_tagged(sb, 256, 256, &ident)) &&+ (ident == TAG_IDENT_AVDP))+ {+ udf_release_data(bh);+ }+ else+ {+ UDF_SB_ANCHOR(sb)[3] = 512;+ }+ }+ }+ + /* We haven't found the lastblock. check 312 */ if ((bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb)))) { ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);@@ -898,6 +952,103 @@ } } +static int+udf_load_metadata_file_entries(struct super_block *sb, int part, kernel_lb_addr *fileset)+{+ kernel_lb_addr addr;+ int fe_error = 0;++ /* metadata address */+ addr.logicalBlockNum = UDF_SB_TYPEMETA(sb, part).s_meta_file_loc;+ addr.partitionReferenceNum = UDF_SB_PARTNUM(sb, part);+ + udf_debug("block=%d part=%d\n",addr.logicalBlockNum,addr.partitionReferenceNum);+ + UDF_SB_TYPEMETA(sb, part).s_metadata_fe = udf_iget(sb, addr);+ + if (UDF_SB_TYPEMETA(sb,part).s_metadata_fe == NULL)+ {+ udf_warning(sb, __FUNCTION__, "metadata inode efe not found, will try mirror inode.");+ fe_error = 1;+ /*goto error_exit;*/+ }++ /* mirror file entry */+ addr.logicalBlockNum = UDF_SB_TYPEMETA(sb, part).s_mirror_file_loc;+ addr.partitionReferenceNum = UDF_SB_PARTNUM(sb, part);+ + udf_debug("block=%d part=%d\n",addr.logicalBlockNum,addr.partitionReferenceNum);++ UDF_SB_TYPEMETA(sb, part).s_mirror_fe = udf_iget(sb, addr);+ + if (UDF_SB_TYPEMETA(sb, part).s_mirror_fe == NULL)+ {+ if (fe_error)+ {+ udf_error(sb, __FUNCTION__, "mirror inode efe not found and metadata inode is missing too, exiting...");+ goto error_exit;+ }+ else+ udf_warning(sb, __FUNCTION__, "mirror inode efe not found but metadata inode is OK");+ }++ /* + bitmap file entry+ Note: Load only if bitmap file location differs from 0xFFFFFFFF (DCN-5102) + */+ if (UDF_SB_TYPEMETA(sb, part).s_bitmap_file_loc != 0xFFFFFFFF)+ {+ addr.logicalBlockNum = UDF_SB_TYPEMETA(sb, part).s_bitmap_file_loc;+ addr.partitionReferenceNum = UDF_SB_PARTNUM(sb, part);+ + udf_debug("block=%d part=%d\n",addr.logicalBlockNum,addr.partitionReferenceNum);+ + UDF_SB_TYPEMETA(sb, part).s_bitmap_fe = udf_iget(sb, addr);+ + if (UDF_SB_TYPEMETA(sb,part).s_bitmap_fe == NULL)+ {+ if (sb->s_flags & MS_RDONLY)+ udf_warning(sb, __FUNCTION__, "bitmap inode efe not found but it's ok since the disc is mounted read-only");+ else+ {+ udf_error(sb, __FUNCTION__, "bitmap inode efe not found and attempted read-write mount");+ goto error_exit;+ }+ }+ }+ udf_debug("udf_load_metadata_file_entries Ok\n");+ + return 0;++error_exit:+ return 1;+}++static void+udf_release_metadata(struct super_block *sb)+{+ int i;+ /* release metadata */+ udf_debug("Releasing metadata!\n");+ for (i=0; i<UDF_SB_NUMPARTS(sb); i++)+ {+ if(UDF_SB_PARTTYPE(sb,i) == UDF_METADATA_MAP25)+ {+ if(UDF_SB_TYPEMETA(sb,i).s_metadata_fe)+ iput(UDF_SB_TYPEMETA(sb,i).s_metadata_fe);+ UDF_SB_TYPEMETA(sb,i).s_metadata_fe = NULL;++ if(UDF_SB_TYPEMETA(sb,i).s_mirror_fe)+ iput(UDF_SB_TYPEMETA(sb,i).s_mirror_fe);+ UDF_SB_TYPEMETA(sb,i).s_mirror_fe = NULL;++ if(UDF_SB_TYPEMETA(sb,i).s_bitmap_fe)+ iput(UDF_SB_TYPEMETA(sb,i).s_bitmap_fe);+ UDF_SB_TYPEMETA(sb,i).s_bitmap_fe = NULL;+ }+ }+}+ static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh, kernel_lb_addr *root) {@@ -917,6 +1068,7 @@ udf_load_partdesc(struct super_block *sb, struct buffer_head *bh) { struct partitionDesc *p;+ int matched_part_desc=0; int i; p = (struct partitionDesc *)bh->b_data;@@ -925,8 +1077,22 @@ { udf_debug("Searching map: (%d == %d)\n", UDF_SB_PARTMAPS(sb)[i].s_partition_num, le16_to_cpu(p->partitionNumber));- if (UDF_SB_PARTMAPS(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber))++ /* workaround problems caused by Vista */+ if (UDF_SB_PARTMAPS(sb)[i].s_partition_num >= UDF_SB_NUMPARTS(sb)) {+ udf_debug("Changing parition# from %d to ", UDF_SB_PARTMAPS(sb)[i].s_partition_num);+ UDF_SB_PARTMAPS(sb)[i].s_partition_num %= (UDF_SB_NUMPARTS(sb)); + udf_debug("%d\n", UDF_SB_PARTMAPS(sb)[i].s_partition_num);+ } else {+ udf_debug("Keeping partition# %d out of %d partitions\n", + UDF_SB_PARTMAPS(sb)[i].s_partition_num, UDF_SB_NUMPARTS(sb));+ }++ if ((UDF_SB_PARTMAPS(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber)) || + ((UDF_SB_PARTMAPS(sb)[i].s_partition_num % UDF_SB_NUMPARTS(sb)) == (le16_to_cpu(p->partitionNumber) % UDF_SB_NUMPARTS(sb)))) {+ matched_part_desc++;+ udf_debug("Found desc for part %d id(%d)\n",i,UDF_SB_PARTMAPS(sb)[i].s_partition_num); UDF_SB_PARTLEN(sb,i) = le32_to_cpu(p->partitionLength); /* blocks */ UDF_SB_PARTROOT(sb,i) = le32_to_cpu(p->partitionStartingLocation);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -