aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/super.c
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2007-07-21 07:37:18 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-21 20:49:14 -0400
commit28de7948a896763bc97ccd416bba5b9422158350 (patch)
treeabee128b137a6fa9fa4104b7bbc4ee409467c38f /fs/udf/super.c
parent71133027febfabd501fde7583b30008224f4d799 (diff)
UDF: coding style conversion - lindent fixups
This patch fixes up sources after conversion by Lindent. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> Cc: Jan Kara <jack@ucw.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/udf/super.c')
-rw-r--r--fs/udf/super.c1023
1 files changed, 388 insertions, 635 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 72097ee6b752..7b30964665db 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -104,11 +104,11 @@ static int udf_get_sb(struct file_system_type *fs_type,
104} 104}
105 105
106static struct file_system_type udf_fstype = { 106static struct file_system_type udf_fstype = {
107 .owner = THIS_MODULE, 107 .owner = THIS_MODULE,
108 .name = "udf", 108 .name = "udf",
109 .get_sb = udf_get_sb, 109 .get_sb = udf_get_sb,
110 .kill_sb = kill_block_super, 110 .kill_sb = kill_block_super,
111 .fs_flags = FS_REQUIRES_DEV, 111 .fs_flags = FS_REQUIRES_DEV,
112}; 112};
113 113
114static struct kmem_cache *udf_inode_cachep; 114static struct kmem_cache *udf_inode_cachep;
@@ -116,8 +116,7 @@ static struct kmem_cache *udf_inode_cachep;
116static struct inode *udf_alloc_inode(struct super_block *sb) 116static struct inode *udf_alloc_inode(struct super_block *sb)
117{ 117{
118 struct udf_inode_info *ei; 118 struct udf_inode_info *ei;
119 ei = (struct udf_inode_info *)kmem_cache_alloc(udf_inode_cachep, 119 ei = (struct udf_inode_info *)kmem_cache_alloc(udf_inode_cachep, GFP_KERNEL);
120 GFP_KERNEL);
121 if (!ei) 120 if (!ei)
122 return NULL; 121 return NULL;
123 122
@@ -150,7 +149,7 @@ static int init_inodecache(void)
150 0, (SLAB_RECLAIM_ACCOUNT | 149 0, (SLAB_RECLAIM_ACCOUNT |
151 SLAB_MEM_SPREAD), 150 SLAB_MEM_SPREAD),
152 init_once); 151 init_once);
153 if (udf_inode_cachep == NULL) 152 if (!udf_inode_cachep)
154 return -ENOMEM; 153 return -ENOMEM;
155 return 0; 154 return 0;
156} 155}
@@ -162,15 +161,15 @@ static void destroy_inodecache(void)
162 161
163/* Superblock operations */ 162/* Superblock operations */
164static const struct super_operations udf_sb_ops = { 163static const struct super_operations udf_sb_ops = {
165 .alloc_inode = udf_alloc_inode, 164 .alloc_inode = udf_alloc_inode,
166 .destroy_inode = udf_destroy_inode, 165 .destroy_inode = udf_destroy_inode,
167 .write_inode = udf_write_inode, 166 .write_inode = udf_write_inode,
168 .delete_inode = udf_delete_inode, 167 .delete_inode = udf_delete_inode,
169 .clear_inode = udf_clear_inode, 168 .clear_inode = udf_clear_inode,
170 .put_super = udf_put_super, 169 .put_super = udf_put_super,
171 .write_super = udf_write_super, 170 .write_super = udf_write_super,
172 .statfs = udf_statfs, 171 .statfs = udf_statfs,
173 .remount_fs = udf_remount_fs, 172 .remount_fs = udf_remount_fs,
174}; 173};
175 174
176struct udf_options { 175struct udf_options {
@@ -193,16 +192,20 @@ struct udf_options {
193static int __init init_udf_fs(void) 192static int __init init_udf_fs(void)
194{ 193{
195 int err; 194 int err;
195
196 err = init_inodecache(); 196 err = init_inodecache();
197 if (err) 197 if (err)
198 goto out1; 198 goto out1;
199 err = register_filesystem(&udf_fstype); 199 err = register_filesystem(&udf_fstype);
200 if (err) 200 if (err)
201 goto out; 201 goto out;
202
202 return 0; 203 return 0;
203 out: 204
205out:
204 destroy_inodecache(); 206 destroy_inodecache();
205 out1: 207
208out1:
206 return err; 209 return err;
207} 210}
208 211
@@ -213,7 +216,7 @@ static void __exit exit_udf_fs(void)
213} 216}
214 217
215module_init(init_udf_fs) 218module_init(init_udf_fs)
216 module_exit(exit_udf_fs) 219module_exit(exit_udf_fs)
217 220
218/* 221/*
219 * udf_parse_options 222 * udf_parse_options
@@ -239,7 +242,7 @@ module_init(init_udf_fs)
239 * 242 *
240 * The remaining are for debugging and disaster recovery: 243 * The remaining are for debugging and disaster recovery:
241 * 244 *
242 * novrs Skip volume sequence recognition 245 * novrs Skip volume sequence recognition
243 * 246 *
244 * The following expect a offset from 0. 247 * The following expect a offset from 0.
245 * 248 *
@@ -268,6 +271,7 @@ module_init(init_udf_fs)
268 * July 1, 1997 - Andrew E. Mileski 271 * July 1, 1997 - Andrew E. Mileski
269 * Written, tested, and released. 272 * Written, tested, and released.
270 */ 273 */
274
271enum { 275enum {
272 Opt_novrs, Opt_nostrict, Opt_bs, Opt_unhide, Opt_undelete, 276 Opt_novrs, Opt_nostrict, Opt_bs, Opt_unhide, Opt_undelete,
273 Opt_noadinicb, Opt_adinicb, Opt_shortad, Opt_longad, 277 Opt_noadinicb, Opt_adinicb, Opt_shortad, Opt_longad,
@@ -278,32 +282,32 @@ enum {
278}; 282};
279 283
280static match_table_t tokens = { 284static match_table_t tokens = {
281 {Opt_novrs, "novrs"}, 285 {Opt_novrs, "novrs"},
282 {Opt_nostrict, "nostrict"}, 286 {Opt_nostrict, "nostrict"},
283 {Opt_bs, "bs=%u"}, 287 {Opt_bs, "bs=%u"},
284 {Opt_unhide, "unhide"}, 288 {Opt_unhide, "unhide"},
285 {Opt_undelete, "undelete"}, 289 {Opt_undelete, "undelete"},
286 {Opt_noadinicb, "noadinicb"}, 290 {Opt_noadinicb, "noadinicb"},
287 {Opt_adinicb, "adinicb"}, 291 {Opt_adinicb, "adinicb"},
288 {Opt_shortad, "shortad"}, 292 {Opt_shortad, "shortad"},
289 {Opt_longad, "longad"}, 293 {Opt_longad, "longad"},
290 {Opt_uforget, "uid=forget"}, 294 {Opt_uforget, "uid=forget"},
291 {Opt_uignore, "uid=ignore"}, 295 {Opt_uignore, "uid=ignore"},
292 {Opt_gforget, "gid=forget"}, 296 {Opt_gforget, "gid=forget"},
293 {Opt_gignore, "gid=ignore"}, 297 {Opt_gignore, "gid=ignore"},
294 {Opt_gid, "gid=%u"}, 298 {Opt_gid, "gid=%u"},
295 {Opt_uid, "uid=%u"}, 299 {Opt_uid, "uid=%u"},
296 {Opt_umask, "umask=%o"}, 300 {Opt_umask, "umask=%o"},
297 {Opt_session, "session=%u"}, 301 {Opt_session, "session=%u"},
298 {Opt_lastblock, "lastblock=%u"}, 302 {Opt_lastblock, "lastblock=%u"},
299 {Opt_anchor, "anchor=%u"}, 303 {Opt_anchor, "anchor=%u"},
300 {Opt_volume, "volume=%u"}, 304 {Opt_volume, "volume=%u"},
301 {Opt_partition, "partition=%u"}, 305 {Opt_partition, "partition=%u"},
302 {Opt_fileset, "fileset=%u"}, 306 {Opt_fileset, "fileset=%u"},
303 {Opt_rootdir, "rootdir=%u"}, 307 {Opt_rootdir, "rootdir=%u"},
304 {Opt_utf8, "utf8"}, 308 {Opt_utf8, "utf8"},
305 {Opt_iocharset, "iocharset=%s"}, 309 {Opt_iocharset, "iocharset=%s"},
306 {Opt_err, NULL} 310 {Opt_err, NULL}
307}; 311};
308 312
309static int udf_parse_options(char *options, struct udf_options *uopt) 313static int udf_parse_options(char *options, struct udf_options *uopt)
@@ -444,9 +448,11 @@ static int udf_parse_options(char *options, struct udf_options *uopt)
444void udf_write_super(struct super_block *sb) 448void udf_write_super(struct super_block *sb)
445{ 449{
446 lock_kernel(); 450 lock_kernel();
451
447 if (!(sb->s_flags & MS_RDONLY)) 452 if (!(sb->s_flags & MS_RDONLY))
448 udf_open_lvid(sb); 453 udf_open_lvid(sb);
449 sb->s_dirt = 0; 454 sb->s_dirt = 0;
455
450 unlock_kernel(); 456 unlock_kernel();
451} 457}
452 458
@@ -455,16 +461,16 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
455 struct udf_options uopt; 461 struct udf_options uopt;
456 462
457 uopt.flags = UDF_SB(sb)->s_flags; 463 uopt.flags = UDF_SB(sb)->s_flags;
458 uopt.uid = UDF_SB(sb)->s_uid; 464 uopt.uid = UDF_SB(sb)->s_uid;
459 uopt.gid = UDF_SB(sb)->s_gid; 465 uopt.gid = UDF_SB(sb)->s_gid;
460 uopt.umask = UDF_SB(sb)->s_umask; 466 uopt.umask = UDF_SB(sb)->s_umask;
461 467
462 if (!udf_parse_options(options, &uopt)) 468 if (!udf_parse_options(options, &uopt))
463 return -EINVAL; 469 return -EINVAL;
464 470
465 UDF_SB(sb)->s_flags = uopt.flags; 471 UDF_SB(sb)->s_flags = uopt.flags;
466 UDF_SB(sb)->s_uid = uopt.uid; 472 UDF_SB(sb)->s_uid = uopt.uid;
467 UDF_SB(sb)->s_gid = uopt.gid; 473 UDF_SB(sb)->s_gid = uopt.gid;
468 UDF_SB(sb)->s_umask = uopt.umask; 474 UDF_SB(sb)->s_umask = uopt.umask;
469 475
470 if (UDF_SB_LVIDBH(sb)) { 476 if (UDF_SB_LVIDBH(sb)) {
@@ -517,6 +523,7 @@ static int udf_set_blocksize(struct super_block *sb, int bsize)
517 printk(KERN_ERR "udf: bad block size (%d)\n", bsize); 523 printk(KERN_ERR "udf: bad block size (%d)\n", bsize);
518 return 0; 524 return 0;
519 } 525 }
526
520 return sb->s_blocksize; 527 return sb->s_blocksize;
521} 528}
522 529
@@ -552,15 +559,12 @@ static int udf_vrs(struct super_block *sb, int silent)
552 559
553 /* Look for ISO descriptors */ 560 /* Look for ISO descriptors */
554 vsd = (struct volStructDesc *)(bh->b_data + 561 vsd = (struct volStructDesc *)(bh->b_data +
555 (sector & 562 (sector & (sb->s_blocksize - 1)));
556 (sb->s_blocksize - 1)));
557 563
558 if (vsd->stdIdent[0] == 0) { 564 if (vsd->stdIdent[0] == 0) {
559 brelse(bh); 565 brelse(bh);
560 break; 566 break;
561 } else 567 } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_CD001, VSD_STD_ID_LEN)) {
562 if (!strncmp
563 (vsd->stdIdent, VSD_STD_ID_CD001, VSD_STD_ID_LEN)) {
564 iso9660 = sector; 568 iso9660 = sector;
565 switch (vsd->structType) { 569 switch (vsd->structType) {
566 case 0: 570 case 0:
@@ -587,21 +591,13 @@ static int udf_vrs(struct super_block *sb, int silent)
587 vsd->structType); 591 vsd->structType);
588 break; 592 break;
589 } 593 }
590 } else 594 } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_BEA01, VSD_STD_ID_LEN)) {
591 if (!strncmp 595 } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_TEA01, VSD_STD_ID_LEN)) {
592 (vsd->stdIdent, VSD_STD_ID_BEA01, VSD_STD_ID_LEN)) {
593 } else
594 if (!strncmp
595 (vsd->stdIdent, VSD_STD_ID_TEA01, VSD_STD_ID_LEN)) {
596 brelse(bh); 596 brelse(bh);
597 break; 597 break;
598 } else 598 } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR02, VSD_STD_ID_LEN)) {
599 if (!strncmp
600 (vsd->stdIdent, VSD_STD_ID_NSR02, VSD_STD_ID_LEN)) {
601 nsr02 = sector; 599 nsr02 = sector;
602 } else 600 } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR03, VSD_STD_ID_LEN)) {
603 if (!strncmp
604 (vsd->stdIdent, VSD_STD_ID_NSR03, VSD_STD_ID_LEN)) {
605 nsr03 = sector; 601 nsr03 = sector;
606 } 602 }
607 brelse(bh); 603 brelse(bh);
@@ -644,11 +640,10 @@ static void udf_find_anchor(struct super_block *sb)
644 640
645 if (lastblock) { 641 if (lastblock) {
646 int varlastblock = udf_variable_to_fixed(lastblock); 642 int varlastblock = udf_variable_to_fixed(lastblock);
647 int last[] = { lastblock, lastblock - 2, 643 int last[] = { lastblock, lastblock - 2,
648 lastblock - 150, lastblock - 152, 644 lastblock - 150, lastblock - 152,
649 varlastblock, varlastblock - 2, 645 varlastblock, varlastblock - 2,
650 varlastblock - 150, varlastblock - 152 646 varlastblock - 150, varlastblock - 152 };
651 };
652 647
653 lastblock = 0; 648 lastblock = 0;
654 649
@@ -664,88 +659,54 @@ static void udf_find_anchor(struct super_block *sb)
664 if (last[i] < 0 || !(bh = sb_bread(sb, last[i]))) { 659 if (last[i] < 0 || !(bh = sb_bread(sb, last[i]))) {
665 ident = location = 0; 660 ident = location = 0;
666 } else { 661 } else {
667 ident = 662 ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
668 le16_to_cpu(((tag *) bh->b_data)->tagIdent); 663 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
669 location =
670 le32_to_cpu(((tag *) bh->b_data)->
671 tagLocation);
672 brelse(bh); 664 brelse(bh);
673 } 665 }
674 666
675 if (ident == TAG_IDENT_AVDP) { 667 if (ident == TAG_IDENT_AVDP) {
676 if (location == last[i] - UDF_SB_SESSION(sb)) { 668 if (location == last[i] - UDF_SB_SESSION(sb)) {
677 lastblock = UDF_SB_ANCHOR(sb)[0] = 669 lastblock = UDF_SB_ANCHOR(sb)[0] = last[i] - UDF_SB_SESSION(sb);
678 last[i] - UDF_SB_SESSION(sb); 670 UDF_SB_ANCHOR(sb)[1] = last[i] - 256 - UDF_SB_SESSION(sb);
679 UDF_SB_ANCHOR(sb)[1] = 671 } else if (location == udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb)) {
680 last[i] - 256 - UDF_SB_SESSION(sb);
681 } else if (location ==
682 udf_variable_to_fixed(last[i]) -
683 UDF_SB_SESSION(sb)) {
684 UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); 672 UDF_SET_FLAG(sb, UDF_FLAG_VARCONV);
685 lastblock = UDF_SB_ANCHOR(sb)[0] = 673 lastblock = UDF_SB_ANCHOR(sb)[0] = udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb);
686 udf_variable_to_fixed(last[i]) - 674 UDF_SB_ANCHOR(sb)[1] = lastblock - 256 - UDF_SB_SESSION(sb);
687 UDF_SB_SESSION(sb); 675 } else {
688 UDF_SB_ANCHOR(sb)[1] = 676 udf_debug("Anchor found at block %d, location mismatch %d.\n",
689 lastblock - 256 - 677 last[i], location);
690 UDF_SB_SESSION(sb); 678 }
691 } else 679 } else if (ident == TAG_IDENT_FE || ident == TAG_IDENT_EFE) {
692 udf_debug
693 ("Anchor found at block %d, location mismatch %d.\n",
694 last[i], location);
695 } else if (ident == TAG_IDENT_FE
696 || ident == TAG_IDENT_EFE) {
697 lastblock = last[i]; 680 lastblock = last[i];
698 UDF_SB_ANCHOR(sb)[3] = 512; 681 UDF_SB_ANCHOR(sb)[3] = 512;
699 } else { 682 } else {
700 if (last[i] < 256 683 if (last[i] < 256 || !(bh = sb_bread(sb, last[i] - 256))) {
701 || !(bh = sb_bread(sb, last[i] - 256))) {
702 ident = location = 0; 684 ident = location = 0;
703 } else { 685 } else {
704 ident = 686 ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
705 le16_to_cpu(((tag *) bh->b_data)-> 687 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
706 tagIdent);
707 location =
708 le32_to_cpu(((tag *) bh->b_data)->
709 tagLocation);
710 brelse(bh); 688 brelse(bh);
711 } 689 }
712 690
713 if (ident == TAG_IDENT_AVDP && 691 if (ident == TAG_IDENT_AVDP &&
714 location == 692 location == last[i] - 256 - UDF_SB_SESSION(sb)) {
715 last[i] - 256 - UDF_SB_SESSION(sb)) {
716 lastblock = last[i]; 693 lastblock = last[i];
717 UDF_SB_ANCHOR(sb)[1] = last[i] - 256; 694 UDF_SB_ANCHOR(sb)[1] = last[i] - 256;
718 } else { 695 } else {
719 if (last[i] < 312 + UDF_SB_SESSION(sb) 696 if (last[i] < 312 + UDF_SB_SESSION(sb) ||
720 || !(bh = 697 !(bh = sb_bread(sb, last[i] - 312 - UDF_SB_SESSION(sb)))) {
721 sb_bread(sb,
722 last[i] - 312 -
723 UDF_SB_SESSION(sb))))
724 {
725 ident = location = 0; 698 ident = location = 0;
726 } else { 699 } else {
727 ident = 700 ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
728 le16_to_cpu(((tag *) bh-> 701 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
729 b_data)->
730 tagIdent);
731 location =
732 le32_to_cpu(((tag *) bh->
733 b_data)->
734 tagLocation);
735 brelse(bh); 702 brelse(bh);
736 } 703 }
737 704
738 if (ident == TAG_IDENT_AVDP && 705 if (ident == TAG_IDENT_AVDP &&
739 location == 706 location == udf_variable_to_fixed(last[i]) - 256) {
740 udf_variable_to_fixed(last[i]) - 707 UDF_SET_FLAG(sb, UDF_FLAG_VARCONV);
741 256) { 708 lastblock = udf_variable_to_fixed(last[i]);
742 UDF_SET_FLAG(sb, 709 UDF_SB_ANCHOR(sb)[1] = lastblock - 256;
743 UDF_FLAG_VARCONV);
744 lastblock =
745 udf_variable_to_fixed(last
746 [i]);
747 UDF_SB_ANCHOR(sb)[1] =
748 lastblock - 256;
749 } 710 }
750 } 711 }
751 } 712 }
@@ -755,9 +716,8 @@ static void udf_find_anchor(struct super_block *sb)
755 if (!lastblock) { 716 if (!lastblock) {
756 /* We havn't found the lastblock. check 312 */ 717 /* We havn't found the lastblock. check 312 */
757 if ((bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb)))) { 718 if ((bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb)))) {
758 ident = le16_to_cpu(((tag *) bh->b_data)->tagIdent); 719 ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
759 location = 720 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
760 le32_to_cpu(((tag *) bh->b_data)->tagLocation);
761 brelse(bh); 721 brelse(bh);
762 722
763 if (ident == TAG_IDENT_AVDP && location == 256) 723 if (ident == TAG_IDENT_AVDP && location == 256)
@@ -767,19 +727,13 @@ static void udf_find_anchor(struct super_block *sb)
767 727
768 for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) { 728 for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) {
769 if (UDF_SB_ANCHOR(sb)[i]) { 729 if (UDF_SB_ANCHOR(sb)[i]) {
770 if (!(bh = udf_read_tagged(sb, 730 if (!(bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i],
771 UDF_SB_ANCHOR(sb)[i], 731 UDF_SB_ANCHOR(sb)[i], &ident))) {
772 UDF_SB_ANCHOR(sb)[i],
773 &ident))) {
774 UDF_SB_ANCHOR(sb)[i] = 0; 732 UDF_SB_ANCHOR(sb)[i] = 0;
775 } else { 733 } else {
776 brelse(bh); 734 brelse(bh);
777 if ((ident != TAG_IDENT_AVDP) && (i || 735 if ((ident != TAG_IDENT_AVDP) &&
778 (ident != 736 (i || (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE))) {
779 TAG_IDENT_FE
780 && ident !=
781 TAG_IDENT_EFE)))
782 {
783 UDF_SB_ANCHOR(sb)[i] = 0; 737 UDF_SB_ANCHOR(sb)[i] = 0;
784 } 738 }
785 } 739 }
@@ -789,9 +743,7 @@ static void udf_find_anchor(struct super_block *sb)
789 UDF_SB_LASTBLOCK(sb) = lastblock; 743 UDF_SB_LASTBLOCK(sb) = lastblock;
790} 744}
791 745
792static int 746static int udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, kernel_lb_addr *root)
793udf_find_fileset(struct super_block *sb, kernel_lb_addr * fileset,
794 kernel_lb_addr * root)
795{ 747{
796 struct buffer_head *bh = NULL; 748 struct buffer_head *bh = NULL;
797 long lastblock; 749 long lastblock;
@@ -801,18 +753,19 @@ udf_find_fileset(struct super_block *sb, kernel_lb_addr * fileset,
801 fileset->partitionReferenceNum != 0xFFFF) { 753 fileset->partitionReferenceNum != 0xFFFF) {
802 bh = udf_read_ptagged(sb, *fileset, 0, &ident); 754 bh = udf_read_ptagged(sb, *fileset, 0, &ident);
803 755
804 if (!bh) 756 if (!bh) {
805 return 1; 757 return 1;
806 else if (ident != TAG_IDENT_FSD) { 758 } else if (ident != TAG_IDENT_FSD) {
807 brelse(bh); 759 brelse(bh);
808 return 1; 760 return 1;
809 } 761 }
810 762
811 } 763 }
812 764
813 if (!bh) { /* Search backwards through the partitions */ 765 if (!bh) { /* Search backwards through the partitions */
814 kernel_lb_addr newfileset; 766 kernel_lb_addr newfileset;
815 767
768/* --> cvg: FIXME - is it reasonable? */
816 return 1; 769 return 1;
817 770
818 for (newfileset.partitionReferenceNum = UDF_SB_NUMPARTS(sb) - 1; 771 for (newfileset.partitionReferenceNum = UDF_SB_NUMPARTS(sb) - 1;
@@ -820,14 +773,11 @@ udf_find_fileset(struct super_block *sb, kernel_lb_addr * fileset,
820 fileset->logicalBlockNum == 0xFFFFFFFF && 773 fileset->logicalBlockNum == 0xFFFFFFFF &&
821 fileset->partitionReferenceNum == 0xFFFF); 774 fileset->partitionReferenceNum == 0xFFFF);
822 newfileset.partitionReferenceNum--) { 775 newfileset.partitionReferenceNum--) {
823 lastblock = 776 lastblock = UDF_SB_PARTLEN(sb, newfileset.partitionReferenceNum);
824 UDF_SB_PARTLEN(sb,
825 newfileset.partitionReferenceNum);
826 newfileset.logicalBlockNum = 0; 777 newfileset.logicalBlockNum = 0;
827 778
828 do { 779 do {
829 bh = udf_read_ptagged(sb, newfileset, 0, 780 bh = udf_read_ptagged(sb, newfileset, 0, &ident);
830 &ident);
831 if (!bh) { 781 if (!bh) {
832 newfileset.logicalBlockNum++; 782 newfileset.logicalBlockNum++;
833 continue; 783 continue;
@@ -835,38 +785,28 @@ udf_find_fileset(struct super_block *sb, kernel_lb_addr * fileset,
835 785
836 switch (ident) { 786 switch (ident) {
837 case TAG_IDENT_SBD: 787 case TAG_IDENT_SBD:
838 { 788 {
839 struct spaceBitmapDesc *sp; 789 struct spaceBitmapDesc *sp;
840 sp = (struct spaceBitmapDesc *) 790 sp = (struct spaceBitmapDesc *)bh->b_data;
841 bh->b_data; 791 newfileset.logicalBlockNum += 1 +
842 newfileset.logicalBlockNum += 792 ((le32_to_cpu(sp->numOfBytes) +
843 1 + 793 sizeof(struct spaceBitmapDesc) - 1)
844 ((le32_to_cpu 794 >> sb->s_blocksize_bits);
845 (sp->numOfBytes) + 795 brelse(bh);
846 sizeof(struct 796 break;
847 spaceBitmapDesc) - 797 }
848 1)
849 >> sb->s_blocksize_bits);
850 brelse(bh);
851 break;
852 }
853 case TAG_IDENT_FSD: 798 case TAG_IDENT_FSD:
854 { 799 *fileset = newfileset;
855 *fileset = newfileset; 800 break;
856 break;
857 }
858 default: 801 default:
859 { 802 newfileset.logicalBlockNum++;
860 newfileset.logicalBlockNum++; 803 brelse(bh);
861 brelse(bh); 804 bh = NULL;
862 bh = NULL; 805 break;
863 break;
864 }
865 } 806 }
866 } 807 } while (newfileset.logicalBlockNum < lastblock &&
867 while (newfileset.logicalBlockNum < lastblock && 808 fileset->logicalBlockNum == 0xFFFFFFFF &&
868 fileset->logicalBlockNum == 0xFFFFFFFF && 809 fileset->partitionReferenceNum == 0xFFFF);
869 fileset->partitionReferenceNum == 0xFFFF);
870 } 810 }
871 } 811 }
872 812
@@ -898,10 +838,10 @@ static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh)
898 lets_to_cpu(pvoldesc->recordingDateAndTime))) { 838 lets_to_cpu(pvoldesc->recordingDateAndTime))) {
899 kernel_timestamp ts; 839 kernel_timestamp ts;
900 ts = lets_to_cpu(pvoldesc->recordingDateAndTime); 840 ts = lets_to_cpu(pvoldesc->recordingDateAndTime);
901 udf_debug 841 udf_debug("recording time %ld/%ld, %04u/%02u/%02u %02u:%02u (%x)\n",
902 ("recording time %ld/%ld, %04u/%02u/%02u %02u:%02u (%x)\n", 842 recording, recording_usec,
903 recording, recording_usec, ts.year, ts.month, ts.day, 843 ts.year, ts.month, ts.day, ts.hour,
904 ts.hour, ts.minute, ts.typeAndTimezone); 844 ts.minute, ts.typeAndTimezone);
905 UDF_SB_RECORDTIME(sb).tv_sec = recording; 845 UDF_SB_RECORDTIME(sb).tv_sec = recording;
906 UDF_SB_RECORDTIME(sb).tv_nsec = recording_usec * 1000; 846 UDF_SB_RECORDTIME(sb).tv_nsec = recording_usec * 1000;
907 } 847 }
@@ -920,9 +860,8 @@ static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh)
920 } 860 }
921} 861}
922 862
923static void 863static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh,
924udf_load_fileset(struct super_block *sb, struct buffer_head *bh, 864 kernel_lb_addr *root)
925 kernel_lb_addr * root)
926{ 865{
927 struct fileSetDesc *fset; 866 struct fileSetDesc *fset;
928 867
@@ -945,121 +884,72 @@ static void udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
945 884
946 for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { 885 for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) {
947 udf_debug("Searching map: (%d == %d)\n", 886 udf_debug("Searching map: (%d == %d)\n",
948 UDF_SB_PARTMAPS(sb)[i].s_partition_num, 887 UDF_SB_PARTMAPS(sb)[i].s_partition_num, le16_to_cpu(p->partitionNumber));
949 le16_to_cpu(p->partitionNumber)); 888 if (UDF_SB_PARTMAPS(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber)) {
950 if (UDF_SB_PARTMAPS(sb)[i].s_partition_num == 889 UDF_SB_PARTLEN(sb,i) = le32_to_cpu(p->partitionLength); /* blocks */
951 le16_to_cpu(p->partitionNumber)) { 890 UDF_SB_PARTROOT(sb,i) = le32_to_cpu(p->partitionStartingLocation);
952 UDF_SB_PARTLEN(sb, i) = le32_to_cpu(p->partitionLength); /* blocks */ 891 if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_READ_ONLY)
953 UDF_SB_PARTROOT(sb, i) = 892 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_READ_ONLY;
954 le32_to_cpu(p->partitionStartingLocation); 893 if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_WRITE_ONCE)
955 if (le32_to_cpu(p->accessType) == 894 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_WRITE_ONCE;
956 PD_ACCESS_TYPE_READ_ONLY) 895 if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_REWRITABLE)
957 UDF_SB_PARTFLAGS(sb, i) |= 896 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_REWRITABLE;
958 UDF_PART_FLAG_READ_ONLY; 897 if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_OVERWRITABLE)
959 if (le32_to_cpu(p->accessType) == 898 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_OVERWRITABLE;
960 PD_ACCESS_TYPE_WRITE_ONCE) 899
961 UDF_SB_PARTFLAGS(sb, i) |= 900 if (!strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) ||
962 UDF_PART_FLAG_WRITE_ONCE; 901 !strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03)) {
963 if (le32_to_cpu(p->accessType) ==
964 PD_ACCESS_TYPE_REWRITABLE)
965 UDF_SB_PARTFLAGS(sb, i) |=
966 UDF_PART_FLAG_REWRITABLE;
967 if (le32_to_cpu(p->accessType) ==
968 PD_ACCESS_TYPE_OVERWRITABLE)
969 UDF_SB_PARTFLAGS(sb, i) |=
970 UDF_PART_FLAG_OVERWRITABLE;
971
972 if (!strcmp
973 (p->partitionContents.ident,
974 PD_PARTITION_CONTENTS_NSR02)
975 || !strcmp(p->partitionContents.ident,
976 PD_PARTITION_CONTENTS_NSR03)) {
977 struct partitionHeaderDesc *phd; 902 struct partitionHeaderDesc *phd;
978 903
979 phd = 904 phd = (struct partitionHeaderDesc *)(p->partitionContentsUse);
980 (struct partitionHeaderDesc *)(p->
981 partitionContentsUse);
982 if (phd->unallocSpaceTable.extLength) { 905 if (phd->unallocSpaceTable.extLength) {
983 kernel_lb_addr loc = 906 kernel_lb_addr loc = {
984 { le32_to_cpu(phd-> 907 .logicalBlockNum = le32_to_cpu(phd->unallocSpaceTable.extPosition),
985 unallocSpaceTable. 908 .partitionReferenceNum = i,
986 extPosition), i }; 909 };
987 910
988 UDF_SB_PARTMAPS(sb)[i].s_uspace. 911 UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table =
989 s_table = udf_iget(sb, loc); 912 udf_iget(sb, loc);
990 UDF_SB_PARTFLAGS(sb, i) |= 913 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_TABLE;
991 UDF_PART_FLAG_UNALLOC_TABLE; 914 udf_debug("unallocSpaceTable (part %d) @ %ld\n",
992 udf_debug 915 i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table->i_ino);
993 ("unallocSpaceTable (part %d) @ %ld\n",
994 i,
995 UDF_SB_PARTMAPS(sb)[i].s_uspace.
996 s_table->i_ino);
997 } 916 }
998 if (phd->unallocSpaceBitmap.extLength) { 917 if (phd->unallocSpaceBitmap.extLength) {
999 UDF_SB_ALLOC_BITMAP(sb, i, s_uspace); 918 UDF_SB_ALLOC_BITMAP(sb, i, s_uspace);
1000 if (UDF_SB_PARTMAPS(sb)[i].s_uspace. 919 if (UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap != NULL) {
1001 s_bitmap != NULL) { 920 UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extLength =
1002 UDF_SB_PARTMAPS(sb)[i].s_uspace. 921 le32_to_cpu(phd->unallocSpaceBitmap.extLength);
1003 s_bitmap->s_extLength = 922 UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition =
1004 le32_to_cpu(phd-> 923 le32_to_cpu(phd->unallocSpaceBitmap.extPosition);
1005 unallocSpaceBitmap. 924 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_BITMAP;
1006 extLength); 925 udf_debug("unallocSpaceBitmap (part %d) @ %d\n",
1007 UDF_SB_PARTMAPS(sb)[i].s_uspace. 926 i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition);
1008 s_bitmap->s_extPosition =
1009 le32_to_cpu(phd->
1010 unallocSpaceBitmap.
1011 extPosition);
1012 UDF_SB_PARTFLAGS(sb, i) |=
1013 UDF_PART_FLAG_UNALLOC_BITMAP;
1014 udf_debug
1015 ("unallocSpaceBitmap (part %d) @ %d\n",
1016 i,
1017 UDF_SB_PARTMAPS(sb)[i].
1018 s_uspace.s_bitmap->
1019 s_extPosition);
1020 } 927 }
1021 } 928 }
1022 if (phd->partitionIntegrityTable.extLength) 929 if (phd->partitionIntegrityTable.extLength)
1023 udf_debug 930 udf_debug("partitionIntegrityTable (part %d)\n", i);
1024 ("partitionIntegrityTable (part %d)\n",
1025 i);
1026 if (phd->freedSpaceTable.extLength) { 931 if (phd->freedSpaceTable.extLength) {
1027 kernel_lb_addr loc = 932 kernel_lb_addr loc = {
1028 { le32_to_cpu(phd->freedSpaceTable. 933 .logicalBlockNum = le32_to_cpu(phd->freedSpaceTable.extPosition),
1029 extPosition), i }; 934 .partitionReferenceNum = i,
1030 935 };
1031 UDF_SB_PARTMAPS(sb)[i].s_fspace. 936
1032 s_table = udf_iget(sb, loc); 937 UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table =
1033 UDF_SB_PARTFLAGS(sb, i) |= 938 udf_iget(sb, loc);
1034 UDF_PART_FLAG_FREED_TABLE; 939 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_TABLE;
1035 udf_debug 940 udf_debug("freedSpaceTable (part %d) @ %ld\n",
1036 ("freedSpaceTable (part %d) @ %ld\n", 941 i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table->i_ino);
1037 i,
1038 UDF_SB_PARTMAPS(sb)[i].s_fspace.
1039 s_table->i_ino);
1040 } 942 }
1041 if (phd->freedSpaceBitmap.extLength) { 943 if (phd->freedSpaceBitmap.extLength) {
1042 UDF_SB_ALLOC_BITMAP(sb, i, s_fspace); 944 UDF_SB_ALLOC_BITMAP(sb, i, s_fspace);
1043 if (UDF_SB_PARTMAPS(sb)[i].s_fspace. 945 if (UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap != NULL) {
1044 s_bitmap != NULL) { 946 UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extLength =
1045 UDF_SB_PARTMAPS(sb)[i].s_fspace. 947 le32_to_cpu(phd->freedSpaceBitmap.extLength);
1046 s_bitmap->s_extLength = 948 UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition =
1047 le32_to_cpu(phd-> 949 le32_to_cpu(phd->freedSpaceBitmap.extPosition);
1048 freedSpaceBitmap. 950 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_BITMAP;
1049 extLength); 951 udf_debug("freedSpaceBitmap (part %d) @ %d\n",
1050 UDF_SB_PARTMAPS(sb)[i].s_fspace. 952 i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition);
1051 s_bitmap->s_extPosition =
1052 le32_to_cpu(phd->
1053 freedSpaceBitmap.
1054 extPosition);
1055 UDF_SB_PARTFLAGS(sb, i) |=
1056 UDF_PART_FLAG_FREED_BITMAP;
1057 udf_debug
1058 ("freedSpaceBitmap (part %d) @ %d\n",
1059 i,
1060 UDF_SB_PARTMAPS(sb)[i].
1061 s_fspace.s_bitmap->
1062 s_extPosition);
1063 } 953 }
1064 } 954 }
1065 } 955 }
@@ -1070,16 +960,14 @@ static void udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
1070 udf_debug("Partition (%d) not found in partition map\n", 960 udf_debug("Partition (%d) not found in partition map\n",
1071 le16_to_cpu(p->partitionNumber)); 961 le16_to_cpu(p->partitionNumber));
1072 } else { 962 } else {
1073 udf_debug 963 udf_debug("Partition (%d:%d type %x) starts at physical %d, block length %d\n",
1074 ("Partition (%d:%d type %x) starts at physical %d, block length %d\n", 964 le16_to_cpu(p->partitionNumber), i, UDF_SB_PARTTYPE(sb,i),
1075 le16_to_cpu(p->partitionNumber), i, UDF_SB_PARTTYPE(sb, i), 965 UDF_SB_PARTROOT(sb,i), UDF_SB_PARTLEN(sb,i));
1076 UDF_SB_PARTROOT(sb, i), UDF_SB_PARTLEN(sb, i));
1077 } 966 }
1078} 967}
1079 968
1080static int 969static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh,
1081udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh, 970 kernel_lb_addr *fileset)
1082 kernel_lb_addr * fileset)
1083{ 971{
1084 struct logicalVolDesc *lvd; 972 struct logicalVolDesc *lvd;
1085 int i, j, offset; 973 int i, j, offset;
@@ -1090,116 +978,69 @@ udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh,
1090 UDF_SB_ALLOC_PARTMAPS(sb, le32_to_cpu(lvd->numPartitionMaps)); 978 UDF_SB_ALLOC_PARTMAPS(sb, le32_to_cpu(lvd->numPartitionMaps));
1091 979
1092 for (i = 0, offset = 0; 980 for (i = 0, offset = 0;
1093 i < UDF_SB_NUMPARTS(sb) 981 i < UDF_SB_NUMPARTS(sb) && offset < le32_to_cpu(lvd->mapTableLength);
1094 && offset < le32_to_cpu(lvd->mapTableLength); 982 i++, offset += ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapLength) {
1095 i++, offset += 983 type = ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapType;
1096 ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->
1097 partitionMapLength) {
1098 type =
1099 ((struct genericPartitionMap *)
1100 &(lvd->partitionMaps[offset]))->partitionMapType;
1101 if (type == 1) { 984 if (type == 1) {
1102 struct genericPartitionMap1 *gpm1 = 985 struct genericPartitionMap1 *gpm1 = (struct genericPartitionMap1 *)&(lvd->partitionMaps[offset]);
1103 (struct genericPartitionMap1 *)&(lvd-> 986 UDF_SB_PARTTYPE(sb,i) = UDF_TYPE1_MAP15;
1104 partitionMaps 987 UDF_SB_PARTVSN(sb,i) = le16_to_cpu(gpm1->volSeqNum);
1105 [offset]); 988 UDF_SB_PARTNUM(sb,i) = le16_to_cpu(gpm1->partitionNum);
1106 UDF_SB_PARTTYPE(sb, i) = UDF_TYPE1_MAP15; 989 UDF_SB_PARTFUNC(sb,i) = NULL;
1107 UDF_SB_PARTVSN(sb, i) = le16_to_cpu(gpm1->volSeqNum);
1108 UDF_SB_PARTNUM(sb, i) = le16_to_cpu(gpm1->partitionNum);
1109 UDF_SB_PARTFUNC(sb, i) = NULL;
1110 } else if (type == 2) { 990 } else if (type == 2) {
1111 struct udfPartitionMap2 *upm2 = 991 struct udfPartitionMap2 *upm2 = (struct udfPartitionMap2 *)&(lvd->partitionMaps[offset]);
1112 (struct udfPartitionMap2 *)&(lvd-> 992 if (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL, strlen(UDF_ID_VIRTUAL))) {
1113 partitionMaps[offset]); 993 if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0150) {
1114 if (!strncmp 994 UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP15;
1115 (upm2->partIdent.ident, UDF_ID_VIRTUAL, 995 UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt15;
1116 strlen(UDF_ID_VIRTUAL))) { 996 } else if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0200) {
1117 if (le16_to_cpu 997 UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP20;
1118 (((__le16 *) upm2->partIdent. 998 UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt20;
1119 identSuffix)[0]) == 0x0150) {
1120 UDF_SB_PARTTYPE(sb, i) =
1121 UDF_VIRTUAL_MAP15;
1122 UDF_SB_PARTFUNC(sb, i) =
1123 udf_get_pblock_virt15;
1124 } else
1125 if (le16_to_cpu
1126 (((__le16 *) upm2->partIdent.
1127 identSuffix)[0]) == 0x0200) {
1128 UDF_SB_PARTTYPE(sb, i) =
1129 UDF_VIRTUAL_MAP20;
1130 UDF_SB_PARTFUNC(sb, i) =
1131 udf_get_pblock_virt20;
1132 } 999 }
1133 } else 1000 } else if (!strncmp(upm2->partIdent.ident, UDF_ID_SPARABLE, strlen(UDF_ID_SPARABLE))) {
1134 if (!strncmp
1135 (upm2->partIdent.ident, UDF_ID_SPARABLE,
1136 strlen(UDF_ID_SPARABLE))) {
1137 uint32_t loc; 1001 uint32_t loc;
1138 uint16_t ident; 1002 uint16_t ident;
1139 struct sparingTable *st; 1003 struct sparingTable *st;
1140 struct sparablePartitionMap *spm = 1004 struct sparablePartitionMap *spm = (struct sparablePartitionMap *)&(lvd->partitionMaps[offset]);
1141 (struct sparablePartitionMap *)&(lvd-> 1005
1142 partitionMaps 1006 UDF_SB_PARTTYPE(sb,i) = UDF_SPARABLE_MAP15;
1143 [offset]); 1007 UDF_SB_TYPESPAR(sb,i).s_packet_len = le16_to_cpu(spm->packetLength);
1144
1145 UDF_SB_PARTTYPE(sb, i) = UDF_SPARABLE_MAP15;
1146 UDF_SB_TYPESPAR(sb, i).s_packet_len =
1147 le16_to_cpu(spm->packetLength);
1148 for (j = 0; j < spm->numSparingTables; j++) { 1008 for (j = 0; j < spm->numSparingTables; j++) {
1149 loc = 1009 loc = le32_to_cpu(spm->locSparingTable[j]);
1150 le32_to_cpu(spm-> 1010 UDF_SB_TYPESPAR(sb,i).s_spar_map[j] =
1151 locSparingTable[j]); 1011 udf_read_tagged(sb, loc, loc, &ident);
1152 UDF_SB_TYPESPAR(sb, i).s_spar_map[j] = 1012 if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL) {
1153 udf_read_tagged(sb, loc, loc, 1013 st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,i).s_spar_map[j]->b_data;
1154 &ident); 1014 if (ident != 0 ||
1155 if (UDF_SB_TYPESPAR(sb, i). 1015 strncmp(st->sparingIdent.ident, UDF_ID_SPARING, strlen(UDF_ID_SPARING))) {
1156 s_spar_map[j] != NULL) { 1016 brelse(UDF_SB_TYPESPAR(sb,i).s_spar_map[j]);
1157 st = (struct sparingTable *) 1017 UDF_SB_TYPESPAR(sb,i).s_spar_map[j] = NULL;
1158 UDF_SB_TYPESPAR(sb,
1159 i).
1160 s_spar_map[j]->b_data;
1161 if (ident != 0
1162 || strncmp(st->sparingIdent.
1163 ident,
1164 UDF_ID_SPARING,
1165 strlen
1166 (UDF_ID_SPARING)))
1167 {
1168 brelse(UDF_SB_TYPESPAR
1169 (sb,
1170 i).
1171 s_spar_map[j]);
1172 UDF_SB_TYPESPAR(sb,
1173 i).
1174 s_spar_map[j] =
1175 NULL;
1176 } 1018 }
1177 } 1019 }
1178 } 1020 }
1179 UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_spar15; 1021 UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_spar15;
1180 } else { 1022 } else {
1181 udf_debug("Unknown ident: %s\n", 1023 udf_debug("Unknown ident: %s\n", upm2->partIdent.ident);
1182 upm2->partIdent.ident);
1183 continue; 1024 continue;
1184 } 1025 }
1185 UDF_SB_PARTVSN(sb, i) = le16_to_cpu(upm2->volSeqNum); 1026 UDF_SB_PARTVSN(sb,i) = le16_to_cpu(upm2->volSeqNum);
1186 UDF_SB_PARTNUM(sb, i) = le16_to_cpu(upm2->partitionNum); 1027 UDF_SB_PARTNUM(sb,i) = le16_to_cpu(upm2->partitionNum);
1187 } 1028 }
1188 udf_debug("Partition (%d:%d) type %d on volume %d\n", 1029 udf_debug("Partition (%d:%d) type %d on volume %d\n",
1189 i, UDF_SB_PARTNUM(sb, i), type, UDF_SB_PARTVSN(sb, 1030 i, UDF_SB_PARTNUM(sb,i), type, UDF_SB_PARTVSN(sb,i));
1190 i));
1191 } 1031 }
1192 1032
1193 if (fileset) { 1033 if (fileset) {
1194 long_ad *la = (long_ad *) & (lvd->logicalVolContentsUse[0]); 1034 long_ad *la = (long_ad *)&(lvd->logicalVolContentsUse[0]);
1195 1035
1196 *fileset = lelb_to_cpu(la->extLocation); 1036 *fileset = lelb_to_cpu(la->extLocation);
1197 udf_debug 1037 udf_debug("FileSet found in LogicalVolDesc at block=%d, partition=%d\n",
1198 ("FileSet found in LogicalVolDesc at block=%d, partition=%d\n", 1038 fileset->logicalBlockNum,
1199 fileset->logicalBlockNum, fileset->partitionReferenceNum); 1039 fileset->partitionReferenceNum);
1200 } 1040 }
1201 if (lvd->integritySeqExt.extLength) 1041 if (lvd->integritySeqExt.extLength)
1202 udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt)); 1042 udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt));
1043
1203 return 0; 1044 return 0;
1204} 1045}
1205 1046
@@ -1219,9 +1060,7 @@ static void udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc)
1219 UDF_SB_LVIDBH(sb) = bh; 1060 UDF_SB_LVIDBH(sb) = bh;
1220 1061
1221 if (UDF_SB_LVID(sb)->nextIntegrityExt.extLength) 1062 if (UDF_SB_LVID(sb)->nextIntegrityExt.extLength)
1222 udf_load_logicalvolint(sb, 1063 udf_load_logicalvolint(sb, leea_to_cpu(UDF_SB_LVID(sb)->nextIntegrityExt));
1223 leea_to_cpu(UDF_SB_LVID(sb)->
1224 nextIntegrityExt));
1225 1064
1226 if (UDF_SB_LVIDBH(sb) != bh) 1065 if (UDF_SB_LVIDBH(sb) != bh)
1227 brelse(bh); 1066 brelse(bh);
@@ -1247,9 +1086,8 @@ static void udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc)
1247 * July 1, 1997 - Andrew E. Mileski 1086 * July 1, 1997 - Andrew E. Mileski
1248 * Written, tested, and released. 1087 * Written, tested, and released.
1249 */ 1088 */
1250static int 1089static int udf_process_sequence(struct super_block *sb, long block, long lastblock,
1251udf_process_sequence(struct super_block *sb, long block, long lastblock, 1090 kernel_lb_addr *fileset)
1252 kernel_lb_addr * fileset)
1253{ 1091{
1254 struct buffer_head *bh = NULL; 1092 struct buffer_head *bh = NULL;
1255 struct udf_vds_record vds[VDS_POS_LENGTH]; 1093 struct udf_vds_record vds[VDS_POS_LENGTH];
@@ -1274,82 +1112,71 @@ udf_process_sequence(struct super_block *sb, long block, long lastblock,
1274 gd = (struct generic_desc *)bh->b_data; 1112 gd = (struct generic_desc *)bh->b_data;
1275 vdsn = le32_to_cpu(gd->volDescSeqNum); 1113 vdsn = le32_to_cpu(gd->volDescSeqNum);
1276 switch (ident) { 1114 switch (ident) {
1277 case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */ 1115 case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */
1278 if (vdsn >= vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum) { 1116 if (vdsn >= vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum) {
1279 vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum = 1117 vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum = vdsn;
1280 vdsn;
1281 vds[VDS_POS_PRIMARY_VOL_DESC].block = block; 1118 vds[VDS_POS_PRIMARY_VOL_DESC].block = block;
1282 } 1119 }
1283 break; 1120 break;
1284 case TAG_IDENT_VDP: /* ISO 13346 3/10.3 */ 1121 case TAG_IDENT_VDP: /* ISO 13346 3/10.3 */
1285 if (vdsn >= vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum) { 1122 if (vdsn >= vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum) {
1286 vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum = vdsn; 1123 vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum = vdsn;
1287 vds[VDS_POS_VOL_DESC_PTR].block = block; 1124 vds[VDS_POS_VOL_DESC_PTR].block = block;
1288 1125
1289 vdp = (struct volDescPtr *)bh->b_data; 1126 vdp = (struct volDescPtr *)bh->b_data;
1290 next_s = 1127 next_s = le32_to_cpu(vdp->nextVolDescSeqExt.extLocation);
1291 le32_to_cpu(vdp->nextVolDescSeqExt. 1128 next_e = le32_to_cpu(vdp->nextVolDescSeqExt.extLength);
1292 extLocation);
1293 next_e =
1294 le32_to_cpu(vdp->nextVolDescSeqExt.
1295 extLength);
1296 next_e = next_e >> sb->s_blocksize_bits; 1129 next_e = next_e >> sb->s_blocksize_bits;
1297 next_e += next_s; 1130 next_e += next_s;
1298 } 1131 }
1299 break; 1132 break;
1300 case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */ 1133 case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */
1301 if (vdsn >= vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum) { 1134 if (vdsn >= vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum) {
1302 vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum = 1135 vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum = vdsn;
1303 vdsn;
1304 vds[VDS_POS_IMP_USE_VOL_DESC].block = block; 1136 vds[VDS_POS_IMP_USE_VOL_DESC].block = block;
1305 } 1137 }
1306 break; 1138 break;
1307 case TAG_IDENT_PD: /* ISO 13346 3/10.5 */ 1139 case TAG_IDENT_PD: /* ISO 13346 3/10.5 */
1308 if (!vds[VDS_POS_PARTITION_DESC].block) 1140 if (!vds[VDS_POS_PARTITION_DESC].block)
1309 vds[VDS_POS_PARTITION_DESC].block = block; 1141 vds[VDS_POS_PARTITION_DESC].block = block;
1310 break; 1142 break;
1311 case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */ 1143 case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */
1312 if (vdsn >= vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum) { 1144 if (vdsn >= vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum) {
1313 vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum = 1145 vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum = vdsn;
1314 vdsn;
1315 vds[VDS_POS_LOGICAL_VOL_DESC].block = block; 1146 vds[VDS_POS_LOGICAL_VOL_DESC].block = block;
1316 } 1147 }
1317 break; 1148 break;
1318 case TAG_IDENT_USD: /* ISO 13346 3/10.8 */ 1149 case TAG_IDENT_USD: /* ISO 13346 3/10.8 */
1319 if (vdsn >= 1150 if (vdsn >= vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum) {
1320 vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum) { 1151 vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum = vdsn;
1321 vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum =
1322 vdsn;
1323 vds[VDS_POS_UNALLOC_SPACE_DESC].block = block; 1152 vds[VDS_POS_UNALLOC_SPACE_DESC].block = block;
1324 } 1153 }
1325 break; 1154 break;
1326 case TAG_IDENT_TD: /* ISO 13346 3/10.9 */ 1155 case TAG_IDENT_TD: /* ISO 13346 3/10.9 */
1327 vds[VDS_POS_TERMINATING_DESC].block = block; 1156 vds[VDS_POS_TERMINATING_DESC].block = block;
1328 if (next_e) { 1157 if (next_e) {
1329 block = next_s; 1158 block = next_s;
1330 lastblock = next_e; 1159 lastblock = next_e;
1331 next_s = next_e = 0; 1160 next_s = next_e = 0;
1332 } else 1161 } else {
1333 done = 1; 1162 done = 1;
1163 }
1334 break; 1164 break;
1335 } 1165 }
1336 brelse(bh); 1166 brelse(bh);
1337 } 1167 }
1338 for (i = 0; i < VDS_POS_LENGTH; i++) { 1168 for (i = 0; i < VDS_POS_LENGTH; i++) {
1339 if (vds[i].block) { 1169 if (vds[i].block) {
1340 bh = udf_read_tagged(sb, vds[i].block, vds[i].block, 1170 bh = udf_read_tagged(sb, vds[i].block, vds[i].block, &ident);
1341 &ident);
1342 1171
1343 if (i == VDS_POS_PRIMARY_VOL_DESC) 1172 if (i == VDS_POS_PRIMARY_VOL_DESC) {
1344 udf_load_pvoldesc(sb, bh); 1173 udf_load_pvoldesc(sb, bh);
1345 else if (i == VDS_POS_LOGICAL_VOL_DESC) 1174 } else if (i == VDS_POS_LOGICAL_VOL_DESC) {
1346 udf_load_logicalvol(sb, bh, fileset); 1175 udf_load_logicalvol(sb, bh, fileset);
1347 else if (i == VDS_POS_PARTITION_DESC) { 1176 } else if (i == VDS_POS_PARTITION_DESC) {
1348 struct buffer_head *bh2 = NULL; 1177 struct buffer_head *bh2 = NULL;
1349 udf_load_partdesc(sb, bh); 1178 udf_load_partdesc(sb, bh);
1350 for (j = vds[i].block + 1; 1179 for (j = vds[i].block + 1; j < vds[VDS_POS_TERMINATING_DESC].block; j++) {
1351 j < vds[VDS_POS_TERMINATING_DESC].block;
1352 j++) {
1353 bh2 = udf_read_tagged(sb, j, j, &ident); 1180 bh2 = udf_read_tagged(sb, j, j, &ident);
1354 gd = (struct generic_desc *)bh2->b_data; 1181 gd = (struct generic_desc *)bh2->b_data;
1355 if (ident == TAG_IDENT_PD) 1182 if (ident == TAG_IDENT_PD)
@@ -1378,16 +1205,17 @@ static int udf_check_valid(struct super_block *sb, int novrs, int silent)
1378 /* Check that it is NSR02 compliant */ 1205 /* Check that it is NSR02 compliant */
1379 /* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */ 1206 /* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */
1380 else if ((block = udf_vrs(sb, silent)) == -1) { 1207 else if ((block = udf_vrs(sb, silent)) == -1) {
1381 udf_debug 1208 udf_debug("Failed to read byte 32768. Assuming open disc. "
1382 ("Failed to read byte 32768. Assuming open disc. Skipping validity check\n"); 1209 "Skipping validity check\n");
1383 if (!UDF_SB_LASTBLOCK(sb)) 1210 if (!UDF_SB_LASTBLOCK(sb))
1384 UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb); 1211 UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb);
1385 return 0; 1212 return 0;
1386 } else 1213 } else {
1387 return !block; 1214 return !block;
1215 }
1388} 1216}
1389 1217
1390static int udf_load_partition(struct super_block *sb, kernel_lb_addr * fileset) 1218static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
1391{ 1219{
1392 struct anchorVolDescPtr *anchor; 1220 struct anchorVolDescPtr *anchor;
1393 uint16_t ident; 1221 uint16_t ident;
@@ -1399,28 +1227,20 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr * fileset)
1399 return 1; 1227 return 1;
1400 1228
1401 for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) { 1229 for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) {
1402 if (UDF_SB_ANCHOR(sb)[i] && (bh = udf_read_tagged(sb, 1230 if (UDF_SB_ANCHOR(sb)[i] &&
1403 UDF_SB_ANCHOR 1231 (bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i],
1404 (sb)[i], 1232 UDF_SB_ANCHOR(sb)[i], &ident))) {
1405 UDF_SB_ANCHOR
1406 (sb)[i],
1407 &ident))) {
1408 anchor = (struct anchorVolDescPtr *)bh->b_data; 1233 anchor = (struct anchorVolDescPtr *)bh->b_data;
1409 1234
1410 /* Locate the main sequence */ 1235 /* Locate the main sequence */
1411 main_s = 1236 main_s = le32_to_cpu(anchor->mainVolDescSeqExt.extLocation);
1412 le32_to_cpu(anchor->mainVolDescSeqExt.extLocation); 1237 main_e = le32_to_cpu(anchor->mainVolDescSeqExt.extLength );
1413 main_e =
1414 le32_to_cpu(anchor->mainVolDescSeqExt.extLength);
1415 main_e = main_e >> sb->s_blocksize_bits; 1238 main_e = main_e >> sb->s_blocksize_bits;
1416 main_e += main_s; 1239 main_e += main_s;
1417 1240
1418 /* Locate the reserve sequence */ 1241 /* Locate the reserve sequence */
1419 reserve_s = 1242 reserve_s = le32_to_cpu(anchor->reserveVolDescSeqExt.extLocation);
1420 le32_to_cpu(anchor->reserveVolDescSeqExt. 1243 reserve_e = le32_to_cpu(anchor->reserveVolDescSeqExt.extLength);
1421 extLocation);
1422 reserve_e =
1423 le32_to_cpu(anchor->reserveVolDescSeqExt.extLength);
1424 reserve_e = reserve_e >> sb->s_blocksize_bits; 1244 reserve_e = reserve_e >> sb->s_blocksize_bits;
1425 reserve_e += reserve_s; 1245 reserve_e += reserve_s;
1426 1246
@@ -1428,10 +1248,8 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr * fileset)
1428 1248
1429 /* Process the main & reserve sequences */ 1249 /* Process the main & reserve sequences */
1430 /* responsible for finding the PartitionDesc(s) */ 1250 /* responsible for finding the PartitionDesc(s) */
1431 if (! 1251 if (!(udf_process_sequence(sb, main_s, main_e, fileset) &&
1432 (udf_process_sequence(sb, main_s, main_e, fileset) 1252 udf_process_sequence(sb, reserve_s, reserve_e, fileset))) {
1433 && udf_process_sequence(sb, reserve_s, reserve_e,
1434 fileset))) {
1435 break; 1253 break;
1436 } 1254 }
1437 } 1255 }
@@ -1444,81 +1262,67 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr * fileset)
1444 udf_debug("Using anchor in block %d\n", UDF_SB_ANCHOR(sb)[i]); 1262 udf_debug("Using anchor in block %d\n", UDF_SB_ANCHOR(sb)[i]);
1445 1263
1446 for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { 1264 for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) {
1265 kernel_lb_addr uninitialized_var(ino);
1447 switch (UDF_SB_PARTTYPE(sb, i)) { 1266 switch (UDF_SB_PARTTYPE(sb, i)) {
1448 case UDF_VIRTUAL_MAP15: 1267 case UDF_VIRTUAL_MAP15:
1449 case UDF_VIRTUAL_MAP20: 1268 case UDF_VIRTUAL_MAP20:
1450 { 1269 if (!UDF_SB_LASTBLOCK(sb)) {
1451 kernel_lb_addr uninitialized_var(ino); 1270 UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb);
1271 udf_find_anchor(sb);
1272 }
1452 1273
1453 if (!UDF_SB_LASTBLOCK(sb)) { 1274 if (!UDF_SB_LASTBLOCK(sb)) {
1454 UDF_SB_LASTBLOCK(sb) = 1275 udf_debug("Unable to determine Lastblock (For "
1455 udf_get_last_block(sb); 1276 "Virtual Partition)\n");
1456 udf_find_anchor(sb); 1277 return 1;
1457 } 1278 }
1458 1279
1459 if (!UDF_SB_LASTBLOCK(sb)) { 1280 for (j = 0; j < UDF_SB_NUMPARTS(sb); j++) {
1460 udf_debug 1281 if (j != i && UDF_SB_PARTVSN(sb, i) ==
1461 ("Unable to determine Lastblock (For Virtual Partition)\n"); 1282 UDF_SB_PARTVSN(sb, j) &&
1462 return 1; 1283 UDF_SB_PARTNUM(sb, i) ==
1284 UDF_SB_PARTNUM(sb, j)) {
1285 ino.partitionReferenceNum = j;
1286 ino.logicalBlockNum =
1287 UDF_SB_LASTBLOCK(sb) -
1288 UDF_SB_PARTROOT(sb, j);
1289 break;
1463 } 1290 }
1291 }
1464 1292
1465 for (j = 0; j < UDF_SB_NUMPARTS(sb); j++) { 1293 if (j == UDF_SB_NUMPARTS(sb))
1466 if (j != i && 1294 return 1;
1467 UDF_SB_PARTVSN(sb,
1468 i) ==
1469 UDF_SB_PARTVSN(sb, j)
1470 && UDF_SB_PARTNUM(sb,
1471 i) ==
1472 UDF_SB_PARTNUM(sb, j)) {
1473 ino.partitionReferenceNum = j;
1474 ino.logicalBlockNum =
1475 UDF_SB_LASTBLOCK(sb) -
1476 UDF_SB_PARTROOT(sb, j);
1477 break;
1478 }
1479 }
1480 1295
1481 if (j == UDF_SB_NUMPARTS(sb)) 1296 if (!(UDF_SB_VAT(sb) = udf_iget(sb, ino)))
1482 return 1; 1297 return 1;
1483 1298
1484 if (!(UDF_SB_VAT(sb) = udf_iget(sb, ino))) 1299 if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP15) {
1485 return 1; 1300 UDF_SB_TYPEVIRT(sb, i).s_start_offset =
1301 udf_ext0_offset(UDF_SB_VAT(sb));
1302 UDF_SB_TYPEVIRT(sb, i).s_num_entries =
1303 (UDF_SB_VAT(sb)->i_size - 36) >> 2;
1304 } else if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP20) {
1305 struct buffer_head *bh = NULL;
1306 uint32_t pos;
1486 1307
1487 if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP15) { 1308 pos = udf_block_map(UDF_SB_VAT(sb), 0);
1488 UDF_SB_TYPEVIRT(sb, i).s_start_offset = 1309 bh = sb_bread(sb, pos);
1489 udf_ext0_offset(UDF_SB_VAT(sb)); 1310 if (!bh)
1490 UDF_SB_TYPEVIRT(sb, i).s_num_entries = 1311 return 1;
1491 (UDF_SB_VAT(sb)->i_size - 36) >> 2; 1312 UDF_SB_TYPEVIRT(sb, i).s_start_offset =
1492 } else if (UDF_SB_PARTTYPE(sb, i) == 1313 le16_to_cpu(((struct
1493 UDF_VIRTUAL_MAP20) { 1314 virtualAllocationTable20 *)bh->b_data +
1494 struct buffer_head *bh = NULL; 1315 udf_ext0_offset(UDF_SB_VAT(sb)))->
1495 uint32_t pos; 1316 lengthHeader) +
1496 1317 udf_ext0_offset(UDF_SB_VAT(sb));
1497 pos = udf_block_map(UDF_SB_VAT(sb), 0); 1318 UDF_SB_TYPEVIRT(sb, i).s_num_entries =
1498 bh = sb_bread(sb, pos); 1319 (UDF_SB_VAT(sb)->i_size -
1499 if (!bh) 1320 UDF_SB_TYPEVIRT(sb, i).s_start_offset) >> 2;
1500 return 1; 1321 brelse(bh);
1501 UDF_SB_TYPEVIRT(sb, i).s_start_offset =
1502 le16_to_cpu(((struct
1503 virtualAllocationTable20
1504 *)bh->b_data +
1505 udf_ext0_offset
1506 (UDF_SB_VAT(sb)))->
1507 lengthHeader) +
1508 udf_ext0_offset(UDF_SB_VAT(sb));
1509 UDF_SB_TYPEVIRT(sb, i).s_num_entries =
1510 (UDF_SB_VAT(sb)->i_size -
1511 UDF_SB_TYPEVIRT(sb,
1512 i).
1513 s_start_offset) >> 2;
1514 brelse(bh);
1515 }
1516 UDF_SB_PARTROOT(sb, i) =
1517 udf_get_pblock(sb, 0, i, 0);
1518 UDF_SB_PARTLEN(sb, i) =
1519 UDF_SB_PARTLEN(sb,
1520 ino.partitionReferenceNum);
1521 } 1322 }
1323 UDF_SB_PARTROOT(sb, i) = udf_get_pblock(sb, 0, i, 0);
1324 UDF_SB_PARTLEN(sb, i) = UDF_SB_PARTLEN(sb,
1325 ino.partitionReferenceNum);
1522 } 1326 }
1523 } 1327 }
1524 return 0; 1328 return 0;
@@ -1555,42 +1359,32 @@ static void udf_open_lvid(struct super_block *sb)
1555 1359
1556static void udf_close_lvid(struct super_block *sb) 1360static void udf_close_lvid(struct super_block *sb)
1557{ 1361{
1362 kernel_timestamp cpu_time;
1363 int i;
1364
1558 if (UDF_SB_LVIDBH(sb) && 1365 if (UDF_SB_LVIDBH(sb) &&
1559 UDF_SB_LVID(sb)->integrityType == LVID_INTEGRITY_TYPE_OPEN) { 1366 UDF_SB_LVID(sb)->integrityType == LVID_INTEGRITY_TYPE_OPEN) {
1560 int i;
1561 kernel_timestamp cpu_time;
1562
1563 UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; 1367 UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
1564 UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; 1368 UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
1565 if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) 1369 if (udf_time_to_stamp(&cpu_time, CURRENT_TIME))
1566 UDF_SB_LVID(sb)->recordingDateAndTime = 1370 UDF_SB_LVID(sb)->recordingDateAndTime = cpu_to_lets(cpu_time);
1567 cpu_to_lets(cpu_time); 1371 if (UDF_MAX_WRITE_VERSION > le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev))
1568 if (UDF_MAX_WRITE_VERSION > 1372 UDF_SB_LVIDIU(sb)->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION);
1569 le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev)) 1373 if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev))
1570 UDF_SB_LVIDIU(sb)->maxUDFWriteRev = 1374 UDF_SB_LVIDIU(sb)->minUDFReadRev = cpu_to_le16(UDF_SB_UDFREV(sb));
1571 cpu_to_le16(UDF_MAX_WRITE_VERSION); 1375 if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev))
1572 if (UDF_SB_UDFREV(sb) > 1376 UDF_SB_LVIDIU(sb)->minUDFWriteRev = cpu_to_le16(UDF_SB_UDFREV(sb));
1573 le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev)) 1377 UDF_SB_LVID(sb)->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
1574 UDF_SB_LVIDIU(sb)->minUDFReadRev =
1575 cpu_to_le16(UDF_SB_UDFREV(sb));
1576 if (UDF_SB_UDFREV(sb) >
1577 le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev))
1578 UDF_SB_LVIDIU(sb)->minUDFWriteRev =
1579 cpu_to_le16(UDF_SB_UDFREV(sb));
1580 UDF_SB_LVID(sb)->integrityType =
1581 cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
1582 1378
1583 UDF_SB_LVID(sb)->descTag.descCRC = 1379 UDF_SB_LVID(sb)->descTag.descCRC =
1584 cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag), 1380 cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag),
1585 le16_to_cpu(UDF_SB_LVID(sb)->descTag. 1381 le16_to_cpu(UDF_SB_LVID(sb)->descTag.descCRCLength), 0));
1586 descCRCLength), 0));
1587 1382
1588 UDF_SB_LVID(sb)->descTag.tagChecksum = 0; 1383 UDF_SB_LVID(sb)->descTag.tagChecksum = 0;
1589 for (i = 0; i < 16; i++) 1384 for (i = 0; i < 16; i++)
1590 if (i != 4) 1385 if (i != 4)
1591 UDF_SB_LVID(sb)->descTag.tagChecksum += 1386 UDF_SB_LVID(sb)->descTag.tagChecksum +=
1592 ((uint8_t *) & 1387 ((uint8_t *)&(UDF_SB_LVID(sb)->descTag))[i];
1593 (UDF_SB_LVID(sb)->descTag))[i];
1594 1388
1595 mark_buffer_dirty(UDF_SB_LVIDBH(sb)); 1389 mark_buffer_dirty(UDF_SB_LVIDBH(sb));
1596 } 1390 }
@@ -1628,6 +1422,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1628 sbi = kmalloc(sizeof(struct udf_sb_info), GFP_KERNEL); 1422 sbi = kmalloc(sizeof(struct udf_sb_info), GFP_KERNEL);
1629 if (!sbi) 1423 if (!sbi)
1630 return -ENOMEM; 1424 return -ENOMEM;
1425
1631 sb->s_fs_info = sbi; 1426 sb->s_fs_info = sbi;
1632 memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info)); 1427 memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info));
1633 1428
@@ -1679,7 +1474,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1679 UDF_SB_ANCHOR(sb)[2] = uopt.anchor; 1474 UDF_SB_ANCHOR(sb)[2] = uopt.anchor;
1680 UDF_SB_ANCHOR(sb)[3] = 256; 1475 UDF_SB_ANCHOR(sb)[3] = 256;
1681 1476
1682 if (udf_check_valid(sb, uopt.novrs, silent)) { /* read volume recognition sequences */ 1477 if (udf_check_valid(sb, uopt.novrs, silent)) { /* read volume recognition sequences */
1683 printk("UDF-fs: No VRS found\n"); 1478 printk("UDF-fs: No VRS found\n");
1684 goto error_out; 1479 goto error_out;
1685 } 1480 }
@@ -1701,10 +1496,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1701 udf_debug("Lastblock=%d\n", UDF_SB_LASTBLOCK(sb)); 1496 udf_debug("Lastblock=%d\n", UDF_SB_LASTBLOCK(sb));
1702 1497
1703 if (UDF_SB_LVIDBH(sb)) { 1498 if (UDF_SB_LVIDBH(sb)) {
1704 uint16_t minUDFReadRev = 1499 uint16_t minUDFReadRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev);
1705 le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev); 1500 uint16_t minUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev);
1706 uint16_t minUDFWriteRev =
1707 le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev);
1708 /* uint16_t maxUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev); */ 1501 /* uint16_t maxUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev); */
1709 1502
1710 if (minUDFReadRev > UDF_MAX_READ_VERSION) { 1503 if (minUDFReadRev > UDF_MAX_READ_VERSION) {
@@ -1729,10 +1522,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1729 goto error_out; 1522 goto error_out;
1730 } 1523 }
1731 1524
1732 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1525 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_READ_ONLY) {
1733 UDF_PART_FLAG_READ_ONLY) { 1526 printk("UDF-fs: Partition marked readonly; forcing readonly mount\n");
1734 printk
1735 ("UDF-fs: Partition marked readonly; forcing readonly mount\n");
1736 sb->s_flags |= MS_RDONLY; 1527 sb->s_flags |= MS_RDONLY;
1737 } 1528 }
1738 1529
@@ -1744,10 +1535,11 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1744 if (!silent) { 1535 if (!silent) {
1745 kernel_timestamp ts; 1536 kernel_timestamp ts;
1746 udf_time_to_stamp(&ts, UDF_SB_RECORDTIME(sb)); 1537 udf_time_to_stamp(&ts, UDF_SB_RECORDTIME(sb));
1747 udf_info 1538 udf_info("UDF %s (%s) Mounting volume '%s', "
1748 ("UDF %s (%s) Mounting volume '%s', timestamp %04u/%02u/%02u %02u:%02u (%x)\n", 1539 "timestamp %04u/%02u/%02u %02u:%02u (%x)\n",
1749 UDFFS_VERSION, UDFFS_DATE, UDF_SB_VOLIDENT(sb), ts.year, 1540 UDFFS_VERSION, UDFFS_DATE,
1750 ts.month, ts.day, ts.hour, ts.minute, ts.typeAndTimezone); 1541 UDF_SB_VOLIDENT(sb), ts.year, ts.month, ts.day, ts.hour, ts.minute,
1542 ts.typeAndTimezone);
1751 } 1543 }
1752 if (!(sb->s_flags & MS_RDONLY)) 1544 if (!(sb->s_flags & MS_RDONLY))
1753 udf_open_lvid(sb); 1545 udf_open_lvid(sb);
@@ -1772,30 +1564,21 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1772 sb->s_maxbytes = MAX_LFS_FILESIZE; 1564 sb->s_maxbytes = MAX_LFS_FILESIZE;
1773 return 0; 1565 return 0;
1774 1566
1775 error_out: 1567error_out:
1776 if (UDF_SB_VAT(sb)) 1568 if (UDF_SB_VAT(sb))
1777 iput(UDF_SB_VAT(sb)); 1569 iput(UDF_SB_VAT(sb));
1778 if (UDF_SB_NUMPARTS(sb)) { 1570 if (UDF_SB_NUMPARTS(sb)) {
1779 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1571 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
1780 UDF_PART_FLAG_UNALLOC_TABLE) 1572 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
1781 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace. 1573 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
1782 s_table); 1574 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
1783 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1575 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
1784 UDF_PART_FLAG_FREED_TABLE) 1576 UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_uspace);
1785 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace. 1577 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
1786 s_table); 1578 UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_fspace);
1787 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1579 if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) {
1788 UDF_PART_FLAG_UNALLOC_BITMAP)
1789 UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_uspace);
1790 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) &
1791 UDF_PART_FLAG_FREED_BITMAP)
1792 UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_fspace);
1793 if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) ==
1794 UDF_SPARABLE_MAP15) {
1795 for (i = 0; i < 4; i++) 1580 for (i = 0; i < 4; i++)
1796 brelse(UDF_SB_TYPESPAR 1581 brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]);
1797 (sb,
1798 UDF_SB_PARTITION(sb)).s_spar_map[i]);
1799 } 1582 }
1800 } 1583 }
1801#ifdef CONFIG_UDF_NLS 1584#ifdef CONFIG_UDF_NLS
@@ -1808,6 +1591,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1808 UDF_SB_FREE(sb); 1591 UDF_SB_FREE(sb);
1809 kfree(sbi); 1592 kfree(sbi);
1810 sb->s_fs_info = NULL; 1593 sb->s_fs_info = NULL;
1594
1811 return -EINVAL; 1595 return -EINVAL;
1812} 1596}
1813 1597
@@ -1823,8 +1607,8 @@ void udf_error(struct super_block *sb, const char *function,
1823 va_start(args, fmt); 1607 va_start(args, fmt);
1824 vsnprintf(error_buf, sizeof(error_buf), fmt, args); 1608 vsnprintf(error_buf, sizeof(error_buf), fmt, args);
1825 va_end(args); 1609 va_end(args);
1826 printk(KERN_CRIT "UDF-fs error (device %s): %s: %s\n", 1610 printk (KERN_CRIT "UDF-fs error (device %s): %s: %s\n",
1827 sb->s_id, function, error_buf); 1611 sb->s_id, function, error_buf);
1828} 1612}
1829 1613
1830void udf_warning(struct super_block *sb, const char *function, 1614void udf_warning(struct super_block *sb, const char *function,
@@ -1859,26 +1643,17 @@ static void udf_put_super(struct super_block *sb)
1859 if (UDF_SB_VAT(sb)) 1643 if (UDF_SB_VAT(sb))
1860 iput(UDF_SB_VAT(sb)); 1644 iput(UDF_SB_VAT(sb));
1861 if (UDF_SB_NUMPARTS(sb)) { 1645 if (UDF_SB_NUMPARTS(sb)) {
1862 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1646 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
1863 UDF_PART_FLAG_UNALLOC_TABLE) 1647 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
1864 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace. 1648 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
1865 s_table); 1649 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
1866 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1650 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
1867 UDF_PART_FLAG_FREED_TABLE) 1651 UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_uspace);
1868 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace. 1652 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
1869 s_table); 1653 UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_fspace);
1870 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1654 if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) {
1871 UDF_PART_FLAG_UNALLOC_BITMAP)
1872 UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_uspace);
1873 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) &
1874 UDF_PART_FLAG_FREED_BITMAP)
1875 UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_fspace);
1876 if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) ==
1877 UDF_SPARABLE_MAP15) {
1878 for (i = 0; i < 4; i++) 1655 for (i = 0; i < 4; i++)
1879 brelse(UDF_SB_TYPESPAR 1656 brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]);
1880 (sb,
1881 UDF_SB_PARTITION(sb)).s_spar_map[i]);
1882 } 1657 }
1883 } 1658 }
1884#ifdef CONFIG_UDF_NLS 1659#ifdef CONFIG_UDF_NLS
@@ -1917,8 +1692,7 @@ static int udf_statfs(struct dentry *dentry, struct kstatfs *buf)
1917 buf->f_bavail = buf->f_bfree; 1692 buf->f_bavail = buf->f_bfree;
1918 buf->f_files = (UDF_SB_LVIDBH(sb) ? 1693 buf->f_files = (UDF_SB_LVIDBH(sb) ?
1919 (le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + 1694 (le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) +
1920 le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)) : 0) + 1695 le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)) : 0) + buf->f_bfree;
1921 buf->f_bfree;
1922 buf->f_ffree = buf->f_bfree; 1696 buf->f_ffree = buf->f_bfree;
1923 /* __kernel_fsid_t f_fsid */ 1697 /* __kernel_fsid_t f_fsid */
1924 buf->f_namelen = UDF_NAME_LEN - 2; 1698 buf->f_namelen = UDF_NAME_LEN - 2;
@@ -1930,8 +1704,7 @@ static unsigned char udf_bitmap_lookup[16] = {
1930 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 1704 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4
1931}; 1705};
1932 1706
1933static unsigned int 1707static unsigned int udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap)
1934udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap)
1935{ 1708{
1936 struct buffer_head *bh = NULL; 1709 struct buffer_head *bh = NULL;
1937 unsigned int accum = 0; 1710 unsigned int accum = 0;
@@ -1961,8 +1734,8 @@ udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap)
1961 1734
1962 bm = (struct spaceBitmapDesc *)bh->b_data; 1735 bm = (struct spaceBitmapDesc *)bh->b_data;
1963 bytes = le32_to_cpu(bm->numOfBytes); 1736 bytes = le32_to_cpu(bm->numOfBytes);
1964 index = sizeof(struct spaceBitmapDesc); /* offset in first block only */ 1737 index = sizeof(struct spaceBitmapDesc); /* offset in first block only */
1965 ptr = (uint8_t *) bh->b_data; 1738 ptr = (uint8_t *)bh->b_data;
1966 1739
1967 while (bytes > 0) { 1740 while (bytes > 0) {
1968 while ((bytes > 0) && (index < sb->s_blocksize)) { 1741 while ((bytes > 0) && (index < sb->s_blocksize)) {
@@ -1981,19 +1754,18 @@ udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap)
1981 goto out; 1754 goto out;
1982 } 1755 }
1983 index = 0; 1756 index = 0;
1984 ptr = (uint8_t *) bh->b_data; 1757 ptr = (uint8_t *)bh->b_data;
1985 } 1758 }
1986 } 1759 }
1987 brelse(bh); 1760 brelse(bh);
1988 1761
1989 out: 1762out:
1990 unlock_kernel(); 1763 unlock_kernel();
1991 1764
1992 return accum; 1765 return accum;
1993} 1766}
1994 1767
1995static unsigned int 1768static unsigned int udf_count_free_table(struct super_block *sb, struct inode *table)
1996udf_count_free_table(struct super_block *sb, struct inode *table)
1997{ 1769{
1998 unsigned int accum = 0; 1770 unsigned int accum = 0;
1999 uint32_t elen; 1771 uint32_t elen;
@@ -2007,8 +1779,9 @@ udf_count_free_table(struct super_block *sb, struct inode *table)
2007 epos.offset = sizeof(struct unallocSpaceEntry); 1779 epos.offset = sizeof(struct unallocSpaceEntry);
2008 epos.bh = NULL; 1780 epos.bh = NULL;
2009 1781
2010 while ((etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) 1782 while ((etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) {
2011 accum += (elen >> table->i_sb->s_blocksize_bits); 1783 accum += (elen >> table->i_sb->s_blocksize_bits);
1784 }
2012 brelse(epos.bh); 1785 brelse(epos.bh);
2013 1786
2014 unlock_kernel(); 1787 unlock_kernel();
@@ -2021,12 +1794,8 @@ static unsigned int udf_count_free(struct super_block *sb)
2021 unsigned int accum = 0; 1794 unsigned int accum = 0;
2022 1795
2023 if (UDF_SB_LVIDBH(sb)) { 1796 if (UDF_SB_LVIDBH(sb)) {
2024 if (le32_to_cpu(UDF_SB_LVID(sb)->numOfPartitions) > 1797 if (le32_to_cpu(UDF_SB_LVID(sb)->numOfPartitions) > UDF_SB_PARTITION(sb)) {
2025 UDF_SB_PARTITION(sb)) { 1798 accum = le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]);
2026 accum =
2027 le32_to_cpu(UDF_SB_LVID(sb)->
2028 freeSpaceTable[UDF_SB_PARTITION(sb)]);
2029
2030 if (accum == 0xFFFFFFFF) 1799 if (accum == 0xFFFFFFFF)
2031 accum = 0; 1800 accum = 0;
2032 } 1801 }
@@ -2035,40 +1804,24 @@ static unsigned int udf_count_free(struct super_block *sb)
2035 if (accum) 1804 if (accum)
2036 return accum; 1805 return accum;
2037 1806
2038 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1807 if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) {
2039 UDF_PART_FLAG_UNALLOC_BITMAP) { 1808 accum += udf_count_free_bitmap(sb,
2040 accum += 1809 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_bitmap);
2041 udf_count_free_bitmap(sb,
2042 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION
2043 (sb)].s_uspace.
2044 s_bitmap);
2045 } 1810 }
2046 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1811 if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) {
2047 UDF_PART_FLAG_FREED_BITMAP) { 1812 accum += udf_count_free_bitmap(sb,
2048 accum += 1813 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_bitmap);
2049 udf_count_free_bitmap(sb,
2050 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION
2051 (sb)].s_fspace.
2052 s_bitmap);
2053 } 1814 }
2054 if (accum) 1815 if (accum)
2055 return accum; 1816 return accum;
2056 1817
2057 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1818 if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) {
2058 UDF_PART_FLAG_UNALLOC_TABLE) { 1819 accum += udf_count_free_table(sb,
2059 accum += 1820 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
2060 udf_count_free_table(sb,
2061 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION
2062 (sb)].s_uspace.
2063 s_table);
2064 } 1821 }
2065 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1822 if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) {
2066 UDF_PART_FLAG_FREED_TABLE) { 1823 accum += udf_count_free_table(sb,
2067 accum += 1824 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
2068 udf_count_free_table(sb,
2069 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION
2070 (sb)].s_fspace.
2071 s_table);
2072 } 1825 }
2073 1826
2074 return accum; 1827 return accum;