[PATCH] PCI: fix to pci ignore pre-set 64-bit bars on 32-bit platforms
[linux-2.6/s3c2410-cpufreq.git] / fs / udf / super.c
blobe45789fe38e8da1e69dec52c6c7c11be82cac855
1 /*
2 * super.c
4 * PURPOSE
5 * Super block routines for the OSTA-UDF(tm) filesystem.
7 * DESCRIPTION
8 * OSTA-UDF(tm) = Optical Storage Technology Association
9 * Universal Disk Format.
11 * This code is based on version 2.00 of the UDF specification,
12 * and revision 3 of the ECMA 167 standard [equivalent to ISO 13346].
13 * http://www.osta.org/
14 * http://www.ecma.ch/
15 * http://www.iso.org/
17 * COPYRIGHT
18 * This file is distributed under the terms of the GNU General Public
19 * License (GPL). Copies of the GPL can be obtained from:
20 * ftp://prep.ai.mit.edu/pub/gnu/GPL
21 * Each contributing author retains all rights to their own work.
23 * (C) 1998 Dave Boynton
24 * (C) 1998-2004 Ben Fennema
25 * (C) 2000 Stelias Computing Inc
27 * HISTORY
29 * 09/24/98 dgb changed to allow compiling outside of kernel, and
30 * added some debugging.
31 * 10/01/98 dgb updated to allow (some) possibility of compiling w/2.0.34
32 * 10/16/98 attempting some multi-session support
33 * 10/17/98 added freespace count for "df"
34 * 11/11/98 gr added novrs option
35 * 11/26/98 dgb added fileset,anchor mount options
36 * 12/06/98 blf really hosed things royally. vat/sparing support. sequenced vol descs
37 * rewrote option handling based on isofs
38 * 12/20/98 find the free space bitmap (if it exists)
41 #include "udfdecl.h"
43 #include <linux/config.h>
44 #include <linux/blkdev.h>
45 #include <linux/slab.h>
46 #include <linux/kernel.h>
47 #include <linux/module.h>
48 #include <linux/parser.h>
49 #include <linux/stat.h>
50 #include <linux/cdrom.h>
51 #include <linux/nls.h>
52 #include <linux/smp_lock.h>
53 #include <linux/buffer_head.h>
54 #include <linux/vfs.h>
55 #include <linux/vmalloc.h>
56 #include <asm/byteorder.h>
58 #include <linux/udf_fs.h>
59 #include "udf_sb.h"
60 #include "udf_i.h"
62 #include <linux/init.h>
63 #include <asm/uaccess.h>
65 #define VDS_POS_PRIMARY_VOL_DESC 0
66 #define VDS_POS_UNALLOC_SPACE_DESC 1
67 #define VDS_POS_LOGICAL_VOL_DESC 2
68 #define VDS_POS_PARTITION_DESC 3
69 #define VDS_POS_IMP_USE_VOL_DESC 4
70 #define VDS_POS_VOL_DESC_PTR 5
71 #define VDS_POS_TERMINATING_DESC 6
72 #define VDS_POS_LENGTH 7
74 static char error_buf[1024];
76 /* These are the "meat" - everything else is stuffing */
77 static int udf_fill_super(struct super_block *, void *, int);
78 static void udf_put_super(struct super_block *);
79 static void udf_write_super(struct super_block *);
80 static int udf_remount_fs(struct super_block *, int *, char *);
81 static int udf_check_valid(struct super_block *, int, int);
82 static int udf_vrs(struct super_block *sb, int silent);
83 static int udf_load_partition(struct super_block *, kernel_lb_addr *);
84 static int udf_load_logicalvol(struct super_block *, struct buffer_head *, kernel_lb_addr *);
85 static void udf_load_logicalvolint(struct super_block *, kernel_extent_ad);
86 static void udf_find_anchor(struct super_block *);
87 static int udf_find_fileset(struct super_block *, kernel_lb_addr *, kernel_lb_addr *);
88 static void udf_load_pvoldesc(struct super_block *, struct buffer_head *);
89 static void udf_load_fileset(struct super_block *, struct buffer_head *, kernel_lb_addr *);
90 static void udf_load_partdesc(struct super_block *, struct buffer_head *);
91 static void udf_open_lvid(struct super_block *);
92 static void udf_close_lvid(struct super_block *);
93 static unsigned int udf_count_free(struct super_block *);
94 static int udf_statfs(struct super_block *, struct kstatfs *);
96 /* UDF filesystem type */
97 static struct super_block *udf_get_sb(struct file_system_type *fs_type,
98 int flags, const char *dev_name, void *data)
100 return get_sb_bdev(fs_type, flags, dev_name, data, udf_fill_super);
103 static struct file_system_type udf_fstype = {
104 .owner = THIS_MODULE,
105 .name = "udf",
106 .get_sb = udf_get_sb,
107 .kill_sb = kill_block_super,
108 .fs_flags = FS_REQUIRES_DEV,
111 static kmem_cache_t * udf_inode_cachep;
113 static struct inode *udf_alloc_inode(struct super_block *sb)
115 struct udf_inode_info *ei;
116 ei = (struct udf_inode_info *)kmem_cache_alloc(udf_inode_cachep, SLAB_KERNEL);
117 if (!ei)
118 return NULL;
119 return &ei->vfs_inode;
122 static void udf_destroy_inode(struct inode *inode)
124 kmem_cache_free(udf_inode_cachep, UDF_I(inode));
127 static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
129 struct udf_inode_info *ei = (struct udf_inode_info *) foo;
131 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
132 SLAB_CTOR_CONSTRUCTOR)
134 ei->i_ext.i_data = NULL;
135 inode_init_once(&ei->vfs_inode);
139 static int init_inodecache(void)
141 udf_inode_cachep = kmem_cache_create("udf_inode_cache",
142 sizeof(struct udf_inode_info),
143 0, (SLAB_RECLAIM_ACCOUNT|
144 SLAB_MEM_SPREAD),
145 init_once, NULL);
146 if (udf_inode_cachep == NULL)
147 return -ENOMEM;
148 return 0;
151 static void destroy_inodecache(void)
153 if (kmem_cache_destroy(udf_inode_cachep))
154 printk(KERN_INFO "udf_inode_cache: not all structures were freed\n");
157 /* Superblock operations */
158 static struct super_operations udf_sb_ops = {
159 .alloc_inode = udf_alloc_inode,
160 .destroy_inode = udf_destroy_inode,
161 .write_inode = udf_write_inode,
162 .delete_inode = udf_delete_inode,
163 .clear_inode = udf_clear_inode,
164 .put_super = udf_put_super,
165 .write_super = udf_write_super,
166 .statfs = udf_statfs,
167 .remount_fs = udf_remount_fs,
170 struct udf_options
172 unsigned char novrs;
173 unsigned int blocksize;
174 unsigned int session;
175 unsigned int lastblock;
176 unsigned int anchor;
177 unsigned int volume;
178 unsigned short partition;
179 unsigned int fileset;
180 unsigned int rootdir;
181 unsigned int flags;
182 mode_t umask;
183 gid_t gid;
184 uid_t uid;
185 struct nls_table *nls_map;
188 static int __init init_udf_fs(void)
190 int err;
191 err = init_inodecache();
192 if (err)
193 goto out1;
194 err = register_filesystem(&udf_fstype);
195 if (err)
196 goto out;
197 return 0;
198 out:
199 destroy_inodecache();
200 out1:
201 return err;
204 static void __exit exit_udf_fs(void)
206 unregister_filesystem(&udf_fstype);
207 destroy_inodecache();
210 module_init(init_udf_fs)
211 module_exit(exit_udf_fs)
214 * udf_parse_options
216 * PURPOSE
217 * Parse mount options.
219 * DESCRIPTION
220 * The following mount options are supported:
222 * gid= Set the default group.
223 * umask= Set the default umask.
224 * uid= Set the default user.
225 * bs= Set the block size.
226 * unhide Show otherwise hidden files.
227 * undelete Show deleted files in lists.
228 * adinicb Embed data in the inode (default)
229 * noadinicb Don't embed data in the inode
230 * shortad Use short ad's
231 * longad Use long ad's (default)
232 * nostrict Unset strict conformance
233 * iocharset= Set the NLS character set
235 * The remaining are for debugging and disaster recovery:
237 * novrs Skip volume sequence recognition
239 * The following expect a offset from 0.
241 * session= Set the CDROM session (default= last session)
242 * anchor= Override standard anchor location. (default= 256)
243 * volume= Override the VolumeDesc location. (unused)
244 * partition= Override the PartitionDesc location. (unused)
245 * lastblock= Set the last block of the filesystem/
247 * The following expect a offset from the partition root.
249 * fileset= Override the fileset block location. (unused)
250 * rootdir= Override the root directory location. (unused)
251 * WARNING: overriding the rootdir to a non-directory may
252 * yield highly unpredictable results.
254 * PRE-CONDITIONS
255 * options Pointer to mount options string.
256 * uopts Pointer to mount options variable.
258 * POST-CONDITIONS
259 * <return> 1 Mount options parsed okay.
260 * <return> 0 Error parsing mount options.
262 * HISTORY
263 * July 1, 1997 - Andrew E. Mileski
264 * Written, tested, and released.
267 enum {
268 Opt_novrs, Opt_nostrict, Opt_bs, Opt_unhide, Opt_undelete,
269 Opt_noadinicb, Opt_adinicb, Opt_shortad, Opt_longad,
270 Opt_gid, Opt_uid, Opt_umask, Opt_session, Opt_lastblock,
271 Opt_anchor, Opt_volume, Opt_partition, Opt_fileset,
272 Opt_rootdir, Opt_utf8, Opt_iocharset,
273 Opt_err, Opt_uforget, Opt_uignore, Opt_gforget, Opt_gignore
276 static match_table_t tokens = {
277 {Opt_novrs, "novrs"},
278 {Opt_nostrict, "nostrict"},
279 {Opt_bs, "bs=%u"},
280 {Opt_unhide, "unhide"},
281 {Opt_undelete, "undelete"},
282 {Opt_noadinicb, "noadinicb"},
283 {Opt_adinicb, "adinicb"},
284 {Opt_shortad, "shortad"},
285 {Opt_longad, "longad"},
286 {Opt_uforget, "uid=forget"},
287 {Opt_uignore, "uid=ignore"},
288 {Opt_gforget, "gid=forget"},
289 {Opt_gignore, "gid=ignore"},
290 {Opt_gid, "gid=%u"},
291 {Opt_uid, "uid=%u"},
292 {Opt_umask, "umask=%o"},
293 {Opt_session, "session=%u"},
294 {Opt_lastblock, "lastblock=%u"},
295 {Opt_anchor, "anchor=%u"},
296 {Opt_volume, "volume=%u"},
297 {Opt_partition, "partition=%u"},
298 {Opt_fileset, "fileset=%u"},
299 {Opt_rootdir, "rootdir=%u"},
300 {Opt_utf8, "utf8"},
301 {Opt_iocharset, "iocharset=%s"},
302 {Opt_err, NULL}
305 static int
306 udf_parse_options(char *options, struct udf_options *uopt)
308 char *p;
309 int option;
311 uopt->novrs = 0;
312 uopt->blocksize = 2048;
313 uopt->partition = 0xFFFF;
314 uopt->session = 0xFFFFFFFF;
315 uopt->lastblock = 0;
316 uopt->anchor = 0;
317 uopt->volume = 0xFFFFFFFF;
318 uopt->rootdir = 0xFFFFFFFF;
319 uopt->fileset = 0xFFFFFFFF;
320 uopt->nls_map = NULL;
322 if (!options)
323 return 1;
325 while ((p = strsep(&options, ",")) != NULL)
327 substring_t args[MAX_OPT_ARGS];
328 int token;
329 if (!*p)
330 continue;
332 token = match_token(p, tokens, args);
333 switch (token)
335 case Opt_novrs:
336 uopt->novrs = 1;
337 case Opt_bs:
338 if (match_int(&args[0], &option))
339 return 0;
340 uopt->blocksize = option;
341 break;
342 case Opt_unhide:
343 uopt->flags |= (1 << UDF_FLAG_UNHIDE);
344 break;
345 case Opt_undelete:
346 uopt->flags |= (1 << UDF_FLAG_UNDELETE);
347 break;
348 case Opt_noadinicb:
349 uopt->flags &= ~(1 << UDF_FLAG_USE_AD_IN_ICB);
350 break;
351 case Opt_adinicb:
352 uopt->flags |= (1 << UDF_FLAG_USE_AD_IN_ICB);
353 break;
354 case Opt_shortad:
355 uopt->flags |= (1 << UDF_FLAG_USE_SHORT_AD);
356 break;
357 case Opt_longad:
358 uopt->flags &= ~(1 << UDF_FLAG_USE_SHORT_AD);
359 break;
360 case Opt_gid:
361 if (match_int(args, &option))
362 return 0;
363 uopt->gid = option;
364 break;
365 case Opt_uid:
366 if (match_int(args, &option))
367 return 0;
368 uopt->uid = option;
369 break;
370 case Opt_umask:
371 if (match_octal(args, &option))
372 return 0;
373 uopt->umask = option;
374 break;
375 case Opt_nostrict:
376 uopt->flags &= ~(1 << UDF_FLAG_STRICT);
377 break;
378 case Opt_session:
379 if (match_int(args, &option))
380 return 0;
381 uopt->session = option;
382 break;
383 case Opt_lastblock:
384 if (match_int(args, &option))
385 return 0;
386 uopt->lastblock = option;
387 break;
388 case Opt_anchor:
389 if (match_int(args, &option))
390 return 0;
391 uopt->anchor = option;
392 break;
393 case Opt_volume:
394 if (match_int(args, &option))
395 return 0;
396 uopt->volume = option;
397 break;
398 case Opt_partition:
399 if (match_int(args, &option))
400 return 0;
401 uopt->partition = option;
402 break;
403 case Opt_fileset:
404 if (match_int(args, &option))
405 return 0;
406 uopt->fileset = option;
407 break;
408 case Opt_rootdir:
409 if (match_int(args, &option))
410 return 0;
411 uopt->rootdir = option;
412 break;
413 case Opt_utf8:
414 uopt->flags |= (1 << UDF_FLAG_UTF8);
415 break;
416 #ifdef CONFIG_UDF_NLS
417 case Opt_iocharset:
418 uopt->nls_map = load_nls(args[0].from);
419 uopt->flags |= (1 << UDF_FLAG_NLS_MAP);
420 break;
421 #endif
422 case Opt_uignore:
423 uopt->flags |= (1 << UDF_FLAG_UID_IGNORE);
424 break;
425 case Opt_uforget:
426 uopt->flags |= (1 << UDF_FLAG_UID_FORGET);
427 break;
428 case Opt_gignore:
429 uopt->flags |= (1 << UDF_FLAG_GID_IGNORE);
430 break;
431 case Opt_gforget:
432 uopt->flags |= (1 << UDF_FLAG_GID_FORGET);
433 break;
434 default:
435 printk(KERN_ERR "udf: bad mount option \"%s\" "
436 "or missing value\n", p);
437 return 0;
440 return 1;
443 void
444 udf_write_super(struct super_block *sb)
446 lock_kernel();
447 if (!(sb->s_flags & MS_RDONLY))
448 udf_open_lvid(sb);
449 sb->s_dirt = 0;
450 unlock_kernel();
453 static int
454 udf_remount_fs(struct super_block *sb, int *flags, char *options)
456 struct udf_options uopt;
458 uopt.flags = UDF_SB(sb)->s_flags ;
459 uopt.uid = UDF_SB(sb)->s_uid ;
460 uopt.gid = UDF_SB(sb)->s_gid ;
461 uopt.umask = UDF_SB(sb)->s_umask ;
463 if ( !udf_parse_options(options, &uopt) )
464 return -EINVAL;
466 UDF_SB(sb)->s_flags = uopt.flags;
467 UDF_SB(sb)->s_uid = uopt.uid;
468 UDF_SB(sb)->s_gid = uopt.gid;
469 UDF_SB(sb)->s_umask = uopt.umask;
471 if (UDF_SB_LVIDBH(sb)) {
472 int write_rev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev);
473 if (write_rev > UDF_MAX_WRITE_VERSION)
474 *flags |= MS_RDONLY;
477 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
478 return 0;
479 if (*flags & MS_RDONLY)
480 udf_close_lvid(sb);
481 else
482 udf_open_lvid(sb);
484 return 0;
488 * udf_set_blocksize
490 * PURPOSE
491 * Set the block size to be used in all transfers.
493 * DESCRIPTION
494 * To allow room for a DMA transfer, it is best to guess big when unsure.
495 * This routine picks 2048 bytes as the blocksize when guessing. This
496 * should be adequate until devices with larger block sizes become common.
498 * Note that the Linux kernel can currently only deal with blocksizes of
499 * 512, 1024, 2048, 4096, and 8192 bytes.
501 * PRE-CONDITIONS
502 * sb Pointer to _locked_ superblock.
504 * POST-CONDITIONS
505 * sb->s_blocksize Blocksize.
506 * sb->s_blocksize_bits log2 of blocksize.
507 * <return> 0 Blocksize is valid.
508 * <return> 1 Blocksize is invalid.
510 * HISTORY
511 * July 1, 1997 - Andrew E. Mileski
512 * Written, tested, and released.
514 static int
515 udf_set_blocksize(struct super_block *sb, int bsize)
517 if (!sb_min_blocksize(sb, bsize)) {
518 udf_debug("Bad block size (%d)\n", bsize);
519 printk(KERN_ERR "udf: bad block size (%d)\n", bsize);
520 return 0;
522 return sb->s_blocksize;
525 static int
526 udf_vrs(struct super_block *sb, int silent)
528 struct volStructDesc *vsd = NULL;
529 int sector = 32768;
530 int sectorsize;
531 struct buffer_head *bh = NULL;
532 int iso9660=0;
533 int nsr02=0;
534 int nsr03=0;
536 /* Block size must be a multiple of 512 */
537 if (sb->s_blocksize & 511)
538 return 0;
540 if (sb->s_blocksize < sizeof(struct volStructDesc))
541 sectorsize = sizeof(struct volStructDesc);
542 else
543 sectorsize = sb->s_blocksize;
545 sector += (UDF_SB_SESSION(sb) << sb->s_blocksize_bits);
547 udf_debug("Starting at sector %u (%ld byte sectors)\n",
548 (sector >> sb->s_blocksize_bits), sb->s_blocksize);
549 /* Process the sequence (if applicable) */
550 for (;!nsr02 && !nsr03; sector += sectorsize)
552 /* Read a block */
553 bh = udf_tread(sb, sector >> sb->s_blocksize_bits);
554 if (!bh)
555 break;
557 /* Look for ISO descriptors */
558 vsd = (struct volStructDesc *)(bh->b_data +
559 (sector & (sb->s_blocksize - 1)));
561 if (vsd->stdIdent[0] == 0)
563 udf_release_data(bh);
564 break;
566 else if (!strncmp(vsd->stdIdent, VSD_STD_ID_CD001, VSD_STD_ID_LEN))
568 iso9660 = sector;
569 switch (vsd->structType)
571 case 0:
572 udf_debug("ISO9660 Boot Record found\n");
573 break;
574 case 1:
575 udf_debug("ISO9660 Primary Volume Descriptor found\n");
576 break;
577 case 2:
578 udf_debug("ISO9660 Supplementary Volume Descriptor found\n");
579 break;
580 case 3:
581 udf_debug("ISO9660 Volume Partition Descriptor found\n");
582 break;
583 case 255:
584 udf_debug("ISO9660 Volume Descriptor Set Terminator found\n");
585 break;
586 default:
587 udf_debug("ISO9660 VRS (%u) found\n", vsd->structType);
588 break;
591 else if (!strncmp(vsd->stdIdent, VSD_STD_ID_BEA01, VSD_STD_ID_LEN))
594 else if (!strncmp(vsd->stdIdent, VSD_STD_ID_TEA01, VSD_STD_ID_LEN))
596 udf_release_data(bh);
597 break;
599 else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR02, VSD_STD_ID_LEN))
601 nsr02 = sector;
603 else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR03, VSD_STD_ID_LEN))
605 nsr03 = sector;
607 udf_release_data(bh);
610 if (nsr03)
611 return nsr03;
612 else if (nsr02)
613 return nsr02;
614 else if (sector - (UDF_SB_SESSION(sb) << sb->s_blocksize_bits) == 32768)
615 return -1;
616 else
617 return 0;
621 * udf_find_anchor
623 * PURPOSE
624 * Find an anchor volume descriptor.
626 * PRE-CONDITIONS
627 * sb Pointer to _locked_ superblock.
628 * lastblock Last block on media.
630 * POST-CONDITIONS
631 * <return> 1 if not found, 0 if ok
633 * HISTORY
634 * July 1, 1997 - Andrew E. Mileski
635 * Written, tested, and released.
637 static void
638 udf_find_anchor(struct super_block *sb)
640 int lastblock = UDF_SB_LASTBLOCK(sb);
641 struct buffer_head *bh = NULL;
642 uint16_t ident;
643 uint32_t location;
644 int i;
646 if (lastblock)
648 int varlastblock = udf_variable_to_fixed(lastblock);
649 int last[] = { lastblock, lastblock - 2,
650 lastblock - 150, lastblock - 152,
651 varlastblock, varlastblock - 2,
652 varlastblock - 150, varlastblock - 152 };
654 lastblock = 0;
656 /* Search for an anchor volume descriptor pointer */
658 /* according to spec, anchor is in either:
659 * block 256
660 * lastblock-256
661 * lastblock
662 * however, if the disc isn't closed, it could be 512 */
664 for (i = 0; !lastblock && i < ARRAY_SIZE(last); i++) {
665 if (last[i] < 0 || !(bh = sb_bread(sb, last[i])))
667 ident = location = 0;
669 else
671 ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
672 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
673 udf_release_data(bh);
676 if (ident == TAG_IDENT_AVDP)
678 if (location == last[i] - UDF_SB_SESSION(sb))
680 lastblock = UDF_SB_ANCHOR(sb)[0] = last[i] - UDF_SB_SESSION(sb);
681 UDF_SB_ANCHOR(sb)[1] = last[i] - 256 - UDF_SB_SESSION(sb);
683 else if (location == udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb))
685 UDF_SET_FLAG(sb, UDF_FLAG_VARCONV);
686 lastblock = UDF_SB_ANCHOR(sb)[0] = udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb);
687 UDF_SB_ANCHOR(sb)[1] = lastblock - 256 - UDF_SB_SESSION(sb);
689 else
690 udf_debug("Anchor found at block %d, location mismatch %d.\n",
691 last[i], location);
693 else if (ident == TAG_IDENT_FE || ident == TAG_IDENT_EFE)
695 lastblock = last[i];
696 UDF_SB_ANCHOR(sb)[3] = 512;
698 else
700 if (last[i] < 256 || !(bh = sb_bread(sb, last[i] - 256)))
702 ident = location = 0;
704 else
706 ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
707 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
708 udf_release_data(bh);
711 if (ident == TAG_IDENT_AVDP &&
712 location == last[i] - 256 - UDF_SB_SESSION(sb))
714 lastblock = last[i];
715 UDF_SB_ANCHOR(sb)[1] = last[i] - 256;
717 else
719 if (last[i] < 312 + UDF_SB_SESSION(sb) || !(bh = sb_bread(sb, last[i] - 312 - UDF_SB_SESSION(sb))))
721 ident = location = 0;
723 else
725 ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
726 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
727 udf_release_data(bh);
730 if (ident == TAG_IDENT_AVDP &&
731 location == udf_variable_to_fixed(last[i]) - 256)
733 UDF_SET_FLAG(sb, UDF_FLAG_VARCONV);
734 lastblock = udf_variable_to_fixed(last[i]);
735 UDF_SB_ANCHOR(sb)[1] = lastblock - 256;
742 if (!lastblock)
744 /* We havn't found the lastblock. check 312 */
745 if ((bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb))))
747 ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
748 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
749 udf_release_data(bh);
751 if (ident == TAG_IDENT_AVDP && location == 256)
752 UDF_SET_FLAG(sb, UDF_FLAG_VARCONV);
756 for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) {
757 if (UDF_SB_ANCHOR(sb)[i])
759 if (!(bh = udf_read_tagged(sb,
760 UDF_SB_ANCHOR(sb)[i], UDF_SB_ANCHOR(sb)[i], &ident)))
762 UDF_SB_ANCHOR(sb)[i] = 0;
764 else
766 udf_release_data(bh);
767 if ((ident != TAG_IDENT_AVDP) && (i ||
768 (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE)))
770 UDF_SB_ANCHOR(sb)[i] = 0;
776 UDF_SB_LASTBLOCK(sb) = lastblock;
779 static int
780 udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, kernel_lb_addr *root)
782 struct buffer_head *bh = NULL;
783 long lastblock;
784 uint16_t ident;
786 if (fileset->logicalBlockNum != 0xFFFFFFFF ||
787 fileset->partitionReferenceNum != 0xFFFF)
789 bh = udf_read_ptagged(sb, *fileset, 0, &ident);
791 if (!bh)
792 return 1;
793 else if (ident != TAG_IDENT_FSD)
795 udf_release_data(bh);
796 return 1;
801 if (!bh) /* Search backwards through the partitions */
803 kernel_lb_addr newfileset;
805 return 1;
807 for (newfileset.partitionReferenceNum=UDF_SB_NUMPARTS(sb)-1;
808 (newfileset.partitionReferenceNum != 0xFFFF &&
809 fileset->logicalBlockNum == 0xFFFFFFFF &&
810 fileset->partitionReferenceNum == 0xFFFF);
811 newfileset.partitionReferenceNum--)
813 lastblock = UDF_SB_PARTLEN(sb, newfileset.partitionReferenceNum);
814 newfileset.logicalBlockNum = 0;
818 bh = udf_read_ptagged(sb, newfileset, 0, &ident);
819 if (!bh)
821 newfileset.logicalBlockNum ++;
822 continue;
825 switch (ident)
827 case TAG_IDENT_SBD:
829 struct spaceBitmapDesc *sp;
830 sp = (struct spaceBitmapDesc *)bh->b_data;
831 newfileset.logicalBlockNum += 1 +
832 ((le32_to_cpu(sp->numOfBytes) + sizeof(struct spaceBitmapDesc) - 1)
833 >> sb->s_blocksize_bits);
834 udf_release_data(bh);
835 break;
837 case TAG_IDENT_FSD:
839 *fileset = newfileset;
840 break;
842 default:
844 newfileset.logicalBlockNum ++;
845 udf_release_data(bh);
846 bh = NULL;
847 break;
851 while (newfileset.logicalBlockNum < lastblock &&
852 fileset->logicalBlockNum == 0xFFFFFFFF &&
853 fileset->partitionReferenceNum == 0xFFFF);
857 if ((fileset->logicalBlockNum != 0xFFFFFFFF ||
858 fileset->partitionReferenceNum != 0xFFFF) && bh)
860 udf_debug("Fileset at block=%d, partition=%d\n",
861 fileset->logicalBlockNum, fileset->partitionReferenceNum);
863 UDF_SB_PARTITION(sb) = fileset->partitionReferenceNum;
864 udf_load_fileset(sb, bh, root);
865 udf_release_data(bh);
866 return 0;
868 return 1;
871 static void
872 udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh)
874 struct primaryVolDesc *pvoldesc;
875 time_t recording;
876 long recording_usec;
877 struct ustr instr;
878 struct ustr outstr;
880 pvoldesc = (struct primaryVolDesc *)bh->b_data;
882 if ( udf_stamp_to_time(&recording, &recording_usec,
883 lets_to_cpu(pvoldesc->recordingDateAndTime)) )
885 kernel_timestamp ts;
886 ts = lets_to_cpu(pvoldesc->recordingDateAndTime);
887 udf_debug("recording time %ld/%ld, %04u/%02u/%02u %02u:%02u (%x)\n",
888 recording, recording_usec,
889 ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.typeAndTimezone);
890 UDF_SB_RECORDTIME(sb).tv_sec = recording;
891 UDF_SB_RECORDTIME(sb).tv_nsec = recording_usec * 1000;
894 if ( !udf_build_ustr(&instr, pvoldesc->volIdent, 32) )
896 if (udf_CS0toUTF8(&outstr, &instr))
898 strncpy( UDF_SB_VOLIDENT(sb), outstr.u_name,
899 outstr.u_len > 31 ? 31 : outstr.u_len);
900 udf_debug("volIdent[] = '%s'\n", UDF_SB_VOLIDENT(sb));
904 if ( !udf_build_ustr(&instr, pvoldesc->volSetIdent, 128) )
906 if (udf_CS0toUTF8(&outstr, &instr))
907 udf_debug("volSetIdent[] = '%s'\n", outstr.u_name);
911 static void
912 udf_load_fileset(struct super_block *sb, struct buffer_head *bh, kernel_lb_addr *root)
914 struct fileSetDesc *fset;
916 fset = (struct fileSetDesc *)bh->b_data;
918 *root = lelb_to_cpu(fset->rootDirectoryICB.extLocation);
920 UDF_SB_SERIALNUM(sb) = le16_to_cpu(fset->descTag.tagSerialNum);
922 udf_debug("Rootdir at block=%d, partition=%d\n",
923 root->logicalBlockNum, root->partitionReferenceNum);
926 static void
927 udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
929 struct partitionDesc *p;
930 int i;
932 p = (struct partitionDesc *)bh->b_data;
934 for (i=0; i<UDF_SB_NUMPARTS(sb); i++)
936 udf_debug("Searching map: (%d == %d)\n",
937 UDF_SB_PARTMAPS(sb)[i].s_partition_num, le16_to_cpu(p->partitionNumber));
938 if (UDF_SB_PARTMAPS(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber))
940 UDF_SB_PARTLEN(sb,i) = le32_to_cpu(p->partitionLength); /* blocks */
941 UDF_SB_PARTROOT(sb,i) = le32_to_cpu(p->partitionStartingLocation);
942 if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_READ_ONLY)
943 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_READ_ONLY;
944 if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_WRITE_ONCE)
945 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_WRITE_ONCE;
946 if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_REWRITABLE)
947 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_REWRITABLE;
948 if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_OVERWRITABLE)
949 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_OVERWRITABLE;
951 if (!strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) ||
952 !strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03))
954 struct partitionHeaderDesc *phd;
956 phd = (struct partitionHeaderDesc *)(p->partitionContentsUse);
957 if (phd->unallocSpaceTable.extLength)
959 kernel_lb_addr loc = { le32_to_cpu(phd->unallocSpaceTable.extPosition), i };
961 UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table =
962 udf_iget(sb, loc);
963 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_TABLE;
964 udf_debug("unallocSpaceTable (part %d) @ %ld\n",
965 i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table->i_ino);
967 if (phd->unallocSpaceBitmap.extLength)
969 UDF_SB_ALLOC_BITMAP(sb, i, s_uspace);
970 if (UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap != NULL)
972 UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extLength =
973 le32_to_cpu(phd->unallocSpaceBitmap.extLength);
974 UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition =
975 le32_to_cpu(phd->unallocSpaceBitmap.extPosition);
976 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_BITMAP;
977 udf_debug("unallocSpaceBitmap (part %d) @ %d\n",
978 i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition);
981 if (phd->partitionIntegrityTable.extLength)
982 udf_debug("partitionIntegrityTable (part %d)\n", i);
983 if (phd->freedSpaceTable.extLength)
985 kernel_lb_addr loc = { le32_to_cpu(phd->freedSpaceTable.extPosition), i };
987 UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table =
988 udf_iget(sb, loc);
989 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_TABLE;
990 udf_debug("freedSpaceTable (part %d) @ %ld\n",
991 i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table->i_ino);
993 if (phd->freedSpaceBitmap.extLength)
995 UDF_SB_ALLOC_BITMAP(sb, i, s_fspace);
996 if (UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap != NULL)
998 UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extLength =
999 le32_to_cpu(phd->freedSpaceBitmap.extLength);
1000 UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition =
1001 le32_to_cpu(phd->freedSpaceBitmap.extPosition);
1002 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_BITMAP;
1003 udf_debug("freedSpaceBitmap (part %d) @ %d\n",
1004 i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition);
1008 break;
1011 if (i == UDF_SB_NUMPARTS(sb))
1013 udf_debug("Partition (%d) not found in partition map\n", le16_to_cpu(p->partitionNumber));
1015 else
1017 udf_debug("Partition (%d:%d type %x) starts at physical %d, block length %d\n",
1018 le16_to_cpu(p->partitionNumber), i, UDF_SB_PARTTYPE(sb,i),
1019 UDF_SB_PARTROOT(sb,i), UDF_SB_PARTLEN(sb,i));
1023 static int
1024 udf_load_logicalvol(struct super_block *sb, struct buffer_head * bh, kernel_lb_addr *fileset)
1026 struct logicalVolDesc *lvd;
1027 int i, j, offset;
1028 uint8_t type;
1030 lvd = (struct logicalVolDesc *)bh->b_data;
1032 UDF_SB_ALLOC_PARTMAPS(sb, le32_to_cpu(lvd->numPartitionMaps));
1034 for (i=0,offset=0;
1035 i<UDF_SB_NUMPARTS(sb) && offset<le32_to_cpu(lvd->mapTableLength);
1036 i++,offset+=((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapLength)
1038 type = ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapType;
1039 if (type == 1)
1041 struct genericPartitionMap1 *gpm1 = (struct genericPartitionMap1 *)&(lvd->partitionMaps[offset]);
1042 UDF_SB_PARTTYPE(sb,i) = UDF_TYPE1_MAP15;
1043 UDF_SB_PARTVSN(sb,i) = le16_to_cpu(gpm1->volSeqNum);
1044 UDF_SB_PARTNUM(sb,i) = le16_to_cpu(gpm1->partitionNum);
1045 UDF_SB_PARTFUNC(sb,i) = NULL;
1047 else if (type == 2)
1049 struct udfPartitionMap2 *upm2 = (struct udfPartitionMap2 *)&(lvd->partitionMaps[offset]);
1050 if (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL, strlen(UDF_ID_VIRTUAL)))
1052 if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0150)
1054 UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP15;
1055 UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt15;
1057 else if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0200)
1059 UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP20;
1060 UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt20;
1063 else if (!strncmp(upm2->partIdent.ident, UDF_ID_SPARABLE, strlen(UDF_ID_SPARABLE)))
1065 uint32_t loc;
1066 uint16_t ident;
1067 struct sparingTable *st;
1068 struct sparablePartitionMap *spm = (struct sparablePartitionMap *)&(lvd->partitionMaps[offset]);
1070 UDF_SB_PARTTYPE(sb,i) = UDF_SPARABLE_MAP15;
1071 UDF_SB_TYPESPAR(sb,i).s_packet_len = le16_to_cpu(spm->packetLength);
1072 for (j=0; j<spm->numSparingTables; j++)
1074 loc = le32_to_cpu(spm->locSparingTable[j]);
1075 UDF_SB_TYPESPAR(sb,i).s_spar_map[j] =
1076 udf_read_tagged(sb, loc, loc, &ident);
1077 if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL)
1079 st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,i).s_spar_map[j]->b_data;
1080 if (ident != 0 ||
1081 strncmp(st->sparingIdent.ident, UDF_ID_SPARING, strlen(UDF_ID_SPARING)))
1083 udf_release_data(UDF_SB_TYPESPAR(sb,i).s_spar_map[j]);
1084 UDF_SB_TYPESPAR(sb,i).s_spar_map[j] = NULL;
1088 UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_spar15;
1090 else
1092 udf_debug("Unknown ident: %s\n", upm2->partIdent.ident);
1093 continue;
1095 UDF_SB_PARTVSN(sb,i) = le16_to_cpu(upm2->volSeqNum);
1096 UDF_SB_PARTNUM(sb,i) = le16_to_cpu(upm2->partitionNum);
1098 udf_debug("Partition (%d:%d) type %d on volume %d\n",
1099 i, UDF_SB_PARTNUM(sb,i), type, UDF_SB_PARTVSN(sb,i));
1102 if (fileset)
1104 long_ad *la = (long_ad *)&(lvd->logicalVolContentsUse[0]);
1106 *fileset = lelb_to_cpu(la->extLocation);
1107 udf_debug("FileSet found in LogicalVolDesc at block=%d, partition=%d\n",
1108 fileset->logicalBlockNum,
1109 fileset->partitionReferenceNum);
1111 if (lvd->integritySeqExt.extLength)
1112 udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt));
1113 return 0;
1117 * udf_load_logicalvolint
1120 static void
1121 udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc)
1123 struct buffer_head *bh = NULL;
1124 uint16_t ident;
1126 while (loc.extLength > 0 &&
1127 (bh = udf_read_tagged(sb, loc.extLocation,
1128 loc.extLocation, &ident)) &&
1129 ident == TAG_IDENT_LVID)
1131 UDF_SB_LVIDBH(sb) = bh;
1133 if (UDF_SB_LVID(sb)->nextIntegrityExt.extLength)
1134 udf_load_logicalvolint(sb, leea_to_cpu(UDF_SB_LVID(sb)->nextIntegrityExt));
1136 if (UDF_SB_LVIDBH(sb) != bh)
1137 udf_release_data(bh);
1138 loc.extLength -= sb->s_blocksize;
1139 loc.extLocation ++;
1141 if (UDF_SB_LVIDBH(sb) != bh)
1142 udf_release_data(bh);
1146 * udf_process_sequence
1148 * PURPOSE
1149 * Process a main/reserve volume descriptor sequence.
1151 * PRE-CONDITIONS
1152 * sb Pointer to _locked_ superblock.
1153 * block First block of first extent of the sequence.
1154 * lastblock Lastblock of first extent of the sequence.
1156 * HISTORY
1157 * July 1, 1997 - Andrew E. Mileski
1158 * Written, tested, and released.
1160 static int
1161 udf_process_sequence(struct super_block *sb, long block, long lastblock, kernel_lb_addr *fileset)
1163 struct buffer_head *bh = NULL;
1164 struct udf_vds_record vds[VDS_POS_LENGTH];
1165 struct generic_desc *gd;
1166 struct volDescPtr *vdp;
1167 int done=0;
1168 int i,j;
1169 uint32_t vdsn;
1170 uint16_t ident;
1171 long next_s = 0, next_e = 0;
1173 memset(vds, 0, sizeof(struct udf_vds_record) * VDS_POS_LENGTH);
1175 /* Read the main descriptor sequence */
1176 for (;(!done && block <= lastblock); block++)
1179 bh = udf_read_tagged(sb, block, block, &ident);
1180 if (!bh)
1181 break;
1183 /* Process each descriptor (ISO 13346 3/8.3-8.4) */
1184 gd = (struct generic_desc *)bh->b_data;
1185 vdsn = le32_to_cpu(gd->volDescSeqNum);
1186 switch (ident)
1188 case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */
1189 if (vdsn >= vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum)
1191 vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum = vdsn;
1192 vds[VDS_POS_PRIMARY_VOL_DESC].block = block;
1194 break;
1195 case TAG_IDENT_VDP: /* ISO 13346 3/10.3 */
1196 if (vdsn >= vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum)
1198 vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum = vdsn;
1199 vds[VDS_POS_VOL_DESC_PTR].block = block;
1201 vdp = (struct volDescPtr *)bh->b_data;
1202 next_s = le32_to_cpu(vdp->nextVolDescSeqExt.extLocation);
1203 next_e = le32_to_cpu(vdp->nextVolDescSeqExt.extLength);
1204 next_e = next_e >> sb->s_blocksize_bits;
1205 next_e += next_s;
1207 break;
1208 case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */
1209 if (vdsn >= vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum)
1211 vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum = vdsn;
1212 vds[VDS_POS_IMP_USE_VOL_DESC].block = block;
1214 break;
1215 case TAG_IDENT_PD: /* ISO 13346 3/10.5 */
1216 if (!vds[VDS_POS_PARTITION_DESC].block)
1217 vds[VDS_POS_PARTITION_DESC].block = block;
1218 break;
1219 case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */
1220 if (vdsn >= vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum)
1222 vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum = vdsn;
1223 vds[VDS_POS_LOGICAL_VOL_DESC].block = block;
1225 break;
1226 case TAG_IDENT_USD: /* ISO 13346 3/10.8 */
1227 if (vdsn >= vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum)
1229 vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum = vdsn;
1230 vds[VDS_POS_UNALLOC_SPACE_DESC].block = block;
1232 break;
1233 case TAG_IDENT_TD: /* ISO 13346 3/10.9 */
1234 vds[VDS_POS_TERMINATING_DESC].block = block;
1235 if (next_e)
1237 block = next_s;
1238 lastblock = next_e;
1239 next_s = next_e = 0;
1241 else
1242 done = 1;
1243 break;
1245 udf_release_data(bh);
1247 for (i=0; i<VDS_POS_LENGTH; i++)
1249 if (vds[i].block)
1251 bh = udf_read_tagged(sb, vds[i].block, vds[i].block, &ident);
1253 if (i == VDS_POS_PRIMARY_VOL_DESC)
1254 udf_load_pvoldesc(sb, bh);
1255 else if (i == VDS_POS_LOGICAL_VOL_DESC)
1256 udf_load_logicalvol(sb, bh, fileset);
1257 else if (i == VDS_POS_PARTITION_DESC)
1259 struct buffer_head *bh2 = NULL;
1260 udf_load_partdesc(sb, bh);
1261 for (j=vds[i].block+1; j<vds[VDS_POS_TERMINATING_DESC].block; j++)
1263 bh2 = udf_read_tagged(sb, j, j, &ident);
1264 gd = (struct generic_desc *)bh2->b_data;
1265 if (ident == TAG_IDENT_PD)
1266 udf_load_partdesc(sb, bh2);
1267 udf_release_data(bh2);
1270 udf_release_data(bh);
1274 return 0;
1278 * udf_check_valid()
1280 static int
1281 udf_check_valid(struct super_block *sb, int novrs, int silent)
1283 long block;
1285 if (novrs)
1287 udf_debug("Validity check skipped because of novrs option\n");
1288 return 0;
1290 /* Check that it is NSR02 compliant */
1291 /* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */
1292 else if ((block = udf_vrs(sb, silent)) == -1)
1294 udf_debug("Failed to read byte 32768. Assuming open disc. Skipping validity check\n");
1295 if (!UDF_SB_LASTBLOCK(sb))
1296 UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb);
1297 return 0;
1299 else
1300 return !block;
1303 static int
1304 udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
1306 struct anchorVolDescPtr *anchor;
1307 uint16_t ident;
1308 struct buffer_head *bh;
1309 long main_s, main_e, reserve_s, reserve_e;
1310 int i, j;
1312 if (!sb)
1313 return 1;
1315 for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) {
1316 if (UDF_SB_ANCHOR(sb)[i] && (bh = udf_read_tagged(sb,
1317 UDF_SB_ANCHOR(sb)[i], UDF_SB_ANCHOR(sb)[i], &ident)))
1319 anchor = (struct anchorVolDescPtr *)bh->b_data;
1321 /* Locate the main sequence */
1322 main_s = le32_to_cpu( anchor->mainVolDescSeqExt.extLocation );
1323 main_e = le32_to_cpu( anchor->mainVolDescSeqExt.extLength );
1324 main_e = main_e >> sb->s_blocksize_bits;
1325 main_e += main_s;
1327 /* Locate the reserve sequence */
1328 reserve_s = le32_to_cpu(anchor->reserveVolDescSeqExt.extLocation);
1329 reserve_e = le32_to_cpu(anchor->reserveVolDescSeqExt.extLength);
1330 reserve_e = reserve_e >> sb->s_blocksize_bits;
1331 reserve_e += reserve_s;
1333 udf_release_data(bh);
1335 /* Process the main & reserve sequences */
1336 /* responsible for finding the PartitionDesc(s) */
1337 if (!(udf_process_sequence(sb, main_s, main_e, fileset) &&
1338 udf_process_sequence(sb, reserve_s, reserve_e, fileset)))
1340 break;
1345 if (i == ARRAY_SIZE(UDF_SB_ANCHOR(sb))) {
1346 udf_debug("No Anchor block found\n");
1347 return 1;
1348 } else
1349 udf_debug("Using anchor in block %d\n", UDF_SB_ANCHOR(sb)[i]);
1351 for (i=0; i<UDF_SB_NUMPARTS(sb); i++)
1353 switch UDF_SB_PARTTYPE(sb, i)
1355 case UDF_VIRTUAL_MAP15:
1356 case UDF_VIRTUAL_MAP20:
1358 kernel_lb_addr ino;
1360 if (!UDF_SB_LASTBLOCK(sb))
1362 UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb);
1363 udf_find_anchor(sb);
1366 if (!UDF_SB_LASTBLOCK(sb))
1368 udf_debug("Unable to determine Lastblock (For Virtual Partition)\n");
1369 return 1;
1372 for (j=0; j<UDF_SB_NUMPARTS(sb); j++)
1374 if (j != i &&
1375 UDF_SB_PARTVSN(sb,i) == UDF_SB_PARTVSN(sb,j) &&
1376 UDF_SB_PARTNUM(sb,i) == UDF_SB_PARTNUM(sb,j))
1378 ino.partitionReferenceNum = j;
1379 ino.logicalBlockNum = UDF_SB_LASTBLOCK(sb) -
1380 UDF_SB_PARTROOT(sb,j);
1381 break;
1385 if (j == UDF_SB_NUMPARTS(sb))
1386 return 1;
1388 if (!(UDF_SB_VAT(sb) = udf_iget(sb, ino)))
1389 return 1;
1391 if (UDF_SB_PARTTYPE(sb,i) == UDF_VIRTUAL_MAP15)
1393 UDF_SB_TYPEVIRT(sb,i).s_start_offset = udf_ext0_offset(UDF_SB_VAT(sb));
1394 UDF_SB_TYPEVIRT(sb,i).s_num_entries = (UDF_SB_VAT(sb)->i_size - 36) >> 2;
1396 else if (UDF_SB_PARTTYPE(sb,i) == UDF_VIRTUAL_MAP20)
1398 struct buffer_head *bh = NULL;
1399 uint32_t pos;
1401 pos = udf_block_map(UDF_SB_VAT(sb), 0);
1402 bh = sb_bread(sb, pos);
1403 UDF_SB_TYPEVIRT(sb,i).s_start_offset =
1404 le16_to_cpu(((struct virtualAllocationTable20 *)bh->b_data + udf_ext0_offset(UDF_SB_VAT(sb)))->lengthHeader) +
1405 udf_ext0_offset(UDF_SB_VAT(sb));
1406 UDF_SB_TYPEVIRT(sb,i).s_num_entries = (UDF_SB_VAT(sb)->i_size -
1407 UDF_SB_TYPEVIRT(sb,i).s_start_offset) >> 2;
1408 udf_release_data(bh);
1410 UDF_SB_PARTROOT(sb,i) = udf_get_pblock(sb, 0, i, 0);
1411 UDF_SB_PARTLEN(sb,i) = UDF_SB_PARTLEN(sb,ino.partitionReferenceNum);
1415 return 0;
1418 static void udf_open_lvid(struct super_block *sb)
1420 if (UDF_SB_LVIDBH(sb))
1422 int i;
1423 kernel_timestamp cpu_time;
1425 UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
1426 UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
1427 if (udf_time_to_stamp(&cpu_time, CURRENT_TIME))
1428 UDF_SB_LVID(sb)->recordingDateAndTime = cpu_to_lets(cpu_time);
1429 UDF_SB_LVID(sb)->integrityType = LVID_INTEGRITY_TYPE_OPEN;
1431 UDF_SB_LVID(sb)->descTag.descCRC =
1432 cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag),
1433 le16_to_cpu(UDF_SB_LVID(sb)->descTag.descCRCLength), 0));
1435 UDF_SB_LVID(sb)->descTag.tagChecksum = 0;
1436 for (i=0; i<16; i++)
1437 if (i != 4)
1438 UDF_SB_LVID(sb)->descTag.tagChecksum +=
1439 ((uint8_t *)&(UDF_SB_LVID(sb)->descTag))[i];
1441 mark_buffer_dirty(UDF_SB_LVIDBH(sb));
1445 static void udf_close_lvid(struct super_block *sb)
1447 if (UDF_SB_LVIDBH(sb) &&
1448 UDF_SB_LVID(sb)->integrityType == LVID_INTEGRITY_TYPE_OPEN)
1450 int i;
1451 kernel_timestamp cpu_time;
1453 UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
1454 UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
1455 if (udf_time_to_stamp(&cpu_time, CURRENT_TIME))
1456 UDF_SB_LVID(sb)->recordingDateAndTime = cpu_to_lets(cpu_time);
1457 if (UDF_MAX_WRITE_VERSION > le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev))
1458 UDF_SB_LVIDIU(sb)->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION);
1459 if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev))
1460 UDF_SB_LVIDIU(sb)->minUDFReadRev = cpu_to_le16(UDF_SB_UDFREV(sb));
1461 if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev))
1462 UDF_SB_LVIDIU(sb)->minUDFWriteRev = cpu_to_le16(UDF_SB_UDFREV(sb));
1463 UDF_SB_LVID(sb)->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
1465 UDF_SB_LVID(sb)->descTag.descCRC =
1466 cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag),
1467 le16_to_cpu(UDF_SB_LVID(sb)->descTag.descCRCLength), 0));
1469 UDF_SB_LVID(sb)->descTag.tagChecksum = 0;
1470 for (i=0; i<16; i++)
1471 if (i != 4)
1472 UDF_SB_LVID(sb)->descTag.tagChecksum +=
1473 ((uint8_t *)&(UDF_SB_LVID(sb)->descTag))[i];
1475 mark_buffer_dirty(UDF_SB_LVIDBH(sb));
1480 * udf_read_super
1482 * PURPOSE
1483 * Complete the specified super block.
1485 * PRE-CONDITIONS
1486 * sb Pointer to superblock to complete - never NULL.
1487 * sb->s_dev Device to read suberblock from.
1488 * options Pointer to mount options.
1489 * silent Silent flag.
1491 * HISTORY
1492 * July 1, 1997 - Andrew E. Mileski
1493 * Written, tested, and released.
1495 static int udf_fill_super(struct super_block *sb, void *options, int silent)
1497 int i;
1498 struct inode *inode=NULL;
1499 struct udf_options uopt;
1500 kernel_lb_addr rootdir, fileset;
1501 struct udf_sb_info *sbi;
1503 uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT);
1504 uopt.uid = -1;
1505 uopt.gid = -1;
1506 uopt.umask = 0;
1508 sbi = kmalloc(sizeof(struct udf_sb_info), GFP_KERNEL);
1509 if (!sbi)
1510 return -ENOMEM;
1511 sb->s_fs_info = sbi;
1512 memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info));
1514 mutex_init(&sbi->s_alloc_mutex);
1516 if (!udf_parse_options((char *)options, &uopt))
1517 goto error_out;
1519 if (uopt.flags & (1 << UDF_FLAG_UTF8) &&
1520 uopt.flags & (1 << UDF_FLAG_NLS_MAP))
1522 udf_error(sb, "udf_read_super",
1523 "utf8 cannot be combined with iocharset\n");
1524 goto error_out;
1526 #ifdef CONFIG_UDF_NLS
1527 if ((uopt.flags & (1 << UDF_FLAG_NLS_MAP)) && !uopt.nls_map)
1529 uopt.nls_map = load_nls_default();
1530 if (!uopt.nls_map)
1531 uopt.flags &= ~(1 << UDF_FLAG_NLS_MAP);
1532 else
1533 udf_debug("Using default NLS map\n");
1535 #endif
1536 if (!(uopt.flags & (1 << UDF_FLAG_NLS_MAP)))
1537 uopt.flags |= (1 << UDF_FLAG_UTF8);
1539 fileset.logicalBlockNum = 0xFFFFFFFF;
1540 fileset.partitionReferenceNum = 0xFFFF;
1542 UDF_SB(sb)->s_flags = uopt.flags;
1543 UDF_SB(sb)->s_uid = uopt.uid;
1544 UDF_SB(sb)->s_gid = uopt.gid;
1545 UDF_SB(sb)->s_umask = uopt.umask;
1546 UDF_SB(sb)->s_nls_map = uopt.nls_map;
1548 /* Set the block size for all transfers */
1549 if (!udf_set_blocksize(sb, uopt.blocksize))
1550 goto error_out;
1552 if ( uopt.session == 0xFFFFFFFF )
1553 UDF_SB_SESSION(sb) = udf_get_last_session(sb);
1554 else
1555 UDF_SB_SESSION(sb) = uopt.session;
1557 udf_debug("Multi-session=%d\n", UDF_SB_SESSION(sb));
1559 UDF_SB_LASTBLOCK(sb) = uopt.lastblock;
1560 UDF_SB_ANCHOR(sb)[0] = UDF_SB_ANCHOR(sb)[1] = 0;
1561 UDF_SB_ANCHOR(sb)[2] = uopt.anchor;
1562 UDF_SB_ANCHOR(sb)[3] = 256;
1564 if (udf_check_valid(sb, uopt.novrs, silent)) /* read volume recognition sequences */
1566 printk("UDF-fs: No VRS found\n");
1567 goto error_out;
1570 udf_find_anchor(sb);
1572 /* Fill in the rest of the superblock */
1573 sb->s_op = &udf_sb_ops;
1574 sb->dq_op = NULL;
1575 sb->s_dirt = 0;
1576 sb->s_magic = UDF_SUPER_MAGIC;
1577 sb->s_time_gran = 1000;
1579 if (udf_load_partition(sb, &fileset))
1581 printk("UDF-fs: No partition found (1)\n");
1582 goto error_out;
1585 udf_debug("Lastblock=%d\n", UDF_SB_LASTBLOCK(sb));
1587 if ( UDF_SB_LVIDBH(sb) )
1589 uint16_t minUDFReadRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev);
1590 uint16_t minUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev);
1591 /* uint16_t maxUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev); */
1593 if (minUDFReadRev > UDF_MAX_READ_VERSION)
1595 printk("UDF-fs: minUDFReadRev=%x (max is %x)\n",
1596 le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev),
1597 UDF_MAX_READ_VERSION);
1598 goto error_out;
1600 else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION)
1602 sb->s_flags |= MS_RDONLY;
1605 UDF_SB_UDFREV(sb) = minUDFWriteRev;
1607 if (minUDFReadRev >= UDF_VERS_USE_EXTENDED_FE)
1608 UDF_SET_FLAG(sb, UDF_FLAG_USE_EXTENDED_FE);
1609 if (minUDFReadRev >= UDF_VERS_USE_STREAMS)
1610 UDF_SET_FLAG(sb, UDF_FLAG_USE_STREAMS);
1613 if ( !UDF_SB_NUMPARTS(sb) )
1615 printk("UDF-fs: No partition found (2)\n");
1616 goto error_out;
1619 if ( udf_find_fileset(sb, &fileset, &rootdir) )
1621 printk("UDF-fs: No fileset found\n");
1622 goto error_out;
1625 if (!silent)
1627 kernel_timestamp ts;
1628 udf_time_to_stamp(&ts, UDF_SB_RECORDTIME(sb));
1629 udf_info("UDF %s (%s) Mounting volume '%s', timestamp %04u/%02u/%02u %02u:%02u (%x)\n",
1630 UDFFS_VERSION, UDFFS_DATE,
1631 UDF_SB_VOLIDENT(sb), ts.year, ts.month, ts.day, ts.hour, ts.minute,
1632 ts.typeAndTimezone);
1634 if (!(sb->s_flags & MS_RDONLY))
1635 udf_open_lvid(sb);
1637 /* Assign the root inode */
1638 /* assign inodes by physical block number */
1639 /* perhaps it's not extensible enough, but for now ... */
1640 inode = udf_iget(sb, rootdir);
1641 if (!inode)
1643 printk("UDF-fs: Error in udf_iget, block=%d, partition=%d\n",
1644 rootdir.logicalBlockNum, rootdir.partitionReferenceNum);
1645 goto error_out;
1648 /* Allocate a dentry for the root inode */
1649 sb->s_root = d_alloc_root(inode);
1650 if (!sb->s_root)
1652 printk("UDF-fs: Couldn't allocate root dentry\n");
1653 iput(inode);
1654 goto error_out;
1656 sb->s_maxbytes = MAX_LFS_FILESIZE;
1657 return 0;
1659 error_out:
1660 if (UDF_SB_VAT(sb))
1661 iput(UDF_SB_VAT(sb));
1662 if (UDF_SB_NUMPARTS(sb))
1664 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
1665 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
1666 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
1667 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
1668 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
1669 UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb),s_uspace);
1670 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
1671 UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb),s_fspace);
1672 if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15)
1674 for (i=0; i<4; i++)
1675 udf_release_data(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]);
1678 #ifdef CONFIG_UDF_NLS
1679 if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
1680 unload_nls(UDF_SB(sb)->s_nls_map);
1681 #endif
1682 if (!(sb->s_flags & MS_RDONLY))
1683 udf_close_lvid(sb);
1684 udf_release_data(UDF_SB_LVIDBH(sb));
1685 UDF_SB_FREE(sb);
1686 kfree(sbi);
1687 sb->s_fs_info = NULL;
1688 return -EINVAL;
1691 void udf_error(struct super_block *sb, const char *function,
1692 const char *fmt, ...)
1694 va_list args;
1696 if (!(sb->s_flags & MS_RDONLY))
1698 /* mark sb error */
1699 sb->s_dirt = 1;
1701 va_start(args, fmt);
1702 vsprintf(error_buf, fmt, args);
1703 va_end(args);
1704 printk (KERN_CRIT "UDF-fs error (device %s): %s: %s\n",
1705 sb->s_id, function, error_buf);
1708 void udf_warning(struct super_block *sb, const char *function,
1709 const char *fmt, ...)
1711 va_list args;
1713 va_start (args, fmt);
1714 vsprintf(error_buf, fmt, args);
1715 va_end(args);
1716 printk(KERN_WARNING "UDF-fs warning (device %s): %s: %s\n",
1717 sb->s_id, function, error_buf);
1721 * udf_put_super
1723 * PURPOSE
1724 * Prepare for destruction of the superblock.
1726 * DESCRIPTION
1727 * Called before the filesystem is unmounted.
1729 * HISTORY
1730 * July 1, 1997 - Andrew E. Mileski
1731 * Written, tested, and released.
1733 static void
1734 udf_put_super(struct super_block *sb)
1736 int i;
1738 if (UDF_SB_VAT(sb))
1739 iput(UDF_SB_VAT(sb));
1740 if (UDF_SB_NUMPARTS(sb))
1742 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
1743 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
1744 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
1745 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
1746 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
1747 UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb),s_uspace);
1748 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
1749 UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb),s_fspace);
1750 if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15)
1752 for (i=0; i<4; i++)
1753 udf_release_data(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]);
1756 #ifdef CONFIG_UDF_NLS
1757 if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
1758 unload_nls(UDF_SB(sb)->s_nls_map);
1759 #endif
1760 if (!(sb->s_flags & MS_RDONLY))
1761 udf_close_lvid(sb);
1762 udf_release_data(UDF_SB_LVIDBH(sb));
1763 UDF_SB_FREE(sb);
1764 kfree(sb->s_fs_info);
1765 sb->s_fs_info = NULL;
1769 * udf_stat_fs
1771 * PURPOSE
1772 * Return info about the filesystem.
1774 * DESCRIPTION
1775 * Called by sys_statfs()
1777 * HISTORY
1778 * July 1, 1997 - Andrew E. Mileski
1779 * Written, tested, and released.
1781 static int
1782 udf_statfs(struct super_block *sb, struct kstatfs *buf)
1784 buf->f_type = UDF_SUPER_MAGIC;
1785 buf->f_bsize = sb->s_blocksize;
1786 buf->f_blocks = UDF_SB_PARTLEN(sb, UDF_SB_PARTITION(sb));
1787 buf->f_bfree = udf_count_free(sb);
1788 buf->f_bavail = buf->f_bfree;
1789 buf->f_files = (UDF_SB_LVIDBH(sb) ?
1790 (le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) +
1791 le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)) : 0) + buf->f_bfree;
1792 buf->f_ffree = buf->f_bfree;
1793 /* __kernel_fsid_t f_fsid */
1794 buf->f_namelen = UDF_NAME_LEN-2;
1796 return 0;
1799 static unsigned char udf_bitmap_lookup[16] = {
1800 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4
1803 static unsigned int
1804 udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap)
1806 struct buffer_head *bh = NULL;
1807 unsigned int accum = 0;
1808 int index;
1809 int block = 0, newblock;
1810 kernel_lb_addr loc;
1811 uint32_t bytes;
1812 uint8_t value;
1813 uint8_t *ptr;
1814 uint16_t ident;
1815 struct spaceBitmapDesc *bm;
1817 lock_kernel();
1819 loc.logicalBlockNum = bitmap->s_extPosition;
1820 loc.partitionReferenceNum = UDF_SB_PARTITION(sb);
1821 bh = udf_read_ptagged(sb, loc, 0, &ident);
1823 if (!bh)
1825 printk(KERN_ERR "udf: udf_count_free failed\n");
1826 goto out;
1828 else if (ident != TAG_IDENT_SBD)
1830 udf_release_data(bh);
1831 printk(KERN_ERR "udf: udf_count_free failed\n");
1832 goto out;
1835 bm = (struct spaceBitmapDesc *)bh->b_data;
1836 bytes = le32_to_cpu(bm->numOfBytes);
1837 index = sizeof(struct spaceBitmapDesc); /* offset in first block only */
1838 ptr = (uint8_t *)bh->b_data;
1840 while ( bytes > 0 )
1842 while ((bytes > 0) && (index < sb->s_blocksize))
1844 value = ptr[index];
1845 accum += udf_bitmap_lookup[ value & 0x0f ];
1846 accum += udf_bitmap_lookup[ value >> 4 ];
1847 index++;
1848 bytes--;
1850 if ( bytes )
1852 udf_release_data(bh);
1853 newblock = udf_get_lb_pblock(sb, loc, ++block);
1854 bh = udf_tread(sb, newblock);
1855 if (!bh)
1857 udf_debug("read failed\n");
1858 goto out;
1860 index = 0;
1861 ptr = (uint8_t *)bh->b_data;
1864 udf_release_data(bh);
1866 out:
1867 unlock_kernel();
1869 return accum;
1872 static unsigned int
1873 udf_count_free_table(struct super_block *sb, struct inode * table)
1875 unsigned int accum = 0;
1876 uint32_t extoffset, elen;
1877 kernel_lb_addr bloc, eloc;
1878 int8_t etype;
1879 struct buffer_head *bh = NULL;
1881 lock_kernel();
1883 bloc = UDF_I_LOCATION(table);
1884 extoffset = sizeof(struct unallocSpaceEntry);
1886 while ((etype = udf_next_aext(table, &bloc, &extoffset, &eloc, &elen, &bh, 1)) != -1)
1888 accum += (elen >> table->i_sb->s_blocksize_bits);
1890 udf_release_data(bh);
1892 unlock_kernel();
1894 return accum;
1897 static unsigned int
1898 udf_count_free(struct super_block *sb)
1900 unsigned int accum = 0;
1902 if (UDF_SB_LVIDBH(sb))
1904 if (le32_to_cpu(UDF_SB_LVID(sb)->numOfPartitions) > UDF_SB_PARTITION(sb))
1906 accum = le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]);
1908 if (accum == 0xFFFFFFFF)
1909 accum = 0;
1913 if (accum)
1914 return accum;
1916 if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
1918 accum += udf_count_free_bitmap(sb,
1919 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_bitmap);
1921 if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
1923 accum += udf_count_free_bitmap(sb,
1924 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_bitmap);
1926 if (accum)
1927 return accum;
1929 if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
1931 accum += udf_count_free_table(sb,
1932 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
1934 if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
1936 accum += udf_count_free_table(sb,
1937 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
1940 return accum;