[SCSI] iscsi update: rm unused sessions list
[linux-2.6/kvm.git] / fs / udf / super.c
blob4a6f49adc609b051b16bea2e5e59d7719b1e5ed7
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 init_once, NULL);
145 if (udf_inode_cachep == NULL)
146 return -ENOMEM;
147 return 0;
150 static void destroy_inodecache(void)
152 if (kmem_cache_destroy(udf_inode_cachep))
153 printk(KERN_INFO "udf_inode_cache: not all structures were freed\n");
156 /* Superblock operations */
157 static struct super_operations udf_sb_ops = {
158 .alloc_inode = udf_alloc_inode,
159 .destroy_inode = udf_destroy_inode,
160 .write_inode = udf_write_inode,
161 .delete_inode = udf_delete_inode,
162 .clear_inode = udf_clear_inode,
163 .put_super = udf_put_super,
164 .write_super = udf_write_super,
165 .statfs = udf_statfs,
166 .remount_fs = udf_remount_fs,
169 struct udf_options
171 unsigned char novrs;
172 unsigned int blocksize;
173 unsigned int session;
174 unsigned int lastblock;
175 unsigned int anchor;
176 unsigned int volume;
177 unsigned short partition;
178 unsigned int fileset;
179 unsigned int rootdir;
180 unsigned int flags;
181 mode_t umask;
182 gid_t gid;
183 uid_t uid;
184 struct nls_table *nls_map;
187 static int __init init_udf_fs(void)
189 int err;
190 err = init_inodecache();
191 if (err)
192 goto out1;
193 err = register_filesystem(&udf_fstype);
194 if (err)
195 goto out;
196 return 0;
197 out:
198 destroy_inodecache();
199 out1:
200 return err;
203 static void __exit exit_udf_fs(void)
205 unregister_filesystem(&udf_fstype);
206 destroy_inodecache();
209 module_init(init_udf_fs)
210 module_exit(exit_udf_fs)
213 * udf_parse_options
215 * PURPOSE
216 * Parse mount options.
218 * DESCRIPTION
219 * The following mount options are supported:
221 * gid= Set the default group.
222 * umask= Set the default umask.
223 * uid= Set the default user.
224 * bs= Set the block size.
225 * unhide Show otherwise hidden files.
226 * undelete Show deleted files in lists.
227 * adinicb Embed data in the inode (default)
228 * noadinicb Don't embed data in the inode
229 * shortad Use short ad's
230 * longad Use long ad's (default)
231 * nostrict Unset strict conformance
232 * iocharset= Set the NLS character set
234 * The remaining are for debugging and disaster recovery:
236 * novrs Skip volume sequence recognition
238 * The following expect a offset from 0.
240 * session= Set the CDROM session (default= last session)
241 * anchor= Override standard anchor location. (default= 256)
242 * volume= Override the VolumeDesc location. (unused)
243 * partition= Override the PartitionDesc location. (unused)
244 * lastblock= Set the last block of the filesystem/
246 * The following expect a offset from the partition root.
248 * fileset= Override the fileset block location. (unused)
249 * rootdir= Override the root directory location. (unused)
250 * WARNING: overriding the rootdir to a non-directory may
251 * yield highly unpredictable results.
253 * PRE-CONDITIONS
254 * options Pointer to mount options string.
255 * uopts Pointer to mount options variable.
257 * POST-CONDITIONS
258 * <return> 1 Mount options parsed okay.
259 * <return> 0 Error parsing mount options.
261 * HISTORY
262 * July 1, 1997 - Andrew E. Mileski
263 * Written, tested, and released.
266 enum {
267 Opt_novrs, Opt_nostrict, Opt_bs, Opt_unhide, Opt_undelete,
268 Opt_noadinicb, Opt_adinicb, Opt_shortad, Opt_longad,
269 Opt_gid, Opt_uid, Opt_umask, Opt_session, Opt_lastblock,
270 Opt_anchor, Opt_volume, Opt_partition, Opt_fileset,
271 Opt_rootdir, Opt_utf8, Opt_iocharset,
272 Opt_err
275 static match_table_t tokens = {
276 {Opt_novrs, "novrs"},
277 {Opt_nostrict, "nostrict"},
278 {Opt_bs, "bs=%u"},
279 {Opt_unhide, "unhide"},
280 {Opt_undelete, "undelete"},
281 {Opt_noadinicb, "noadinicb"},
282 {Opt_adinicb, "adinicb"},
283 {Opt_shortad, "shortad"},
284 {Opt_longad, "longad"},
285 {Opt_gid, "gid=%u"},
286 {Opt_uid, "uid=%u"},
287 {Opt_umask, "umask=%o"},
288 {Opt_session, "session=%u"},
289 {Opt_lastblock, "lastblock=%u"},
290 {Opt_anchor, "anchor=%u"},
291 {Opt_volume, "volume=%u"},
292 {Opt_partition, "partition=%u"},
293 {Opt_fileset, "fileset=%u"},
294 {Opt_rootdir, "rootdir=%u"},
295 {Opt_utf8, "utf8"},
296 {Opt_iocharset, "iocharset=%s"},
297 {Opt_err, NULL}
300 static int
301 udf_parse_options(char *options, struct udf_options *uopt)
303 char *p;
304 int option;
306 uopt->novrs = 0;
307 uopt->blocksize = 2048;
308 uopt->partition = 0xFFFF;
309 uopt->session = 0xFFFFFFFF;
310 uopt->lastblock = 0;
311 uopt->anchor = 0;
312 uopt->volume = 0xFFFFFFFF;
313 uopt->rootdir = 0xFFFFFFFF;
314 uopt->fileset = 0xFFFFFFFF;
315 uopt->nls_map = NULL;
317 if (!options)
318 return 1;
320 while ((p = strsep(&options, ",")) != NULL)
322 substring_t args[MAX_OPT_ARGS];
323 int token;
324 if (!*p)
325 continue;
327 token = match_token(p, tokens, args);
328 switch (token)
330 case Opt_novrs:
331 uopt->novrs = 1;
332 case Opt_bs:
333 if (match_int(&args[0], &option))
334 return 0;
335 uopt->blocksize = option;
336 break;
337 case Opt_unhide:
338 uopt->flags |= (1 << UDF_FLAG_UNHIDE);
339 break;
340 case Opt_undelete:
341 uopt->flags |= (1 << UDF_FLAG_UNDELETE);
342 break;
343 case Opt_noadinicb:
344 uopt->flags &= ~(1 << UDF_FLAG_USE_AD_IN_ICB);
345 break;
346 case Opt_adinicb:
347 uopt->flags |= (1 << UDF_FLAG_USE_AD_IN_ICB);
348 break;
349 case Opt_shortad:
350 uopt->flags |= (1 << UDF_FLAG_USE_SHORT_AD);
351 break;
352 case Opt_longad:
353 uopt->flags &= ~(1 << UDF_FLAG_USE_SHORT_AD);
354 break;
355 case Opt_gid:
356 if (match_int(args, &option))
357 return 0;
358 uopt->gid = option;
359 break;
360 case Opt_uid:
361 if (match_int(args, &option))
362 return 0;
363 uopt->uid = option;
364 break;
365 case Opt_umask:
366 if (match_octal(args, &option))
367 return 0;
368 uopt->umask = option;
369 break;
370 case Opt_nostrict:
371 uopt->flags &= ~(1 << UDF_FLAG_STRICT);
372 break;
373 case Opt_session:
374 if (match_int(args, &option))
375 return 0;
376 uopt->session = option;
377 break;
378 case Opt_lastblock:
379 if (match_int(args, &option))
380 return 0;
381 uopt->lastblock = option;
382 break;
383 case Opt_anchor:
384 if (match_int(args, &option))
385 return 0;
386 uopt->anchor = option;
387 break;
388 case Opt_volume:
389 if (match_int(args, &option))
390 return 0;
391 uopt->volume = option;
392 break;
393 case Opt_partition:
394 if (match_int(args, &option))
395 return 0;
396 uopt->partition = option;
397 break;
398 case Opt_fileset:
399 if (match_int(args, &option))
400 return 0;
401 uopt->fileset = option;
402 break;
403 case Opt_rootdir:
404 if (match_int(args, &option))
405 return 0;
406 uopt->rootdir = option;
407 break;
408 case Opt_utf8:
409 uopt->flags |= (1 << UDF_FLAG_UTF8);
410 break;
411 #ifdef CONFIG_UDF_NLS
412 case Opt_iocharset:
413 uopt->nls_map = load_nls(args[0].from);
414 uopt->flags |= (1 << UDF_FLAG_NLS_MAP);
415 break;
416 #endif
417 default:
418 printk(KERN_ERR "udf: bad mount option \"%s\" "
419 "or missing value\n", p);
420 return 0;
423 return 1;
426 void
427 udf_write_super(struct super_block *sb)
429 lock_kernel();
430 if (!(sb->s_flags & MS_RDONLY))
431 udf_open_lvid(sb);
432 sb->s_dirt = 0;
433 unlock_kernel();
436 static int
437 udf_remount_fs(struct super_block *sb, int *flags, char *options)
439 struct udf_options uopt;
441 uopt.flags = UDF_SB(sb)->s_flags ;
442 uopt.uid = UDF_SB(sb)->s_uid ;
443 uopt.gid = UDF_SB(sb)->s_gid ;
444 uopt.umask = UDF_SB(sb)->s_umask ;
446 if ( !udf_parse_options(options, &uopt) )
447 return -EINVAL;
449 UDF_SB(sb)->s_flags = uopt.flags;
450 UDF_SB(sb)->s_uid = uopt.uid;
451 UDF_SB(sb)->s_gid = uopt.gid;
452 UDF_SB(sb)->s_umask = uopt.umask;
454 if (UDF_SB_LVIDBH(sb)) {
455 int write_rev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev);
456 if (write_rev > UDF_MAX_WRITE_VERSION)
457 *flags |= MS_RDONLY;
460 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
461 return 0;
462 if (*flags & MS_RDONLY)
463 udf_close_lvid(sb);
464 else
465 udf_open_lvid(sb);
467 return 0;
471 * udf_set_blocksize
473 * PURPOSE
474 * Set the block size to be used in all transfers.
476 * DESCRIPTION
477 * To allow room for a DMA transfer, it is best to guess big when unsure.
478 * This routine picks 2048 bytes as the blocksize when guessing. This
479 * should be adequate until devices with larger block sizes become common.
481 * Note that the Linux kernel can currently only deal with blocksizes of
482 * 512, 1024, 2048, 4096, and 8192 bytes.
484 * PRE-CONDITIONS
485 * sb Pointer to _locked_ superblock.
487 * POST-CONDITIONS
488 * sb->s_blocksize Blocksize.
489 * sb->s_blocksize_bits log2 of blocksize.
490 * <return> 0 Blocksize is valid.
491 * <return> 1 Blocksize is invalid.
493 * HISTORY
494 * July 1, 1997 - Andrew E. Mileski
495 * Written, tested, and released.
497 static int
498 udf_set_blocksize(struct super_block *sb, int bsize)
500 if (!sb_min_blocksize(sb, bsize)) {
501 udf_debug("Bad block size (%d)\n", bsize);
502 printk(KERN_ERR "udf: bad block size (%d)\n", bsize);
503 return 0;
505 return sb->s_blocksize;
508 static int
509 udf_vrs(struct super_block *sb, int silent)
511 struct volStructDesc *vsd = NULL;
512 int sector = 32768;
513 int sectorsize;
514 struct buffer_head *bh = NULL;
515 int iso9660=0;
516 int nsr02=0;
517 int nsr03=0;
519 /* Block size must be a multiple of 512 */
520 if (sb->s_blocksize & 511)
521 return 0;
523 if (sb->s_blocksize < sizeof(struct volStructDesc))
524 sectorsize = sizeof(struct volStructDesc);
525 else
526 sectorsize = sb->s_blocksize;
528 sector += (UDF_SB_SESSION(sb) << sb->s_blocksize_bits);
530 udf_debug("Starting at sector %u (%ld byte sectors)\n",
531 (sector >> sb->s_blocksize_bits), sb->s_blocksize);
532 /* Process the sequence (if applicable) */
533 for (;!nsr02 && !nsr03; sector += sectorsize)
535 /* Read a block */
536 bh = udf_tread(sb, sector >> sb->s_blocksize_bits);
537 if (!bh)
538 break;
540 /* Look for ISO descriptors */
541 vsd = (struct volStructDesc *)(bh->b_data +
542 (sector & (sb->s_blocksize - 1)));
544 if (vsd->stdIdent[0] == 0)
546 udf_release_data(bh);
547 break;
549 else if (!strncmp(vsd->stdIdent, VSD_STD_ID_CD001, VSD_STD_ID_LEN))
551 iso9660 = sector;
552 switch (vsd->structType)
554 case 0:
555 udf_debug("ISO9660 Boot Record found\n");
556 break;
557 case 1:
558 udf_debug("ISO9660 Primary Volume Descriptor found\n");
559 break;
560 case 2:
561 udf_debug("ISO9660 Supplementary Volume Descriptor found\n");
562 break;
563 case 3:
564 udf_debug("ISO9660 Volume Partition Descriptor found\n");
565 break;
566 case 255:
567 udf_debug("ISO9660 Volume Descriptor Set Terminator found\n");
568 break;
569 default:
570 udf_debug("ISO9660 VRS (%u) found\n", vsd->structType);
571 break;
574 else if (!strncmp(vsd->stdIdent, VSD_STD_ID_BEA01, VSD_STD_ID_LEN))
577 else if (!strncmp(vsd->stdIdent, VSD_STD_ID_TEA01, VSD_STD_ID_LEN))
579 udf_release_data(bh);
580 break;
582 else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR02, VSD_STD_ID_LEN))
584 nsr02 = sector;
586 else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR03, VSD_STD_ID_LEN))
588 nsr03 = sector;
590 udf_release_data(bh);
593 if (nsr03)
594 return nsr03;
595 else if (nsr02)
596 return nsr02;
597 else if (sector - (UDF_SB_SESSION(sb) << sb->s_blocksize_bits) == 32768)
598 return -1;
599 else
600 return 0;
604 * udf_find_anchor
606 * PURPOSE
607 * Find an anchor volume descriptor.
609 * PRE-CONDITIONS
610 * sb Pointer to _locked_ superblock.
611 * lastblock Last block on media.
613 * POST-CONDITIONS
614 * <return> 1 if not found, 0 if ok
616 * HISTORY
617 * July 1, 1997 - Andrew E. Mileski
618 * Written, tested, and released.
620 static void
621 udf_find_anchor(struct super_block *sb)
623 int lastblock = UDF_SB_LASTBLOCK(sb);
624 struct buffer_head *bh = NULL;
625 uint16_t ident;
626 uint32_t location;
627 int i;
629 if (lastblock)
631 int varlastblock = udf_variable_to_fixed(lastblock);
632 int last[] = { lastblock, lastblock - 2,
633 lastblock - 150, lastblock - 152,
634 varlastblock, varlastblock - 2,
635 varlastblock - 150, varlastblock - 152 };
637 lastblock = 0;
639 /* Search for an anchor volume descriptor pointer */
641 /* according to spec, anchor is in either:
642 * block 256
643 * lastblock-256
644 * lastblock
645 * however, if the disc isn't closed, it could be 512 */
647 for (i=0; (!lastblock && i<sizeof(last)/sizeof(int)); i++)
649 if (last[i] < 0 || !(bh = sb_bread(sb, last[i])))
651 ident = location = 0;
653 else
655 ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
656 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
657 udf_release_data(bh);
660 if (ident == TAG_IDENT_AVDP)
662 if (location == last[i] - UDF_SB_SESSION(sb))
664 lastblock = UDF_SB_ANCHOR(sb)[0] = last[i] - UDF_SB_SESSION(sb);
665 UDF_SB_ANCHOR(sb)[1] = last[i] - 256 - UDF_SB_SESSION(sb);
667 else if (location == udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb))
669 UDF_SET_FLAG(sb, UDF_FLAG_VARCONV);
670 lastblock = UDF_SB_ANCHOR(sb)[0] = udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb);
671 UDF_SB_ANCHOR(sb)[1] = lastblock - 256 - UDF_SB_SESSION(sb);
673 else
674 udf_debug("Anchor found at block %d, location mismatch %d.\n",
675 last[i], location);
677 else if (ident == TAG_IDENT_FE || ident == TAG_IDENT_EFE)
679 lastblock = last[i];
680 UDF_SB_ANCHOR(sb)[3] = 512;
682 else
684 if (last[i] < 256 || !(bh = sb_bread(sb, last[i] - 256)))
686 ident = location = 0;
688 else
690 ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
691 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
692 udf_release_data(bh);
695 if (ident == TAG_IDENT_AVDP &&
696 location == last[i] - 256 - UDF_SB_SESSION(sb))
698 lastblock = last[i];
699 UDF_SB_ANCHOR(sb)[1] = last[i] - 256;
701 else
703 if (last[i] < 312 + UDF_SB_SESSION(sb) || !(bh = sb_bread(sb, last[i] - 312 - UDF_SB_SESSION(sb))))
705 ident = location = 0;
707 else
709 ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
710 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
711 udf_release_data(bh);
714 if (ident == TAG_IDENT_AVDP &&
715 location == udf_variable_to_fixed(last[i]) - 256)
717 UDF_SET_FLAG(sb, UDF_FLAG_VARCONV);
718 lastblock = udf_variable_to_fixed(last[i]);
719 UDF_SB_ANCHOR(sb)[1] = lastblock - 256;
726 if (!lastblock)
728 /* We havn't found the lastblock. check 312 */
729 if ((bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb))))
731 ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
732 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
733 udf_release_data(bh);
735 if (ident == TAG_IDENT_AVDP && location == 256)
736 UDF_SET_FLAG(sb, UDF_FLAG_VARCONV);
740 for (i=0; i<sizeof(UDF_SB_ANCHOR(sb))/sizeof(int); i++)
742 if (UDF_SB_ANCHOR(sb)[i])
744 if (!(bh = udf_read_tagged(sb,
745 UDF_SB_ANCHOR(sb)[i], UDF_SB_ANCHOR(sb)[i], &ident)))
747 UDF_SB_ANCHOR(sb)[i] = 0;
749 else
751 udf_release_data(bh);
752 if ((ident != TAG_IDENT_AVDP) && (i ||
753 (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE)))
755 UDF_SB_ANCHOR(sb)[i] = 0;
761 UDF_SB_LASTBLOCK(sb) = lastblock;
764 static int
765 udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, kernel_lb_addr *root)
767 struct buffer_head *bh = NULL;
768 long lastblock;
769 uint16_t ident;
771 if (fileset->logicalBlockNum != 0xFFFFFFFF ||
772 fileset->partitionReferenceNum != 0xFFFF)
774 bh = udf_read_ptagged(sb, *fileset, 0, &ident);
776 if (!bh)
777 return 1;
778 else if (ident != TAG_IDENT_FSD)
780 udf_release_data(bh);
781 return 1;
786 if (!bh) /* Search backwards through the partitions */
788 kernel_lb_addr newfileset;
790 return 1;
792 for (newfileset.partitionReferenceNum=UDF_SB_NUMPARTS(sb)-1;
793 (newfileset.partitionReferenceNum != 0xFFFF &&
794 fileset->logicalBlockNum == 0xFFFFFFFF &&
795 fileset->partitionReferenceNum == 0xFFFF);
796 newfileset.partitionReferenceNum--)
798 lastblock = UDF_SB_PARTLEN(sb, newfileset.partitionReferenceNum);
799 newfileset.logicalBlockNum = 0;
803 bh = udf_read_ptagged(sb, newfileset, 0, &ident);
804 if (!bh)
806 newfileset.logicalBlockNum ++;
807 continue;
810 switch (ident)
812 case TAG_IDENT_SBD:
814 struct spaceBitmapDesc *sp;
815 sp = (struct spaceBitmapDesc *)bh->b_data;
816 newfileset.logicalBlockNum += 1 +
817 ((le32_to_cpu(sp->numOfBytes) + sizeof(struct spaceBitmapDesc) - 1)
818 >> sb->s_blocksize_bits);
819 udf_release_data(bh);
820 break;
822 case TAG_IDENT_FSD:
824 *fileset = newfileset;
825 break;
827 default:
829 newfileset.logicalBlockNum ++;
830 udf_release_data(bh);
831 bh = NULL;
832 break;
836 while (newfileset.logicalBlockNum < lastblock &&
837 fileset->logicalBlockNum == 0xFFFFFFFF &&
838 fileset->partitionReferenceNum == 0xFFFF);
842 if ((fileset->logicalBlockNum != 0xFFFFFFFF ||
843 fileset->partitionReferenceNum != 0xFFFF) && bh)
845 udf_debug("Fileset at block=%d, partition=%d\n",
846 fileset->logicalBlockNum, fileset->partitionReferenceNum);
848 UDF_SB_PARTITION(sb) = fileset->partitionReferenceNum;
849 udf_load_fileset(sb, bh, root);
850 udf_release_data(bh);
851 return 0;
853 return 1;
856 static void
857 udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh)
859 struct primaryVolDesc *pvoldesc;
860 time_t recording;
861 long recording_usec;
862 struct ustr instr;
863 struct ustr outstr;
865 pvoldesc = (struct primaryVolDesc *)bh->b_data;
867 if ( udf_stamp_to_time(&recording, &recording_usec,
868 lets_to_cpu(pvoldesc->recordingDateAndTime)) )
870 kernel_timestamp ts;
871 ts = lets_to_cpu(pvoldesc->recordingDateAndTime);
872 udf_debug("recording time %ld/%ld, %04u/%02u/%02u %02u:%02u (%x)\n",
873 recording, recording_usec,
874 ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.typeAndTimezone);
875 UDF_SB_RECORDTIME(sb).tv_sec = recording;
876 UDF_SB_RECORDTIME(sb).tv_nsec = recording_usec * 1000;
879 if ( !udf_build_ustr(&instr, pvoldesc->volIdent, 32) )
881 if (udf_CS0toUTF8(&outstr, &instr))
883 strncpy( UDF_SB_VOLIDENT(sb), outstr.u_name,
884 outstr.u_len > 31 ? 31 : outstr.u_len);
885 udf_debug("volIdent[] = '%s'\n", UDF_SB_VOLIDENT(sb));
889 if ( !udf_build_ustr(&instr, pvoldesc->volSetIdent, 128) )
891 if (udf_CS0toUTF8(&outstr, &instr))
892 udf_debug("volSetIdent[] = '%s'\n", outstr.u_name);
896 static void
897 udf_load_fileset(struct super_block *sb, struct buffer_head *bh, kernel_lb_addr *root)
899 struct fileSetDesc *fset;
901 fset = (struct fileSetDesc *)bh->b_data;
903 *root = lelb_to_cpu(fset->rootDirectoryICB.extLocation);
905 UDF_SB_SERIALNUM(sb) = le16_to_cpu(fset->descTag.tagSerialNum);
907 udf_debug("Rootdir at block=%d, partition=%d\n",
908 root->logicalBlockNum, root->partitionReferenceNum);
911 static void
912 udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
914 struct partitionDesc *p;
915 int i;
917 p = (struct partitionDesc *)bh->b_data;
919 for (i=0; i<UDF_SB_NUMPARTS(sb); i++)
921 udf_debug("Searching map: (%d == %d)\n",
922 UDF_SB_PARTMAPS(sb)[i].s_partition_num, le16_to_cpu(p->partitionNumber));
923 if (UDF_SB_PARTMAPS(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber))
925 UDF_SB_PARTLEN(sb,i) = le32_to_cpu(p->partitionLength); /* blocks */
926 UDF_SB_PARTROOT(sb,i) = le32_to_cpu(p->partitionStartingLocation);
927 if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_READ_ONLY)
928 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_READ_ONLY;
929 if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_WRITE_ONCE)
930 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_WRITE_ONCE;
931 if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_REWRITABLE)
932 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_REWRITABLE;
933 if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_OVERWRITABLE)
934 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_OVERWRITABLE;
936 if (!strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) ||
937 !strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03))
939 struct partitionHeaderDesc *phd;
941 phd = (struct partitionHeaderDesc *)(p->partitionContentsUse);
942 if (phd->unallocSpaceTable.extLength)
944 kernel_lb_addr loc = { le32_to_cpu(phd->unallocSpaceTable.extPosition), i };
946 UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table =
947 udf_iget(sb, loc);
948 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_TABLE;
949 udf_debug("unallocSpaceTable (part %d) @ %ld\n",
950 i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table->i_ino);
952 if (phd->unallocSpaceBitmap.extLength)
954 UDF_SB_ALLOC_BITMAP(sb, i, s_uspace);
955 if (UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap != NULL)
957 UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extLength =
958 le32_to_cpu(phd->unallocSpaceBitmap.extLength);
959 UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition =
960 le32_to_cpu(phd->unallocSpaceBitmap.extPosition);
961 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_BITMAP;
962 udf_debug("unallocSpaceBitmap (part %d) @ %d\n",
963 i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition);
966 if (phd->partitionIntegrityTable.extLength)
967 udf_debug("partitionIntegrityTable (part %d)\n", i);
968 if (phd->freedSpaceTable.extLength)
970 kernel_lb_addr loc = { le32_to_cpu(phd->freedSpaceTable.extPosition), i };
972 UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table =
973 udf_iget(sb, loc);
974 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_TABLE;
975 udf_debug("freedSpaceTable (part %d) @ %ld\n",
976 i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table->i_ino);
978 if (phd->freedSpaceBitmap.extLength)
980 UDF_SB_ALLOC_BITMAP(sb, i, s_fspace);
981 if (UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap != NULL)
983 UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extLength =
984 le32_to_cpu(phd->freedSpaceBitmap.extLength);
985 UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition =
986 le32_to_cpu(phd->freedSpaceBitmap.extPosition);
987 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_BITMAP;
988 udf_debug("freedSpaceBitmap (part %d) @ %d\n",
989 i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition);
993 break;
996 if (i == UDF_SB_NUMPARTS(sb))
998 udf_debug("Partition (%d) not found in partition map\n", le16_to_cpu(p->partitionNumber));
1000 else
1002 udf_debug("Partition (%d:%d type %x) starts at physical %d, block length %d\n",
1003 le16_to_cpu(p->partitionNumber), i, UDF_SB_PARTTYPE(sb,i),
1004 UDF_SB_PARTROOT(sb,i), UDF_SB_PARTLEN(sb,i));
1008 static int
1009 udf_load_logicalvol(struct super_block *sb, struct buffer_head * bh, kernel_lb_addr *fileset)
1011 struct logicalVolDesc *lvd;
1012 int i, j, offset;
1013 uint8_t type;
1015 lvd = (struct logicalVolDesc *)bh->b_data;
1017 UDF_SB_ALLOC_PARTMAPS(sb, le32_to_cpu(lvd->numPartitionMaps));
1019 for (i=0,offset=0;
1020 i<UDF_SB_NUMPARTS(sb) && offset<le32_to_cpu(lvd->mapTableLength);
1021 i++,offset+=((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapLength)
1023 type = ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapType;
1024 if (type == 1)
1026 struct genericPartitionMap1 *gpm1 = (struct genericPartitionMap1 *)&(lvd->partitionMaps[offset]);
1027 UDF_SB_PARTTYPE(sb,i) = UDF_TYPE1_MAP15;
1028 UDF_SB_PARTVSN(sb,i) = le16_to_cpu(gpm1->volSeqNum);
1029 UDF_SB_PARTNUM(sb,i) = le16_to_cpu(gpm1->partitionNum);
1030 UDF_SB_PARTFUNC(sb,i) = NULL;
1032 else if (type == 2)
1034 struct udfPartitionMap2 *upm2 = (struct udfPartitionMap2 *)&(lvd->partitionMaps[offset]);
1035 if (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL, strlen(UDF_ID_VIRTUAL)))
1037 if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0150)
1039 UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP15;
1040 UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt15;
1042 else if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0200)
1044 UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP20;
1045 UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt20;
1048 else if (!strncmp(upm2->partIdent.ident, UDF_ID_SPARABLE, strlen(UDF_ID_SPARABLE)))
1050 uint32_t loc;
1051 uint16_t ident;
1052 struct sparingTable *st;
1053 struct sparablePartitionMap *spm = (struct sparablePartitionMap *)&(lvd->partitionMaps[offset]);
1055 UDF_SB_PARTTYPE(sb,i) = UDF_SPARABLE_MAP15;
1056 UDF_SB_TYPESPAR(sb,i).s_packet_len = le16_to_cpu(spm->packetLength);
1057 for (j=0; j<spm->numSparingTables; j++)
1059 loc = le32_to_cpu(spm->locSparingTable[j]);
1060 UDF_SB_TYPESPAR(sb,i).s_spar_map[j] =
1061 udf_read_tagged(sb, loc, loc, &ident);
1062 if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL)
1064 st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,i).s_spar_map[j]->b_data;
1065 if (ident != 0 ||
1066 strncmp(st->sparingIdent.ident, UDF_ID_SPARING, strlen(UDF_ID_SPARING)))
1068 udf_release_data(UDF_SB_TYPESPAR(sb,i).s_spar_map[j]);
1069 UDF_SB_TYPESPAR(sb,i).s_spar_map[j] = NULL;
1073 UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_spar15;
1075 else
1077 udf_debug("Unknown ident: %s\n", upm2->partIdent.ident);
1078 continue;
1080 UDF_SB_PARTVSN(sb,i) = le16_to_cpu(upm2->volSeqNum);
1081 UDF_SB_PARTNUM(sb,i) = le16_to_cpu(upm2->partitionNum);
1083 udf_debug("Partition (%d:%d) type %d on volume %d\n",
1084 i, UDF_SB_PARTNUM(sb,i), type, UDF_SB_PARTVSN(sb,i));
1087 if (fileset)
1089 long_ad *la = (long_ad *)&(lvd->logicalVolContentsUse[0]);
1091 *fileset = lelb_to_cpu(la->extLocation);
1092 udf_debug("FileSet found in LogicalVolDesc at block=%d, partition=%d\n",
1093 fileset->logicalBlockNum,
1094 fileset->partitionReferenceNum);
1096 if (lvd->integritySeqExt.extLength)
1097 udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt));
1098 return 0;
1102 * udf_load_logicalvolint
1105 static void
1106 udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc)
1108 struct buffer_head *bh = NULL;
1109 uint16_t ident;
1111 while (loc.extLength > 0 &&
1112 (bh = udf_read_tagged(sb, loc.extLocation,
1113 loc.extLocation, &ident)) &&
1114 ident == TAG_IDENT_LVID)
1116 UDF_SB_LVIDBH(sb) = bh;
1118 if (UDF_SB_LVID(sb)->nextIntegrityExt.extLength)
1119 udf_load_logicalvolint(sb, leea_to_cpu(UDF_SB_LVID(sb)->nextIntegrityExt));
1121 if (UDF_SB_LVIDBH(sb) != bh)
1122 udf_release_data(bh);
1123 loc.extLength -= sb->s_blocksize;
1124 loc.extLocation ++;
1126 if (UDF_SB_LVIDBH(sb) != bh)
1127 udf_release_data(bh);
1131 * udf_process_sequence
1133 * PURPOSE
1134 * Process a main/reserve volume descriptor sequence.
1136 * PRE-CONDITIONS
1137 * sb Pointer to _locked_ superblock.
1138 * block First block of first extent of the sequence.
1139 * lastblock Lastblock of first extent of the sequence.
1141 * HISTORY
1142 * July 1, 1997 - Andrew E. Mileski
1143 * Written, tested, and released.
1145 static int
1146 udf_process_sequence(struct super_block *sb, long block, long lastblock, kernel_lb_addr *fileset)
1148 struct buffer_head *bh = NULL;
1149 struct udf_vds_record vds[VDS_POS_LENGTH];
1150 struct generic_desc *gd;
1151 struct volDescPtr *vdp;
1152 int done=0;
1153 int i,j;
1154 uint32_t vdsn;
1155 uint16_t ident;
1156 long next_s = 0, next_e = 0;
1158 memset(vds, 0, sizeof(struct udf_vds_record) * VDS_POS_LENGTH);
1160 /* Read the main descriptor sequence */
1161 for (;(!done && block <= lastblock); block++)
1164 bh = udf_read_tagged(sb, block, block, &ident);
1165 if (!bh)
1166 break;
1168 /* Process each descriptor (ISO 13346 3/8.3-8.4) */
1169 gd = (struct generic_desc *)bh->b_data;
1170 vdsn = le32_to_cpu(gd->volDescSeqNum);
1171 switch (ident)
1173 case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */
1174 if (vdsn >= vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum)
1176 vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum = vdsn;
1177 vds[VDS_POS_PRIMARY_VOL_DESC].block = block;
1179 break;
1180 case TAG_IDENT_VDP: /* ISO 13346 3/10.3 */
1181 if (vdsn >= vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum)
1183 vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum = vdsn;
1184 vds[VDS_POS_VOL_DESC_PTR].block = block;
1186 vdp = (struct volDescPtr *)bh->b_data;
1187 next_s = le32_to_cpu(vdp->nextVolDescSeqExt.extLocation);
1188 next_e = le32_to_cpu(vdp->nextVolDescSeqExt.extLength);
1189 next_e = next_e >> sb->s_blocksize_bits;
1190 next_e += next_s;
1192 break;
1193 case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */
1194 if (vdsn >= vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum)
1196 vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum = vdsn;
1197 vds[VDS_POS_IMP_USE_VOL_DESC].block = block;
1199 break;
1200 case TAG_IDENT_PD: /* ISO 13346 3/10.5 */
1201 if (!vds[VDS_POS_PARTITION_DESC].block)
1202 vds[VDS_POS_PARTITION_DESC].block = block;
1203 break;
1204 case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */
1205 if (vdsn >= vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum)
1207 vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum = vdsn;
1208 vds[VDS_POS_LOGICAL_VOL_DESC].block = block;
1210 break;
1211 case TAG_IDENT_USD: /* ISO 13346 3/10.8 */
1212 if (vdsn >= vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum)
1214 vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum = vdsn;
1215 vds[VDS_POS_UNALLOC_SPACE_DESC].block = block;
1217 break;
1218 case TAG_IDENT_TD: /* ISO 13346 3/10.9 */
1219 vds[VDS_POS_TERMINATING_DESC].block = block;
1220 if (next_e)
1222 block = next_s;
1223 lastblock = next_e;
1224 next_s = next_e = 0;
1226 else
1227 done = 1;
1228 break;
1230 udf_release_data(bh);
1232 for (i=0; i<VDS_POS_LENGTH; i++)
1234 if (vds[i].block)
1236 bh = udf_read_tagged(sb, vds[i].block, vds[i].block, &ident);
1238 if (i == VDS_POS_PRIMARY_VOL_DESC)
1239 udf_load_pvoldesc(sb, bh);
1240 else if (i == VDS_POS_LOGICAL_VOL_DESC)
1241 udf_load_logicalvol(sb, bh, fileset);
1242 else if (i == VDS_POS_PARTITION_DESC)
1244 struct buffer_head *bh2 = NULL;
1245 udf_load_partdesc(sb, bh);
1246 for (j=vds[i].block+1; j<vds[VDS_POS_TERMINATING_DESC].block; j++)
1248 bh2 = udf_read_tagged(sb, j, j, &ident);
1249 gd = (struct generic_desc *)bh2->b_data;
1250 if (ident == TAG_IDENT_PD)
1251 udf_load_partdesc(sb, bh2);
1252 udf_release_data(bh2);
1255 udf_release_data(bh);
1259 return 0;
1263 * udf_check_valid()
1265 static int
1266 udf_check_valid(struct super_block *sb, int novrs, int silent)
1268 long block;
1270 if (novrs)
1272 udf_debug("Validity check skipped because of novrs option\n");
1273 return 0;
1275 /* Check that it is NSR02 compliant */
1276 /* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */
1277 else if ((block = udf_vrs(sb, silent)) == -1)
1279 udf_debug("Failed to read byte 32768. Assuming open disc. Skipping validity check\n");
1280 if (!UDF_SB_LASTBLOCK(sb))
1281 UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb);
1282 return 0;
1284 else
1285 return !block;
1288 static int
1289 udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
1291 struct anchorVolDescPtr *anchor;
1292 uint16_t ident;
1293 struct buffer_head *bh;
1294 long main_s, main_e, reserve_s, reserve_e;
1295 int i, j;
1297 if (!sb)
1298 return 1;
1300 for (i=0; i<sizeof(UDF_SB_ANCHOR(sb))/sizeof(int); i++)
1302 if (UDF_SB_ANCHOR(sb)[i] && (bh = udf_read_tagged(sb,
1303 UDF_SB_ANCHOR(sb)[i], UDF_SB_ANCHOR(sb)[i], &ident)))
1305 anchor = (struct anchorVolDescPtr *)bh->b_data;
1307 /* Locate the main sequence */
1308 main_s = le32_to_cpu( anchor->mainVolDescSeqExt.extLocation );
1309 main_e = le32_to_cpu( anchor->mainVolDescSeqExt.extLength );
1310 main_e = main_e >> sb->s_blocksize_bits;
1311 main_e += main_s;
1313 /* Locate the reserve sequence */
1314 reserve_s = le32_to_cpu(anchor->reserveVolDescSeqExt.extLocation);
1315 reserve_e = le32_to_cpu(anchor->reserveVolDescSeqExt.extLength);
1316 reserve_e = reserve_e >> sb->s_blocksize_bits;
1317 reserve_e += reserve_s;
1319 udf_release_data(bh);
1321 /* Process the main & reserve sequences */
1322 /* responsible for finding the PartitionDesc(s) */
1323 if (!(udf_process_sequence(sb, main_s, main_e, fileset) &&
1324 udf_process_sequence(sb, reserve_s, reserve_e, fileset)))
1326 break;
1331 if (i == sizeof(UDF_SB_ANCHOR(sb))/sizeof(int))
1333 udf_debug("No Anchor block found\n");
1334 return 1;
1336 else
1337 udf_debug("Using anchor in block %d\n", UDF_SB_ANCHOR(sb)[i]);
1339 for (i=0; i<UDF_SB_NUMPARTS(sb); i++)
1341 switch UDF_SB_PARTTYPE(sb, i)
1343 case UDF_VIRTUAL_MAP15:
1344 case UDF_VIRTUAL_MAP20:
1346 kernel_lb_addr ino;
1348 if (!UDF_SB_LASTBLOCK(sb))
1350 UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb);
1351 udf_find_anchor(sb);
1354 if (!UDF_SB_LASTBLOCK(sb))
1356 udf_debug("Unable to determine Lastblock (For Virtual Partition)\n");
1357 return 1;
1360 for (j=0; j<UDF_SB_NUMPARTS(sb); j++)
1362 if (j != i &&
1363 UDF_SB_PARTVSN(sb,i) == UDF_SB_PARTVSN(sb,j) &&
1364 UDF_SB_PARTNUM(sb,i) == UDF_SB_PARTNUM(sb,j))
1366 ino.partitionReferenceNum = j;
1367 ino.logicalBlockNum = UDF_SB_LASTBLOCK(sb) -
1368 UDF_SB_PARTROOT(sb,j);
1369 break;
1373 if (j == UDF_SB_NUMPARTS(sb))
1374 return 1;
1376 if (!(UDF_SB_VAT(sb) = udf_iget(sb, ino)))
1377 return 1;
1379 if (UDF_SB_PARTTYPE(sb,i) == UDF_VIRTUAL_MAP15)
1381 UDF_SB_TYPEVIRT(sb,i).s_start_offset = udf_ext0_offset(UDF_SB_VAT(sb));
1382 UDF_SB_TYPEVIRT(sb,i).s_num_entries = (UDF_SB_VAT(sb)->i_size - 36) >> 2;
1384 else if (UDF_SB_PARTTYPE(sb,i) == UDF_VIRTUAL_MAP20)
1386 struct buffer_head *bh = NULL;
1387 uint32_t pos;
1389 pos = udf_block_map(UDF_SB_VAT(sb), 0);
1390 bh = sb_bread(sb, pos);
1391 UDF_SB_TYPEVIRT(sb,i).s_start_offset =
1392 le16_to_cpu(((struct virtualAllocationTable20 *)bh->b_data + udf_ext0_offset(UDF_SB_VAT(sb)))->lengthHeader) +
1393 udf_ext0_offset(UDF_SB_VAT(sb));
1394 UDF_SB_TYPEVIRT(sb,i).s_num_entries = (UDF_SB_VAT(sb)->i_size -
1395 UDF_SB_TYPEVIRT(sb,i).s_start_offset) >> 2;
1396 udf_release_data(bh);
1398 UDF_SB_PARTROOT(sb,i) = udf_get_pblock(sb, 0, i, 0);
1399 UDF_SB_PARTLEN(sb,i) = UDF_SB_PARTLEN(sb,ino.partitionReferenceNum);
1403 return 0;
1406 static void udf_open_lvid(struct super_block *sb)
1408 if (UDF_SB_LVIDBH(sb))
1410 int i;
1411 kernel_timestamp cpu_time;
1413 UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
1414 UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
1415 if (udf_time_to_stamp(&cpu_time, CURRENT_TIME))
1416 UDF_SB_LVID(sb)->recordingDateAndTime = cpu_to_lets(cpu_time);
1417 UDF_SB_LVID(sb)->integrityType = LVID_INTEGRITY_TYPE_OPEN;
1419 UDF_SB_LVID(sb)->descTag.descCRC =
1420 cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag),
1421 le16_to_cpu(UDF_SB_LVID(sb)->descTag.descCRCLength), 0));
1423 UDF_SB_LVID(sb)->descTag.tagChecksum = 0;
1424 for (i=0; i<16; i++)
1425 if (i != 4)
1426 UDF_SB_LVID(sb)->descTag.tagChecksum +=
1427 ((uint8_t *)&(UDF_SB_LVID(sb)->descTag))[i];
1429 mark_buffer_dirty(UDF_SB_LVIDBH(sb));
1433 static void udf_close_lvid(struct super_block *sb)
1435 if (UDF_SB_LVIDBH(sb) &&
1436 UDF_SB_LVID(sb)->integrityType == LVID_INTEGRITY_TYPE_OPEN)
1438 int i;
1439 kernel_timestamp cpu_time;
1441 UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
1442 UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
1443 if (udf_time_to_stamp(&cpu_time, CURRENT_TIME))
1444 UDF_SB_LVID(sb)->recordingDateAndTime = cpu_to_lets(cpu_time);
1445 if (UDF_MAX_WRITE_VERSION > le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev))
1446 UDF_SB_LVIDIU(sb)->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION);
1447 if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev))
1448 UDF_SB_LVIDIU(sb)->minUDFReadRev = cpu_to_le16(UDF_SB_UDFREV(sb));
1449 if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev))
1450 UDF_SB_LVIDIU(sb)->minUDFWriteRev = cpu_to_le16(UDF_SB_UDFREV(sb));
1451 UDF_SB_LVID(sb)->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
1453 UDF_SB_LVID(sb)->descTag.descCRC =
1454 cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag),
1455 le16_to_cpu(UDF_SB_LVID(sb)->descTag.descCRCLength), 0));
1457 UDF_SB_LVID(sb)->descTag.tagChecksum = 0;
1458 for (i=0; i<16; i++)
1459 if (i != 4)
1460 UDF_SB_LVID(sb)->descTag.tagChecksum +=
1461 ((uint8_t *)&(UDF_SB_LVID(sb)->descTag))[i];
1463 mark_buffer_dirty(UDF_SB_LVIDBH(sb));
1468 * udf_read_super
1470 * PURPOSE
1471 * Complete the specified super block.
1473 * PRE-CONDITIONS
1474 * sb Pointer to superblock to complete - never NULL.
1475 * sb->s_dev Device to read suberblock from.
1476 * options Pointer to mount options.
1477 * silent Silent flag.
1479 * HISTORY
1480 * July 1, 1997 - Andrew E. Mileski
1481 * Written, tested, and released.
1483 static int udf_fill_super(struct super_block *sb, void *options, int silent)
1485 int i;
1486 struct inode *inode=NULL;
1487 struct udf_options uopt;
1488 kernel_lb_addr rootdir, fileset;
1489 struct udf_sb_info *sbi;
1491 uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT);
1492 uopt.uid = -1;
1493 uopt.gid = -1;
1494 uopt.umask = 0;
1496 sbi = kmalloc(sizeof(struct udf_sb_info), GFP_KERNEL);
1497 if (!sbi)
1498 return -ENOMEM;
1499 sb->s_fs_info = sbi;
1500 memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info));
1502 init_MUTEX(&sbi->s_alloc_sem);
1504 if (!udf_parse_options((char *)options, &uopt))
1505 goto error_out;
1507 if (uopt.flags & (1 << UDF_FLAG_UTF8) &&
1508 uopt.flags & (1 << UDF_FLAG_NLS_MAP))
1510 udf_error(sb, "udf_read_super",
1511 "utf8 cannot be combined with iocharset\n");
1512 goto error_out;
1514 #ifdef CONFIG_UDF_NLS
1515 if ((uopt.flags & (1 << UDF_FLAG_NLS_MAP)) && !uopt.nls_map)
1517 uopt.nls_map = load_nls_default();
1518 if (!uopt.nls_map)
1519 uopt.flags &= ~(1 << UDF_FLAG_NLS_MAP);
1520 else
1521 udf_debug("Using default NLS map\n");
1523 #endif
1524 if (!(uopt.flags & (1 << UDF_FLAG_NLS_MAP)))
1525 uopt.flags |= (1 << UDF_FLAG_UTF8);
1527 fileset.logicalBlockNum = 0xFFFFFFFF;
1528 fileset.partitionReferenceNum = 0xFFFF;
1530 UDF_SB(sb)->s_flags = uopt.flags;
1531 UDF_SB(sb)->s_uid = uopt.uid;
1532 UDF_SB(sb)->s_gid = uopt.gid;
1533 UDF_SB(sb)->s_umask = uopt.umask;
1534 UDF_SB(sb)->s_nls_map = uopt.nls_map;
1536 /* Set the block size for all transfers */
1537 if (!udf_set_blocksize(sb, uopt.blocksize))
1538 goto error_out;
1540 if ( uopt.session == 0xFFFFFFFF )
1541 UDF_SB_SESSION(sb) = udf_get_last_session(sb);
1542 else
1543 UDF_SB_SESSION(sb) = uopt.session;
1545 udf_debug("Multi-session=%d\n", UDF_SB_SESSION(sb));
1547 UDF_SB_LASTBLOCK(sb) = uopt.lastblock;
1548 UDF_SB_ANCHOR(sb)[0] = UDF_SB_ANCHOR(sb)[1] = 0;
1549 UDF_SB_ANCHOR(sb)[2] = uopt.anchor;
1550 UDF_SB_ANCHOR(sb)[3] = 256;
1552 if (udf_check_valid(sb, uopt.novrs, silent)) /* read volume recognition sequences */
1554 printk("UDF-fs: No VRS found\n");
1555 goto error_out;
1558 udf_find_anchor(sb);
1560 /* Fill in the rest of the superblock */
1561 sb->s_op = &udf_sb_ops;
1562 sb->dq_op = NULL;
1563 sb->s_dirt = 0;
1564 sb->s_magic = UDF_SUPER_MAGIC;
1565 sb->s_time_gran = 1000;
1567 if (udf_load_partition(sb, &fileset))
1569 printk("UDF-fs: No partition found (1)\n");
1570 goto error_out;
1573 udf_debug("Lastblock=%d\n", UDF_SB_LASTBLOCK(sb));
1575 if ( UDF_SB_LVIDBH(sb) )
1577 uint16_t minUDFReadRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev);
1578 uint16_t minUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev);
1579 /* uint16_t maxUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev); */
1581 if (minUDFReadRev > UDF_MAX_READ_VERSION)
1583 printk("UDF-fs: minUDFReadRev=%x (max is %x)\n",
1584 le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev),
1585 UDF_MAX_READ_VERSION);
1586 goto error_out;
1588 else if (minUDFWriteRev > UDF_MAX_WRITE_VERSION)
1590 sb->s_flags |= MS_RDONLY;
1593 UDF_SB_UDFREV(sb) = minUDFWriteRev;
1595 if (minUDFReadRev >= UDF_VERS_USE_EXTENDED_FE)
1596 UDF_SET_FLAG(sb, UDF_FLAG_USE_EXTENDED_FE);
1597 if (minUDFReadRev >= UDF_VERS_USE_STREAMS)
1598 UDF_SET_FLAG(sb, UDF_FLAG_USE_STREAMS);
1601 if ( !UDF_SB_NUMPARTS(sb) )
1603 printk("UDF-fs: No partition found (2)\n");
1604 goto error_out;
1607 if ( udf_find_fileset(sb, &fileset, &rootdir) )
1609 printk("UDF-fs: No fileset found\n");
1610 goto error_out;
1613 if (!silent)
1615 kernel_timestamp ts;
1616 udf_time_to_stamp(&ts, UDF_SB_RECORDTIME(sb));
1617 udf_info("UDF %s (%s) Mounting volume '%s', timestamp %04u/%02u/%02u %02u:%02u (%x)\n",
1618 UDFFS_VERSION, UDFFS_DATE,
1619 UDF_SB_VOLIDENT(sb), ts.year, ts.month, ts.day, ts.hour, ts.minute,
1620 ts.typeAndTimezone);
1622 if (!(sb->s_flags & MS_RDONLY))
1623 udf_open_lvid(sb);
1625 /* Assign the root inode */
1626 /* assign inodes by physical block number */
1627 /* perhaps it's not extensible enough, but for now ... */
1628 inode = udf_iget(sb, rootdir);
1629 if (!inode)
1631 printk("UDF-fs: Error in udf_iget, block=%d, partition=%d\n",
1632 rootdir.logicalBlockNum, rootdir.partitionReferenceNum);
1633 goto error_out;
1636 /* Allocate a dentry for the root inode */
1637 sb->s_root = d_alloc_root(inode);
1638 if (!sb->s_root)
1640 printk("UDF-fs: Couldn't allocate root dentry\n");
1641 iput(inode);
1642 goto error_out;
1644 sb->s_maxbytes = MAX_LFS_FILESIZE;
1645 return 0;
1647 error_out:
1648 if (UDF_SB_VAT(sb))
1649 iput(UDF_SB_VAT(sb));
1650 if (UDF_SB_NUMPARTS(sb))
1652 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
1653 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
1654 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
1655 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
1656 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
1657 UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb),s_uspace);
1658 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
1659 UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb),s_fspace);
1660 if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15)
1662 for (i=0; i<4; i++)
1663 udf_release_data(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]);
1666 #ifdef CONFIG_UDF_NLS
1667 if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
1668 unload_nls(UDF_SB(sb)->s_nls_map);
1669 #endif
1670 if (!(sb->s_flags & MS_RDONLY))
1671 udf_close_lvid(sb);
1672 udf_release_data(UDF_SB_LVIDBH(sb));
1673 UDF_SB_FREE(sb);
1674 kfree(sbi);
1675 sb->s_fs_info = NULL;
1676 return -EINVAL;
1679 void udf_error(struct super_block *sb, const char *function,
1680 const char *fmt, ...)
1682 va_list args;
1684 if (!(sb->s_flags & MS_RDONLY))
1686 /* mark sb error */
1687 sb->s_dirt = 1;
1689 va_start(args, fmt);
1690 vsprintf(error_buf, fmt, args);
1691 va_end(args);
1692 printk (KERN_CRIT "UDF-fs error (device %s): %s: %s\n",
1693 sb->s_id, function, error_buf);
1696 void udf_warning(struct super_block *sb, const char *function,
1697 const char *fmt, ...)
1699 va_list args;
1701 va_start (args, fmt);
1702 vsprintf(error_buf, fmt, args);
1703 va_end(args);
1704 printk(KERN_WARNING "UDF-fs warning (device %s): %s: %s\n",
1705 sb->s_id, function, error_buf);
1709 * udf_put_super
1711 * PURPOSE
1712 * Prepare for destruction of the superblock.
1714 * DESCRIPTION
1715 * Called before the filesystem is unmounted.
1717 * HISTORY
1718 * July 1, 1997 - Andrew E. Mileski
1719 * Written, tested, and released.
1721 static void
1722 udf_put_super(struct super_block *sb)
1724 int i;
1726 if (UDF_SB_VAT(sb))
1727 iput(UDF_SB_VAT(sb));
1728 if (UDF_SB_NUMPARTS(sb))
1730 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
1731 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
1732 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
1733 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
1734 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
1735 UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb),s_uspace);
1736 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
1737 UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb),s_fspace);
1738 if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15)
1740 for (i=0; i<4; i++)
1741 udf_release_data(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]);
1744 #ifdef CONFIG_UDF_NLS
1745 if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
1746 unload_nls(UDF_SB(sb)->s_nls_map);
1747 #endif
1748 if (!(sb->s_flags & MS_RDONLY))
1749 udf_close_lvid(sb);
1750 udf_release_data(UDF_SB_LVIDBH(sb));
1751 UDF_SB_FREE(sb);
1752 kfree(sb->s_fs_info);
1753 sb->s_fs_info = NULL;
1757 * udf_stat_fs
1759 * PURPOSE
1760 * Return info about the filesystem.
1762 * DESCRIPTION
1763 * Called by sys_statfs()
1765 * HISTORY
1766 * July 1, 1997 - Andrew E. Mileski
1767 * Written, tested, and released.
1769 static int
1770 udf_statfs(struct super_block *sb, struct kstatfs *buf)
1772 buf->f_type = UDF_SUPER_MAGIC;
1773 buf->f_bsize = sb->s_blocksize;
1774 buf->f_blocks = UDF_SB_PARTLEN(sb, UDF_SB_PARTITION(sb));
1775 buf->f_bfree = udf_count_free(sb);
1776 buf->f_bavail = buf->f_bfree;
1777 buf->f_files = (UDF_SB_LVIDBH(sb) ?
1778 (le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) +
1779 le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)) : 0) + buf->f_bfree;
1780 buf->f_ffree = buf->f_bfree;
1781 /* __kernel_fsid_t f_fsid */
1782 buf->f_namelen = UDF_NAME_LEN-2;
1784 return 0;
1787 static unsigned char udf_bitmap_lookup[16] = {
1788 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4
1791 static unsigned int
1792 udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap)
1794 struct buffer_head *bh = NULL;
1795 unsigned int accum = 0;
1796 int index;
1797 int block = 0, newblock;
1798 kernel_lb_addr loc;
1799 uint32_t bytes;
1800 uint8_t value;
1801 uint8_t *ptr;
1802 uint16_t ident;
1803 struct spaceBitmapDesc *bm;
1805 lock_kernel();
1807 loc.logicalBlockNum = bitmap->s_extPosition;
1808 loc.partitionReferenceNum = UDF_SB_PARTITION(sb);
1809 bh = udf_read_ptagged(sb, loc, 0, &ident);
1811 if (!bh)
1813 printk(KERN_ERR "udf: udf_count_free failed\n");
1814 goto out;
1816 else if (ident != TAG_IDENT_SBD)
1818 udf_release_data(bh);
1819 printk(KERN_ERR "udf: udf_count_free failed\n");
1820 goto out;
1823 bm = (struct spaceBitmapDesc *)bh->b_data;
1824 bytes = le32_to_cpu(bm->numOfBytes);
1825 index = sizeof(struct spaceBitmapDesc); /* offset in first block only */
1826 ptr = (uint8_t *)bh->b_data;
1828 while ( bytes > 0 )
1830 while ((bytes > 0) && (index < sb->s_blocksize))
1832 value = ptr[index];
1833 accum += udf_bitmap_lookup[ value & 0x0f ];
1834 accum += udf_bitmap_lookup[ value >> 4 ];
1835 index++;
1836 bytes--;
1838 if ( bytes )
1840 udf_release_data(bh);
1841 newblock = udf_get_lb_pblock(sb, loc, ++block);
1842 bh = udf_tread(sb, newblock);
1843 if (!bh)
1845 udf_debug("read failed\n");
1846 goto out;
1848 index = 0;
1849 ptr = (uint8_t *)bh->b_data;
1852 udf_release_data(bh);
1854 out:
1855 unlock_kernel();
1857 return accum;
1860 static unsigned int
1861 udf_count_free_table(struct super_block *sb, struct inode * table)
1863 unsigned int accum = 0;
1864 uint32_t extoffset, elen;
1865 kernel_lb_addr bloc, eloc;
1866 int8_t etype;
1867 struct buffer_head *bh = NULL;
1869 lock_kernel();
1871 bloc = UDF_I_LOCATION(table);
1872 extoffset = sizeof(struct unallocSpaceEntry);
1874 while ((etype = udf_next_aext(table, &bloc, &extoffset, &eloc, &elen, &bh, 1)) != -1)
1876 accum += (elen >> table->i_sb->s_blocksize_bits);
1878 udf_release_data(bh);
1880 unlock_kernel();
1882 return accum;
1885 static unsigned int
1886 udf_count_free(struct super_block *sb)
1888 unsigned int accum = 0;
1890 if (UDF_SB_LVIDBH(sb))
1892 if (le32_to_cpu(UDF_SB_LVID(sb)->numOfPartitions) > UDF_SB_PARTITION(sb))
1894 accum = le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]);
1896 if (accum == 0xFFFFFFFF)
1897 accum = 0;
1901 if (accum)
1902 return accum;
1904 if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
1906 accum += udf_count_free_bitmap(sb,
1907 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_bitmap);
1909 if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
1911 accum += udf_count_free_bitmap(sb,
1912 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_bitmap);
1914 if (accum)
1915 return accum;
1917 if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
1919 accum += udf_count_free_table(sb,
1920 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
1922 if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
1924 accum += udf_count_free_table(sb,
1925 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
1928 return accum;