Lines Matching +full:out +full:- +full:volume +full:- +full:limit

1 // SPDX-License-Identifier: GPL-2.0-only
6 * Super block routines for the OSTA-UDF(tm) filesystem.
9 * OSTA-UDF(tm) = Optical Storage Technology Association
20 * (C) 1998-2004 Ben Fennema
28 * 10/16/98 attempting some multi-session support
51 #include <linux/crc-itu-t.h>
76 * Maximum number of Terminating Descriptor / Logical Volume Integrity
77 * Descriptor redirections. The chosen numbers are arbitrary - just that we
78 * hopefully don't limit any real use of rewritten inode on write-once media
86 * We limit filesize to 4TB. This is arbitrary as the on-disk format supports
93 /* These are the "meat" - everything else is stuffing */
115 if (!UDF_SB(sb)->s_lvid_bh) in udf_sb_lvidiu()
117 lvid = (struct logicalVolIntegrityDesc *)UDF_SB(sb)->s_lvid_bh->b_data; in udf_sb_lvidiu()
118 partnum = le32_to_cpu(lvid->numOfPartitions); in udf_sb_lvidiu()
157 ei->i_unique = 0; in udf_alloc_inode()
158 ei->i_lenExtents = 0; in udf_alloc_inode()
159 ei->i_lenStreams = 0; in udf_alloc_inode()
160 ei->i_next_alloc_block = 0; in udf_alloc_inode()
161 ei->i_next_alloc_goal = 0; in udf_alloc_inode()
162 ei->i_strat4096 = 0; in udf_alloc_inode()
163 ei->i_streamdir = 0; in udf_alloc_inode()
164 ei->i_hidden = 0; in udf_alloc_inode()
165 init_rwsem(&ei->i_data_sem); in udf_alloc_inode()
166 ei->cached_extent.lstart = -1; in udf_alloc_inode()
167 spin_lock_init(&ei->i_extent_cache_lock); in udf_alloc_inode()
168 inode_set_iversion(&ei->vfs_inode, 1); in udf_alloc_inode()
170 return &ei->vfs_inode; in udf_alloc_inode()
182 ei->i_data = NULL; in init_once()
183 inode_init_once(&ei->vfs_inode); in init_once()
194 return -ENOMEM; in init_inodecache()
241 if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) { in udf_init_options()
242 struct super_block *sb = fc->root->d_sb; in udf_init_options()
245 uopt->flags = sbi->s_flags; in udf_init_options()
246 uopt->uid = sbi->s_uid; in udf_init_options()
247 uopt->gid = sbi->s_gid; in udf_init_options()
248 uopt->umask = sbi->s_umask; in udf_init_options()
249 uopt->fmode = sbi->s_fmode; in udf_init_options()
250 uopt->dmode = sbi->s_dmode; in udf_init_options()
251 uopt->nls_map = NULL; in udf_init_options()
253 uopt->flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | in udf_init_options()
257 * inode [ug]id == -1 in udf_init_options()
259 uopt->uid = make_kuid(current_user_ns(), overflowuid); in udf_init_options()
260 uopt->gid = make_kgid(current_user_ns(), overflowgid); in udf_init_options()
261 uopt->umask = 0; in udf_init_options()
262 uopt->fmode = UDF_INVALID_MODE; in udf_init_options()
263 uopt->dmode = UDF_INVALID_MODE; in udf_init_options()
264 uopt->nls_map = NULL; in udf_init_options()
265 uopt->session = 0xFFFFFFFF; in udf_init_options()
275 return -ENOMEM; in udf_init_fs_context()
279 fc->fs_private = uopt; in udf_init_fs_context()
280 fc->ops = &udf_context_ops; in udf_init_fs_context()
287 struct udf_options *uopt = fc->fs_private; in udf_free_fc()
289 unload_nls(uopt->nls_map); in udf_free_fc()
290 kfree(fc->fs_private); in udf_free_fc()
302 goto out; in init_udf_fs()
306 out: in init_udf_fs()
323 sbi->s_partmaps = kcalloc(count, sizeof(*sbi->s_partmaps), GFP_KERNEL); in udf_sb_alloc_partition_maps()
324 if (!sbi->s_partmaps) { in udf_sb_alloc_partition_maps()
325 sbi->s_partitions = 0; in udf_sb_alloc_partition_maps()
326 return -ENOMEM; in udf_sb_alloc_partition_maps()
329 sbi->s_partitions = count; in udf_sb_alloc_partition_maps()
336 int nr_groups = bitmap->s_nr_groups; in udf_sb_free_bitmap()
339 if (!IS_ERR_OR_NULL(bitmap->s_block_bitmap[i])) in udf_sb_free_bitmap()
340 brelse(bitmap->s_block_bitmap[i]); in udf_sb_free_bitmap()
350 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) in udf_free_partition()
351 iput(map->s_uspace.s_table); in udf_free_partition()
352 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) in udf_free_partition()
353 udf_sb_free_bitmap(map->s_uspace.s_bitmap); in udf_free_partition()
354 if (map->s_partition_type == UDF_SPARABLE_MAP15) in udf_free_partition()
356 brelse(map->s_type_specific.s_sparing.s_spar_map[i]); in udf_free_partition()
357 else if (map->s_partition_type == UDF_METADATA_MAP25) { in udf_free_partition()
358 mdata = &map->s_type_specific.s_metadata; in udf_free_partition()
359 iput(mdata->s_metadata_fe); in udf_free_partition()
360 mdata->s_metadata_fe = NULL; in udf_free_partition()
362 iput(mdata->s_mirror_fe); in udf_free_partition()
363 mdata->s_mirror_fe = NULL; in udf_free_partition()
365 iput(mdata->s_bitmap_fe); in udf_free_partition()
366 mdata->s_bitmap_fe = NULL; in udf_free_partition()
375 if (!sbi->s_partmaps) in udf_sb_free_partitions()
377 for (i = 0; i < sbi->s_partitions; i++) in udf_sb_free_partitions()
378 udf_free_partition(&sbi->s_partmaps[i]); in udf_sb_free_partitions()
379 kfree(sbi->s_partmaps); in udf_sb_free_partitions()
380 sbi->s_partmaps = NULL; in udf_sb_free_partitions()
385 struct super_block *sb = root->d_sb; in udf_show_options()
391 seq_printf(seq, ",bs=%lu", sb->s_blocksize); in udf_show_options()
405 seq_printf(seq, ",uid=%u", from_kuid(&init_user_ns, sbi->s_uid)); in udf_show_options()
407 seq_printf(seq, ",gid=%u", from_kgid(&init_user_ns, sbi->s_gid)); in udf_show_options()
408 if (sbi->s_umask != 0) in udf_show_options()
409 seq_printf(seq, ",umask=%ho", sbi->s_umask); in udf_show_options()
410 if (sbi->s_fmode != UDF_INVALID_MODE) in udf_show_options()
411 seq_printf(seq, ",mode=%ho", sbi->s_fmode); in udf_show_options()
412 if (sbi->s_dmode != UDF_INVALID_MODE) in udf_show_options()
413 seq_printf(seq, ",dmode=%ho", sbi->s_dmode); in udf_show_options()
415 seq_printf(seq, ",session=%d", sbi->s_session); in udf_show_options()
417 seq_printf(seq, ",lastblock=%u", sbi->s_last_block); in udf_show_options()
418 if (sbi->s_anchor != 0) in udf_show_options()
419 seq_printf(seq, ",anchor=%u", sbi->s_anchor); in udf_show_options()
420 if (sbi->s_nls_map) in udf_show_options()
421 seq_printf(seq, ",iocharset=%s", sbi->s_nls_map->charset); in udf_show_options()
454 * novrs Skip volume sequence recognition
460 * volume= Override the VolumeDesc location. (unused)
468 * WARNING: overriding the rootdir to a non-directory may
471 * PRE-CONDITIONS
475 * POST-CONDITIONS
480 * July 1, 1997 - Andrew E. Mileski
507 fsparam_u32 ("volume", Opt_volume),
522 struct udf_options *uopt = fc->fs_private; in udf_parse_param()
525 bool remount = (fc->purpose & FS_CONTEXT_FOR_RECONFIGURE); in udf_parse_param()
533 uopt->flags |= (1 << UDF_FLAG_NOVRS); in udf_parse_param()
538 return -EINVAL; in udf_parse_param()
539 uopt->blocksize = n; in udf_parse_param()
540 uopt->flags |= (1 << UDF_FLAG_BLOCKSIZE_SET); in udf_parse_param()
543 uopt->flags |= (1 << UDF_FLAG_UNHIDE); in udf_parse_param()
546 uopt->flags |= (1 << UDF_FLAG_UNDELETE); in udf_parse_param()
550 uopt->flags &= ~(1 << UDF_FLAG_USE_AD_IN_ICB); in udf_parse_param()
552 uopt->flags |= (1 << UDF_FLAG_USE_AD_IN_ICB); in udf_parse_param()
555 uopt->flags |= (1 << UDF_FLAG_USE_SHORT_AD); in udf_parse_param()
558 uopt->flags &= ~(1 << UDF_FLAG_USE_SHORT_AD); in udf_parse_param()
561 if (kstrtoint(param->string, 10, &uv) == 0) { in udf_parse_param()
564 return -EINVAL; in udf_parse_param()
565 uopt->gid = gid; in udf_parse_param()
566 uopt->flags |= (1 << UDF_FLAG_GID_SET); in udf_parse_param()
567 } else if (!strcmp(param->string, "forget")) { in udf_parse_param()
568 uopt->flags |= (1 << UDF_FLAG_GID_FORGET); in udf_parse_param()
569 } else if (!strcmp(param->string, "ignore")) { in udf_parse_param()
573 return -EINVAL; in udf_parse_param()
577 if (kstrtoint(param->string, 10, &uv) == 0) { in udf_parse_param()
580 return -EINVAL; in udf_parse_param()
581 uopt->uid = uid; in udf_parse_param()
582 uopt->flags |= (1 << UDF_FLAG_UID_SET); in udf_parse_param()
583 } else if (!strcmp(param->string, "forget")) { in udf_parse_param()
584 uopt->flags |= (1 << UDF_FLAG_UID_FORGET); in udf_parse_param()
585 } else if (!strcmp(param->string, "ignore")) { in udf_parse_param()
589 return -EINVAL; in udf_parse_param()
593 uopt->umask = result.uint_32; in udf_parse_param()
596 uopt->flags &= ~(1 << UDF_FLAG_STRICT); in udf_parse_param()
599 uopt->session = result.uint_32; in udf_parse_param()
601 uopt->flags |= (1 << UDF_FLAG_SESSION_SET); in udf_parse_param()
604 uopt->lastblock = result.uint_32; in udf_parse_param()
606 uopt->flags |= (1 << UDF_FLAG_LASTBLOCK_SET); in udf_parse_param()
609 uopt->anchor = result.uint_32; in udf_parse_param()
619 unload_nls(uopt->nls_map); in udf_parse_param()
620 uopt->nls_map = NULL; in udf_parse_param()
625 unload_nls(uopt->nls_map); in udf_parse_param()
626 uopt->nls_map = NULL; in udf_parse_param()
628 /* When nls_map is not loaded then UTF-8 is used */ in udf_parse_param()
629 if (!remount && strcmp(param->string, "utf8") != 0) { in udf_parse_param()
630 uopt->nls_map = load_nls(param->string); in udf_parse_param()
631 if (!uopt->nls_map) { in udf_parse_param()
633 param->string); in udf_parse_param()
634 return -EINVAL; in udf_parse_param()
639 uopt->fmode = result.uint_32 & 0777; in udf_parse_param()
642 uopt->dmode = result.uint_32 & 0777; in udf_parse_param()
645 return -EINVAL; in udf_parse_param()
652 struct udf_options *uopt = fc->fs_private; in udf_reconfigure()
653 struct super_block *sb = fc->root->d_sb; in udf_reconfigure()
655 int readonly = fc->sb_flags & SB_RDONLY; in udf_reconfigure()
659 return -EACCES; in udf_reconfigure()
663 write_lock(&sbi->s_cred_lock); in udf_reconfigure()
664 sbi->s_flags = uopt->flags; in udf_reconfigure()
665 sbi->s_uid = uopt->uid; in udf_reconfigure()
666 sbi->s_gid = uopt->gid; in udf_reconfigure()
667 sbi->s_umask = uopt->umask; in udf_reconfigure()
668 sbi->s_fmode = uopt->fmode; in udf_reconfigure()
669 sbi->s_dmode = uopt->dmode; in udf_reconfigure()
670 write_unlock(&sbi->s_cred_lock); in udf_reconfigure()
685 * Check VSD descriptor. Returns -1 in case we are at the end of volume
686 * recognition area, 0 if the descriptor is valid but non-interesting, 1 if
693 if (!memcmp(vsd->stdIdent, VSD_STD_ID_CD001, VSD_STD_ID_LEN)) { in identify_vsd()
694 switch (vsd->structType) { in identify_vsd()
699 udf_debug("ISO9660 Primary Volume Descriptor found\n"); in identify_vsd()
702 udf_debug("ISO9660 Supplementary Volume Descriptor found\n"); in identify_vsd()
705 udf_debug("ISO9660 Volume Partition Descriptor found\n"); in identify_vsd()
708 udf_debug("ISO9660 Volume Descriptor Set Terminator found\n"); in identify_vsd()
711 udf_debug("ISO9660 VRS (%u) found\n", vsd->structType); in identify_vsd()
714 } else if (!memcmp(vsd->stdIdent, VSD_STD_ID_BEA01, VSD_STD_ID_LEN)) in identify_vsd()
716 else if (!memcmp(vsd->stdIdent, VSD_STD_ID_NSR02, VSD_STD_ID_LEN)) in identify_vsd()
718 else if (!memcmp(vsd->stdIdent, VSD_STD_ID_NSR03, VSD_STD_ID_LEN)) in identify_vsd()
720 else if (!memcmp(vsd->stdIdent, VSD_STD_ID_BOOT2, VSD_STD_ID_LEN)) in identify_vsd()
722 else if (!memcmp(vsd->stdIdent, VSD_STD_ID_CDW02, VSD_STD_ID_LEN)) in identify_vsd()
725 /* TEA01 or invalid id : end of volume recognition area */ in identify_vsd()
726 ret = -1; in identify_vsd()
733 * Check Volume Structure Descriptors (ECMA 167 2/9.1)
734 * We also check any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1)
736 * -1 if first sector read error, 0 otherwise
749 if (sb->s_blocksize < sizeof(struct volStructDesc)) in udf_check_vsd()
752 sectorsize = sb->s_blocksize; in udf_check_vsd()
754 session_offset = (loff_t)sbi->s_session << sb->s_blocksize_bits; in udf_check_vsd()
758 (unsigned int)(sector >> sb->s_blocksize_bits), in udf_check_vsd()
759 sb->s_blocksize); in udf_check_vsd()
760 /* Process the sequence (if applicable). The hard limit on the sector in udf_check_vsd()
763 * bound to the size of the volume recognition area in the standard. in udf_check_vsd()
764 * The limit will prevent the code to read all the sectors of a in udf_check_vsd()
768 * (all 0xFF) before the check for the limit and all valid IDs were in udf_check_vsd()
772 bh = sb_bread(sb, sector >> sb->s_blocksize_bits); in udf_check_vsd()
776 vsd = (struct volStructDesc *)(bh->b_data + in udf_check_vsd()
777 (sector & (sb->s_blocksize - 1))); in udf_check_vsd()
789 if (sb->s_blocksize == 4096) { in udf_check_vsd()
800 else if (!bh && sector - session_offset == VSD_FIRST_SECTOR_OFFSET) in udf_check_vsd()
801 return -1; in udf_check_vsd()
811 if (memcmp(ident->ident, UDF_ID_COMPLIANT, strlen(UDF_ID_COMPLIANT))) { in udf_verify_domain_identifier()
815 if (ident->flags & ENTITYID_FLAGS_DIRTY) { in udf_verify_domain_identifier()
820 suffix = (struct domainIdentSuffix *)ident->identSuffix; in udf_verify_domain_identifier()
821 if ((suffix->domainFlags & DOMAIN_FLAGS_HARD_WRITE_PROTECT) || in udf_verify_domain_identifier()
822 (suffix->domainFlags & DOMAIN_FLAGS_SOFT_WRITE_PROTECT)) { in udf_verify_domain_identifier()
833 return -EACCES; in udf_verify_domain_identifier()
843 ret = udf_verify_domain_identifier(sb, &fset->domainIdent, "file set"); in udf_load_fileset()
847 *root = lelb_to_cpu(fset->rootDirectoryICB.extLocation); in udf_load_fileset()
848 UDF_SB(sb)->s_serial_number = le16_to_cpu(fset->descTag.tagSerialNum); in udf_load_fileset()
851 root->logicalBlockNum, root->partitionReferenceNum); in udf_load_fileset()
863 if (fileset->logicalBlockNum == 0xFFFFFFFF && in udf_find_fileset()
864 fileset->partitionReferenceNum == 0xFFFF) in udf_find_fileset()
865 return -EINVAL; in udf_find_fileset()
869 return -EIO; in udf_find_fileset()
872 return -EINVAL; in udf_find_fileset()
876 fileset->logicalBlockNum, fileset->partitionReferenceNum); in udf_find_fileset()
878 UDF_SB(sb)->s_partition = fileset->partitionReferenceNum; in udf_find_fileset()
879 ret = udf_load_fileset(sb, (struct fileSetDesc *)bh->b_data, root); in udf_find_fileset()
885 * Load primary Volume Descriptor Sequence
887 * Return <0 on error, 0 on success. -EAGAIN is special meaning next sequence
901 return -ENOMEM; in udf_load_pvoldesc()
905 ret = -EAGAIN; in udf_load_pvoldesc()
910 ret = -EIO; in udf_load_pvoldesc()
914 pvoldesc = (struct primaryVolDesc *)bh->b_data; in udf_load_pvoldesc()
916 udf_disk_stamp_to_time(&UDF_SB(sb)->s_record_time, in udf_load_pvoldesc()
917 pvoldesc->recordingDateAndTime); in udf_load_pvoldesc()
918 ts = &pvoldesc->recordingDateAndTime; in udf_load_pvoldesc()
920 le16_to_cpu(ts->year), ts->month, ts->day, ts->hour, in udf_load_pvoldesc()
921 ts->minute, le16_to_cpu(ts->typeAndTimezone)); in udf_load_pvoldesc()
923 ret = udf_dstrCS0toChar(sb, outstr, 31, pvoldesc->volIdent, 32); in udf_load_pvoldesc()
925 strscpy_pad(UDF_SB(sb)->s_volume_ident, "InvalidName"); in udf_load_pvoldesc()
926 pr_warn("incorrect volume identification, setting to " in udf_load_pvoldesc()
929 strscpy_pad(UDF_SB(sb)->s_volume_ident, outstr); in udf_load_pvoldesc()
931 udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident); in udf_load_pvoldesc()
933 ret = udf_dstrCS0toChar(sb, outstr, 127, pvoldesc->volSetIdent, 128); in udf_load_pvoldesc()
964 if (UDF_I(metadata_fe)->i_alloc_type != ICBTAG_FLAG_AD_SHORT) { in udf_find_metadata_inode_efe()
967 return ERR_PTR(-EIO); in udf_find_metadata_inode_efe()
982 map = &sbi->s_partmaps[partition]; in udf_load_metadata_files()
983 mdata = &map->s_type_specific.s_metadata; in udf_load_metadata_files()
984 mdata->s_phys_partition_ref = type1_index; in udf_load_metadata_files()
988 mdata->s_meta_file_loc, mdata->s_phys_partition_ref); in udf_load_metadata_files()
990 fe = udf_find_metadata_inode_efe(sb, mdata->s_meta_file_loc, in udf_load_metadata_files()
991 mdata->s_phys_partition_ref); in udf_load_metadata_files()
995 mdata->s_mirror_file_loc, mdata->s_phys_partition_ref); in udf_load_metadata_files()
997 fe = udf_find_metadata_inode_efe(sb, mdata->s_mirror_file_loc, in udf_load_metadata_files()
998 mdata->s_phys_partition_ref); in udf_load_metadata_files()
1004 mdata->s_mirror_fe = fe; in udf_load_metadata_files()
1006 mdata->s_metadata_fe = fe; in udf_load_metadata_files()
1012 * Load only if bitmap file location differs from 0xFFFFFFFF (DCN-5102) in udf_load_metadata_files()
1014 if (mdata->s_bitmap_file_loc != 0xFFFFFFFF) { in udf_load_metadata_files()
1015 addr.logicalBlockNum = mdata->s_bitmap_file_loc; in udf_load_metadata_files()
1016 addr.partitionReferenceNum = mdata->s_phys_partition_ref; in udf_load_metadata_files()
1024 udf_warn(sb, "bitmap inode efe not found but it's ok since the disc is mounted read-only\n"); in udf_load_metadata_files()
1026 udf_err(sb, "bitmap inode efe not found and attempted read-write mount\n"); in udf_load_metadata_files()
1030 mdata->s_bitmap_fe = fe; in udf_load_metadata_files()
1039 struct udf_part_map *map = &UDF_SB(sb)->s_partmaps[partition]; in udf_compute_nr_groups()
1040 return DIV_ROUND_UP(map->s_partition_len + in udf_compute_nr_groups()
1042 sb->s_blocksize * 8); in udf_compute_nr_groups()
1055 bitmap->s_nr_groups = nr_groups; in udf_sb_alloc_bitmap()
1066 switch (le32_to_cpu(p->accessType)) { in check_partition_desc()
1074 if (strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) && in check_partition_desc()
1075 strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03)) in check_partition_desc()
1078 phd = (struct partitionHeaderDesc *)p->partitionContentsUse; in check_partition_desc()
1079 utable = phd->unallocSpaceTable.extLength; in check_partition_desc()
1080 umap = phd->unallocSpaceBitmap.extLength; in check_partition_desc()
1081 ftable = phd->freedSpaceTable.extLength; in check_partition_desc()
1082 fmap = phd->freedSpaceBitmap.extLength; in check_partition_desc()
1091 /* UDF 2.60: 2.3.3 - no mixing of tables & bitmaps, no VAT. */ in check_partition_desc()
1095 if (map->s_partition_type == UDF_VIRTUAL_MAP15 || in check_partition_desc()
1096 map->s_partition_type == UDF_VIRTUAL_MAP20 || in check_partition_desc()
1097 map->s_partition_type == UDF_METADATA_MAP25) in check_partition_desc()
1103 return -EACCES; in check_partition_desc()
1117 map = &sbi->s_partmaps[p_index]; in udf_fill_partdesc_info()
1119 map->s_partition_len = le32_to_cpu(p->partitionLength); /* blocks */ in udf_fill_partdesc_info()
1120 map->s_partition_root = le32_to_cpu(p->partitionStartingLocation); in udf_fill_partdesc_info()
1121 if (check_add_overflow(map->s_partition_root, map->s_partition_len, in udf_fill_partdesc_info()
1124 p_index, map->s_partition_root, map->s_partition_len); in udf_fill_partdesc_info()
1125 return -EFSCORRUPTED; in udf_fill_partdesc_info()
1128 if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_READ_ONLY)) in udf_fill_partdesc_info()
1129 map->s_partition_flags |= UDF_PART_FLAG_READ_ONLY; in udf_fill_partdesc_info()
1130 if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_WRITE_ONCE)) in udf_fill_partdesc_info()
1131 map->s_partition_flags |= UDF_PART_FLAG_WRITE_ONCE; in udf_fill_partdesc_info()
1132 if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_REWRITABLE)) in udf_fill_partdesc_info()
1133 map->s_partition_flags |= UDF_PART_FLAG_REWRITABLE; in udf_fill_partdesc_info()
1134 if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_OVERWRITABLE)) in udf_fill_partdesc_info()
1135 map->s_partition_flags |= UDF_PART_FLAG_OVERWRITABLE; in udf_fill_partdesc_info()
1138 p_index, map->s_partition_type, in udf_fill_partdesc_info()
1139 map->s_partition_root, map->s_partition_len); in udf_fill_partdesc_info()
1153 phd = (struct partitionHeaderDesc *)p->partitionContentsUse; in udf_fill_partdesc_info()
1154 if (phd->unallocSpaceTable.extLength) { in udf_fill_partdesc_info()
1157 phd->unallocSpaceTable.extPosition), in udf_fill_partdesc_info()
1168 map->s_uspace.s_table = inode; in udf_fill_partdesc_info()
1169 map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_TABLE; in udf_fill_partdesc_info()
1171 p_index, map->s_uspace.s_table->i_ino); in udf_fill_partdesc_info()
1174 if (phd->unallocSpaceBitmap.extLength) { in udf_fill_partdesc_info()
1177 return -ENOMEM; in udf_fill_partdesc_info()
1178 map->s_uspace.s_bitmap = bitmap; in udf_fill_partdesc_info()
1179 bitmap->s_extPosition = le32_to_cpu( in udf_fill_partdesc_info()
1180 phd->unallocSpaceBitmap.extPosition); in udf_fill_partdesc_info()
1181 map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP; in udf_fill_partdesc_info()
1183 if (check_add_overflow(map->s_partition_len, in udf_fill_partdesc_info()
1187 map->s_partition_len); in udf_fill_partdesc_info()
1188 return -EFSCORRUPTED; in udf_fill_partdesc_info()
1191 p_index, bitmap->s_extPosition); in udf_fill_partdesc_info()
1201 struct udf_part_map *map = &sbi->s_partmaps[p_index]; in udf_find_vat_block()
1212 vat_block >= map->s_partition_root && in udf_find_vat_block()
1213 vat_block >= start_block - 3; vat_block--) { in udf_find_vat_block()
1214 ino.logicalBlockNum = vat_block - map->s_partition_root; in udf_find_vat_block()
1217 sbi->s_vat_inode = inode; in udf_find_vat_block()
1226 struct udf_part_map *map = &sbi->s_partmaps[p_index]; in udf_load_vat()
1232 udf_find_vat_block(sb, p_index, type1_index, sbi->s_last_block); in udf_load_vat()
1233 if (!sbi->s_vat_inode && in udf_load_vat()
1234 sbi->s_last_block != blocks - 1) { in udf_load_vat()
1236 (unsigned long)sbi->s_last_block, in udf_load_vat()
1237 (unsigned long)blocks - 1); in udf_load_vat()
1238 udf_find_vat_block(sb, p_index, type1_index, blocks - 1); in udf_load_vat()
1240 if (!sbi->s_vat_inode) in udf_load_vat()
1241 return -EIO; in udf_load_vat()
1243 if (map->s_partition_type == UDF_VIRTUAL_MAP15) { in udf_load_vat()
1244 map->s_type_specific.s_virtual.s_start_offset = 0; in udf_load_vat()
1245 map->s_type_specific.s_virtual.s_num_entries = in udf_load_vat()
1246 (sbi->s_vat_inode->i_size - 36) >> 2; in udf_load_vat()
1247 } else if (map->s_partition_type == UDF_VIRTUAL_MAP20) { in udf_load_vat()
1248 vati = UDF_I(sbi->s_vat_inode); in udf_load_vat()
1249 if (vati->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { in udf_load_vat()
1252 bh = udf_bread(sbi->s_vat_inode, 0, 0, &err); in udf_load_vat()
1255 err = -EFSCORRUPTED; in udf_load_vat()
1258 vat20 = (struct virtualAllocationTable20 *)bh->b_data; in udf_load_vat()
1261 vati->i_data; in udf_load_vat()
1264 map->s_type_specific.s_virtual.s_start_offset = in udf_load_vat()
1265 le16_to_cpu(vat20->lengthHeader); in udf_load_vat()
1266 map->s_type_specific.s_virtual.s_num_entries = in udf_load_vat()
1267 (sbi->s_vat_inode->i_size - in udf_load_vat()
1268 map->s_type_specific.s_virtual. in udf_load_vat()
1278 * Returns <0 on error, 0 on success, -EAGAIN is special - try next descriptor
1294 return -EAGAIN; in udf_load_partdesc()
1300 p = (struct partitionDesc *)bh->b_data; in udf_load_partdesc()
1301 partitionNumber = le16_to_cpu(p->partitionNumber); in udf_load_partdesc()
1304 for (i = 0; i < sbi->s_partitions; i++) { in udf_load_partdesc()
1305 map = &sbi->s_partmaps[i]; in udf_load_partdesc()
1307 map->s_partition_num, partitionNumber); in udf_load_partdesc()
1308 if (map->s_partition_num == partitionNumber && in udf_load_partdesc()
1309 (map->s_partition_type == UDF_TYPE1_MAP15 || in udf_load_partdesc()
1310 map->s_partition_type == UDF_SPARABLE_MAP15)) in udf_load_partdesc()
1314 if (i >= sbi->s_partitions) { in udf_load_partdesc()
1331 for (i = 0; i < sbi->s_partitions; i++) { in udf_load_partdesc()
1332 map = &sbi->s_partmaps[i]; in udf_load_partdesc()
1334 if (map->s_partition_num == partitionNumber && in udf_load_partdesc()
1335 (map->s_partition_type == UDF_VIRTUAL_MAP15 || in udf_load_partdesc()
1336 map->s_partition_type == UDF_VIRTUAL_MAP20 || in udf_load_partdesc()
1337 map->s_partition_type == UDF_METADATA_MAP25)) in udf_load_partdesc()
1341 if (i >= sbi->s_partitions) { in udf_load_partdesc()
1350 if (map->s_partition_type == UDF_METADATA_MAP25) { in udf_load_partdesc()
1364 ret = -EACCES; in udf_load_partdesc()
1386 struct udf_sparing_data *sdata = &map->s_type_specific.s_sparing; in udf_load_sparable_map()
1390 map->s_partition_type = UDF_SPARABLE_MAP15; in udf_load_sparable_map()
1391 sdata->s_packet_len = le16_to_cpu(spm->packetLength); in udf_load_sparable_map()
1392 if (!is_power_of_2(sdata->s_packet_len)) { in udf_load_sparable_map()
1393 udf_err(sb, "error loading logical volume descriptor: " in udf_load_sparable_map()
1395 (unsigned)sdata->s_packet_len); in udf_load_sparable_map()
1396 return -EIO; in udf_load_sparable_map()
1398 if (spm->numSparingTables > 4) { in udf_load_sparable_map()
1399 udf_err(sb, "error loading logical volume descriptor: " in udf_load_sparable_map()
1401 (int)spm->numSparingTables); in udf_load_sparable_map()
1402 return -EIO; in udf_load_sparable_map()
1404 if (le32_to_cpu(spm->sizeSparingTable) > sb->s_blocksize) { in udf_load_sparable_map()
1405 udf_err(sb, "error loading logical volume descriptor: " in udf_load_sparable_map()
1407 le32_to_cpu(spm->sizeSparingTable)); in udf_load_sparable_map()
1408 return -EIO; in udf_load_sparable_map()
1411 for (i = 0; i < spm->numSparingTables; i++) { in udf_load_sparable_map()
1412 loc = le32_to_cpu(spm->locSparingTable[i]); in udf_load_sparable_map()
1417 st = (struct sparingTable *)bh->b_data; in udf_load_sparable_map()
1419 strncmp(st->sparingIdent.ident, UDF_ID_SPARING, in udf_load_sparable_map()
1421 sizeof(*st) + le16_to_cpu(st->reallocationTableLen) > in udf_load_sparable_map()
1422 sb->s_blocksize) { in udf_load_sparable_map()
1427 sdata->s_spar_map[i] = bh; in udf_load_sparable_map()
1429 map->s_partition_func = udf_get_pblock_spar15; in udf_load_sparable_map()
1448 return -EAGAIN; in udf_load_logicalvol()
1450 lvd = (struct logicalVolDesc *)bh->b_data; in udf_load_logicalvol()
1451 table_len = le32_to_cpu(lvd->mapTableLength); in udf_load_logicalvol()
1452 if (table_len > sb->s_blocksize - sizeof(*lvd)) { in udf_load_logicalvol()
1453 udf_err(sb, "error loading logical volume descriptor: " in udf_load_logicalvol()
1455 sb->s_blocksize - sizeof(*lvd)); in udf_load_logicalvol()
1456 ret = -EIO; in udf_load_logicalvol()
1460 ret = udf_verify_domain_identifier(sb, &lvd->domainIdent, in udf_load_logicalvol()
1461 "logical volume"); in udf_load_logicalvol()
1464 ret = udf_sb_alloc_partition_maps(sb, le32_to_cpu(lvd->numPartitionMaps)); in udf_load_logicalvol()
1469 i < sbi->s_partitions && offset < table_len; in udf_load_logicalvol()
1470 i++, offset += gpm->partitionMapLength) { in udf_load_logicalvol()
1471 struct udf_part_map *map = &sbi->s_partmaps[i]; in udf_load_logicalvol()
1473 &(lvd->partitionMaps[offset]); in udf_load_logicalvol()
1474 type = gpm->partitionMapType; in udf_load_logicalvol()
1478 map->s_partition_type = UDF_TYPE1_MAP15; in udf_load_logicalvol()
1479 map->s_volumeseqnum = le16_to_cpu(gpm1->volSeqNum); in udf_load_logicalvol()
1480 map->s_partition_num = le16_to_cpu(gpm1->partitionNum); in udf_load_logicalvol()
1481 map->s_partition_func = NULL; in udf_load_logicalvol()
1485 if (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL, in udf_load_logicalvol()
1488 le16_to_cpu(((__le16 *)upm2->partIdent. in udf_load_logicalvol()
1491 map->s_partition_type = in udf_load_logicalvol()
1493 map->s_partition_func = in udf_load_logicalvol()
1496 map->s_partition_type = in udf_load_logicalvol()
1498 map->s_partition_func = in udf_load_logicalvol()
1501 } else if (!strncmp(upm2->partIdent.ident, in udf_load_logicalvol()
1508 } else if (!strncmp(upm2->partIdent.ident, in udf_load_logicalvol()
1512 &map->s_type_specific.s_metadata; in udf_load_logicalvol()
1515 &(lvd->partitionMaps[offset]); in udf_load_logicalvol()
1519 map->s_partition_type = UDF_METADATA_MAP25; in udf_load_logicalvol()
1520 map->s_partition_func = udf_get_pblock_meta25; in udf_load_logicalvol()
1522 mdata->s_meta_file_loc = in udf_load_logicalvol()
1523 le32_to_cpu(mdm->metadataFileLoc); in udf_load_logicalvol()
1524 mdata->s_mirror_file_loc = in udf_load_logicalvol()
1525 le32_to_cpu(mdm->metadataMirrorFileLoc); in udf_load_logicalvol()
1526 mdata->s_bitmap_file_loc = in udf_load_logicalvol()
1527 le32_to_cpu(mdm->metadataBitmapFileLoc); in udf_load_logicalvol()
1528 mdata->s_alloc_unit_size = in udf_load_logicalvol()
1529 le32_to_cpu(mdm->allocUnitSize); in udf_load_logicalvol()
1530 mdata->s_align_unit_size = in udf_load_logicalvol()
1531 le16_to_cpu(mdm->alignUnitSize); in udf_load_logicalvol()
1532 if (mdm->flags & 0x01) in udf_load_logicalvol()
1533 mdata->s_flags |= MF_DUPLICATE_MD; in udf_load_logicalvol()
1537 mdm->partIdent.identSuffix)); in udf_load_logicalvol()
1539 le16_to_cpu(mdm->partitionNum)); in udf_load_logicalvol()
1541 le32_to_cpu(mdm->allocUnitSize)); in udf_load_logicalvol()
1543 le32_to_cpu(mdm->metadataFileLoc)); in udf_load_logicalvol()
1545 le32_to_cpu(mdm->metadataMirrorFileLoc)); in udf_load_logicalvol()
1547 le32_to_cpu(mdm->metadataBitmapFileLoc)); in udf_load_logicalvol()
1549 mdata->s_flags, mdm->flags); in udf_load_logicalvol()
1552 upm2->partIdent.ident); in udf_load_logicalvol()
1555 map->s_volumeseqnum = le16_to_cpu(upm2->volSeqNum); in udf_load_logicalvol()
1556 map->s_partition_num = le16_to_cpu(upm2->partitionNum); in udf_load_logicalvol()
1558 udf_debug("Partition (%d:%u) type %u on volume %u\n", in udf_load_logicalvol()
1559 i, map->s_partition_num, type, map->s_volumeseqnum); in udf_load_logicalvol()
1563 struct long_ad *la = (struct long_ad *)&(lvd->logicalVolContentsUse[0]); in udf_load_logicalvol()
1565 *fileset = lelb_to_cpu(la->extLocation); in udf_load_logicalvol()
1567 fileset->logicalBlockNum, in udf_load_logicalvol()
1568 fileset->partitionReferenceNum); in udf_load_logicalvol()
1570 if (lvd->integritySeqExt.extLength) in udf_load_logicalvol()
1571 udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt)); in udf_load_logicalvol()
1574 if (!sbi->s_lvid_bh) { in udf_load_logicalvol()
1581 ret = -EACCES; in udf_load_logicalvol()
1594 parts = le32_to_cpu(lvid->numOfPartitions); in udf_lvid_valid()
1595 impuselen = le32_to_cpu(lvid->lengthOfImpUse); in udf_lvid_valid()
1596 if (parts >= sb->s_blocksize || impuselen >= sb->s_blocksize || in udf_lvid_valid()
1598 2 * parts * sizeof(u32) > sb->s_blocksize) in udf_lvid_valid()
1604 * Find the prevailing Logical Volume Integrity Descriptor.
1627 loc.extLength -= sb->s_blocksize; in udf_load_logicalvolint()
1634 lvid = (struct logicalVolIntegrityDesc *)final_bh->b_data; in udf_load_logicalvolint()
1636 brelse(sbi->s_lvid_bh); in udf_load_logicalvolint()
1637 sbi->s_lvid_bh = final_bh; in udf_load_logicalvolint()
1641 le32_to_cpu(lvid->numOfPartitions), in udf_load_logicalvolint()
1642 le32_to_cpu(lvid->lengthOfImpUse)); in udf_load_logicalvolint()
1645 if (lvid->nextIntegrityExt.extLength == 0) in udf_load_logicalvolint()
1648 loc = leea_to_cpu(lvid->nextIntegrityExt); in udf_load_logicalvolint()
1653 brelse(sbi->s_lvid_bh); in udf_load_logicalvolint()
1654 sbi->s_lvid_bh = NULL; in udf_load_logicalvolint()
1679 struct partitionDesc *desc = (struct partitionDesc *)bh->b_data; in handle_partition_descriptor()
1683 partnum = le16_to_cpu(desc->partitionNumber); in handle_partition_descriptor()
1684 for (i = 0; i < data->num_part_descs; i++) in handle_partition_descriptor()
1685 if (partnum == data->part_descs_loc[i].partnum) in handle_partition_descriptor()
1686 return &(data->part_descs_loc[i].rec); in handle_partition_descriptor()
1687 if (data->num_part_descs >= data->size_part_descs) { in handle_partition_descriptor()
1693 return ERR_PTR(-ENOMEM); in handle_partition_descriptor()
1694 memcpy(new_loc, data->part_descs_loc, in handle_partition_descriptor()
1695 data->size_part_descs * sizeof(*new_loc)); in handle_partition_descriptor()
1696 kfree(data->part_descs_loc); in handle_partition_descriptor()
1697 data->part_descs_loc = new_loc; in handle_partition_descriptor()
1698 data->size_part_descs = new_size; in handle_partition_descriptor()
1700 return &(data->part_descs_loc[data->num_part_descs++].rec); in handle_partition_descriptor()
1709 return &(data->vds[VDS_POS_PRIMARY_VOL_DESC]); in get_volume_descriptor_record()
1711 return &(data->vds[VDS_POS_IMP_USE_VOL_DESC]); in get_volume_descriptor_record()
1713 return &(data->vds[VDS_POS_LOGICAL_VOL_DESC]); in get_volume_descriptor_record()
1715 return &(data->vds[VDS_POS_UNALLOC_SPACE_DESC]); in get_volume_descriptor_record()
1723 * Process a main/reserve volume descriptor sequence.
1728 * Returns <0 on error, 0 on success. -EAGAIN is special - try next descriptor
1755 return -ENOMEM; in udf_process_sequence()
1766 /* Process each descriptor (ISO 13346 3/8.3-8.4) */ in udf_process_sequence()
1767 gd = (struct generic_desc *)bh->b_data; in udf_process_sequence()
1768 vdsn = le32_to_cpu(gd->volDescSeqNum); in udf_process_sequence()
1772 udf_err(sb, "too many Volume Descriptor " in udf_process_sequence()
1776 ret = -EIO; in udf_process_sequence()
1777 goto out; in udf_process_sequence()
1780 vdp = (struct volDescPtr *)bh->b_data; in udf_process_sequence()
1781 block = le32_to_cpu(vdp->nextVolDescSeqExt.extLocation); in udf_process_sequence()
1783 vdp->nextVolDescSeqExt.extLength) >> in udf_process_sequence()
1784 sb->s_blocksize_bits; in udf_process_sequence()
1785 lastblock += block - 1; in udf_process_sequence()
1787 block--; in udf_process_sequence()
1798 goto out; in udf_process_sequence()
1803 if (vdsn >= curr->volDescSeqNum) { in udf_process_sequence()
1804 curr->volDescSeqNum = vdsn; in udf_process_sequence()
1805 curr->block = block; in udf_process_sequence()
1819 udf_err(sb, "Primary Volume Descriptor not found!\n"); in udf_process_sequence()
1820 ret = -EAGAIN; in udf_process_sequence()
1821 goto out; in udf_process_sequence()
1825 goto out; in udf_process_sequence()
1832 goto out; in udf_process_sequence()
1839 goto out; in udf_process_sequence()
1842 out: in udf_process_sequence()
1848 * Load Volume Descriptor Sequence described by anchor in bh
1859 anchor = (struct anchorVolDescPtr *)bh->b_data; in udf_load_sequence()
1862 main_s = le32_to_cpu(anchor->mainVolDescSeqExt.extLocation); in udf_load_sequence()
1863 main_e = le32_to_cpu(anchor->mainVolDescSeqExt.extLength); in udf_load_sequence()
1864 main_e = main_e >> sb->s_blocksize_bits; in udf_load_sequence()
1865 main_e += main_s - 1; in udf_load_sequence()
1868 reserve_s = le32_to_cpu(anchor->reserveVolDescSeqExt.extLocation); in udf_load_sequence()
1869 reserve_e = le32_to_cpu(anchor->reserveVolDescSeqExt.extLength); in udf_load_sequence()
1870 reserve_e = reserve_e >> sb->s_blocksize_bits; in udf_load_sequence()
1871 reserve_e += reserve_s - 1; in udf_load_sequence()
1876 if (ret != -EAGAIN) in udf_load_sequence()
1882 /* No sequence was OK, return -EIO */ in udf_load_sequence()
1883 if (ret == -EAGAIN) in udf_load_sequence()
1884 ret = -EIO; in udf_load_sequence()
1891 * load Volume Descriptor Sequence if so.
1893 * Returns <0 on error, 0 on success, -EAGAIN is special - try next anchor
1905 return -EAGAIN; in udf_check_anchor_block()
1908 return -EAGAIN; in udf_check_anchor_block()
1916 * Search for an anchor volume descriptor pointer.
1918 * Returns < 0 on error, 0 on success. -EAGAIN is special - try next set
1931 if (sbi->s_anchor) { in udf_scan_anchors()
1932 ret = udf_check_anchor_block(sb, sbi->s_anchor, fileset); in udf_scan_anchors()
1933 if (ret != -EAGAIN) in udf_scan_anchors()
1939 * lastblock-256 in udf_scan_anchors()
1943 ret = udf_check_anchor_block(sb, sbi->s_session + 256, fileset); in udf_scan_anchors()
1944 if (ret != -EAGAIN) in udf_scan_anchors()
1952 last[last_count++] = *lastblock - 1; in udf_scan_anchors()
1955 last[last_count++] = *lastblock - 2; in udf_scan_anchors()
1957 last[last_count++] = *lastblock - 150; in udf_scan_anchors()
1959 last[last_count++] = *lastblock - 152; in udf_scan_anchors()
1965 if (ret != -EAGAIN) { in udf_scan_anchors()
1972 ret = udf_check_anchor_block(sb, last[i] - 256, fileset); in udf_scan_anchors()
1973 if (ret != -EAGAIN) { in udf_scan_anchors()
1981 return udf_check_anchor_block(sb, sbi->s_session + 512, fileset); in udf_scan_anchors()
1985 * Check Volume Structure Descriptor, find Anchor block and load Volume
1988 * Returns < 0 on error, 0 on success. -EAGAIN is special meaning anchor
1998 if (!sb_set_blocksize(sb, uopt->blocksize)) { in udf_load_vrs()
2001 return -EINVAL; in udf_load_vrs()
2003 sbi->s_last_block = uopt->lastblock; in udf_load_vrs()
2010 return -EINVAL; in udf_load_vrs()
2012 if (nsr == -1) in udf_load_vrs()
2016 if (!sbi->s_last_block) in udf_load_vrs()
2017 sbi->s_last_block = udf_get_last_block(sb); in udf_load_vrs()
2022 /* Look for anchor block and load Volume Descriptor Sequence */ in udf_load_vrs()
2023 sbi->s_anchor = uopt->anchor; in udf_load_vrs()
2024 ret = udf_scan_anchors(sb, &sbi->s_last_block, fileset); in udf_load_vrs()
2026 if (!silent && ret == -EAGAIN) in udf_load_vrs()
2038 udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts); in udf_finalize_lvid()
2039 lvid->descTag.descCRC = cpu_to_le16( in udf_finalize_lvid()
2041 le16_to_cpu(lvid->descTag.descCRCLength))); in udf_finalize_lvid()
2042 lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag); in udf_finalize_lvid()
2048 struct buffer_head *bh = sbi->s_lvid_bh; in udf_open_lvid()
2054 lvid = (struct logicalVolIntegrityDesc *)bh->b_data; in udf_open_lvid()
2059 mutex_lock(&sbi->s_alloc_mutex); in udf_open_lvid()
2060 lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; in udf_open_lvid()
2061 lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; in udf_open_lvid()
2062 if (le32_to_cpu(lvid->integrityType) == LVID_INTEGRITY_TYPE_CLOSE) in udf_open_lvid()
2063 lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN); in udf_open_lvid()
2069 sbi->s_lvid_dirty = 0; in udf_open_lvid()
2070 mutex_unlock(&sbi->s_alloc_mutex); in udf_open_lvid()
2078 struct buffer_head *bh = sbi->s_lvid_bh; in udf_close_lvid()
2084 lvid = (struct logicalVolIntegrityDesc *)bh->b_data; in udf_close_lvid()
2089 mutex_lock(&sbi->s_alloc_mutex); in udf_close_lvid()
2090 lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; in udf_close_lvid()
2091 lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; in udf_close_lvid()
2092 if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev)) in udf_close_lvid()
2093 lvidiu->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION); in udf_close_lvid()
2094 if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev)) in udf_close_lvid()
2095 lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev); in udf_close_lvid()
2096 if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev)) in udf_close_lvid()
2097 lvidiu->minUDFWriteRev = cpu_to_le16(sbi->s_udfrev); in udf_close_lvid()
2099 lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE); in udf_close_lvid()
2109 sbi->s_lvid_dirty = 0; in udf_close_lvid()
2110 mutex_unlock(&sbi->s_alloc_mutex); in udf_close_lvid()
2124 bh = sbi->s_lvid_bh; in lvid_get_unique_id()
2128 lvid = (struct logicalVolIntegrityDesc *)bh->b_data; in lvid_get_unique_id()
2129 lvhd = (struct logicalVolHeaderDesc *)lvid->logicalVolContentsUse; in lvid_get_unique_id()
2131 mutex_lock(&sbi->s_alloc_mutex); in lvid_get_unique_id()
2132 ret = uniqueID = le64_to_cpu(lvhd->uniqueID); in lvid_get_unique_id()
2135 lvhd->uniqueID = cpu_to_le64(uniqueID); in lvid_get_unique_id()
2137 mutex_unlock(&sbi->s_alloc_mutex); in lvid_get_unique_id()
2144 int ret = -EINVAL; in udf_fill_super()
2146 struct udf_options *uopt = fc->fs_private; in udf_fill_super()
2150 int silent = fc->sb_flags & SB_SILENT; in udf_fill_super()
2154 return -ENOMEM; in udf_fill_super()
2156 sb->s_fs_info = sbi; in udf_fill_super()
2158 mutex_init(&sbi->s_alloc_mutex); in udf_fill_super()
2163 sbi->s_flags = uopt->flags; in udf_fill_super()
2164 sbi->s_uid = uopt->uid; in udf_fill_super()
2165 sbi->s_gid = uopt->gid; in udf_fill_super()
2166 sbi->s_umask = uopt->umask; in udf_fill_super()
2167 sbi->s_fmode = uopt->fmode; in udf_fill_super()
2168 sbi->s_dmode = uopt->dmode; in udf_fill_super()
2169 sbi->s_nls_map = uopt->nls_map; in udf_fill_super()
2170 uopt->nls_map = NULL; in udf_fill_super()
2171 rwlock_init(&sbi->s_cred_lock); in udf_fill_super()
2173 if (uopt->session == 0xFFFFFFFF) in udf_fill_super()
2174 sbi->s_session = udf_get_last_session(sb); in udf_fill_super()
2176 sbi->s_session = uopt->session; in udf_fill_super()
2178 udf_debug("Multi-session=%d\n", sbi->s_session); in udf_fill_super()
2181 sb->s_op = &udf_sb_ops; in udf_fill_super()
2182 sb->s_export_op = &udf_export_ops; in udf_fill_super()
2184 sb->s_magic = UDF_SUPER_MAGIC; in udf_fill_super()
2185 sb->s_time_gran = 1000; in udf_fill_super()
2187 if (uopt->flags & (1 << UDF_FLAG_BLOCKSIZE_SET)) { in udf_fill_super()
2190 uopt->blocksize = bdev_logical_block_size(sb->s_bdev); in udf_fill_super()
2191 while (uopt->blocksize <= 4096) { in udf_fill_super()
2194 if (!silent && ret != -EACCES) { in udf_fill_super()
2196 uopt->blocksize); in udf_fill_super()
2198 brelse(sbi->s_lvid_bh); in udf_fill_super()
2199 sbi->s_lvid_bh = NULL; in udf_fill_super()
2201 * EACCES is special - we want to propagate to in udf_fill_super()
2204 if (ret == -EACCES) in udf_fill_super()
2209 uopt->blocksize <<= 1; in udf_fill_super()
2213 if (ret == -EAGAIN) { in udf_fill_super()
2215 ret = -EINVAL; in udf_fill_super()
2220 udf_debug("Lastblock=%u\n", sbi->s_last_block); in udf_fill_super()
2222 if (sbi->s_lvid_bh) { in udf_fill_super()
2229 ret = -EINVAL; in udf_fill_super()
2232 minUDFReadRev = le16_to_cpu(lvidiu->minUDFReadRev); in udf_fill_super()
2233 minUDFWriteRev = le16_to_cpu(lvidiu->minUDFWriteRev); in udf_fill_super()
2238 ret = -EINVAL; in udf_fill_super()
2242 ret = -EACCES; in udf_fill_super()
2248 sbi->s_udfrev = minUDFWriteRev; in udf_fill_super()
2256 if (!sbi->s_partitions) { in udf_fill_super()
2258 ret = -EINVAL; in udf_fill_super()
2262 if (sbi->s_partmaps[sbi->s_partition].s_partition_flags & in udf_fill_super()
2265 ret = -EACCES; in udf_fill_super()
2279 udf_time_to_disk_stamp(&ts, sbi->s_record_time); in udf_fill_super()
2280 udf_info("Mounting volume '%s', timestamp %04u/%02u/%02u %02u:%02u (%x)\n", in udf_fill_super()
2281 sbi->s_volume_ident, in udf_fill_super()
2302 sb->s_root = d_make_root(inode); in udf_fill_super()
2303 if (!sb->s_root) { in udf_fill_super()
2305 ret = -ENOMEM; in udf_fill_super()
2308 sb->s_maxbytes = UDF_MAX_FILESIZE; in udf_fill_super()
2309 sb->s_max_links = UDF_MAX_LINKS; in udf_fill_super()
2313 iput(sbi->s_vat_inode); in udf_fill_super()
2314 unload_nls(uopt->nls_map); in udf_fill_super()
2317 brelse(sbi->s_lvid_bh); in udf_fill_super()
2320 sb->s_fs_info = NULL; in udf_fill_super()
2336 pr_err("error (device %s): %s: %pV", sb->s_id, function, &vaf); in _udf_err()
2352 pr_warn("warning (device %s): %s: %pV", sb->s_id, function, &vaf); in _udf_warn()
2363 iput(sbi->s_vat_inode); in udf_put_super()
2364 unload_nls(sbi->s_nls_map); in udf_put_super()
2367 brelse(sbi->s_lvid_bh); in udf_put_super()
2369 mutex_destroy(&sbi->s_alloc_mutex); in udf_put_super()
2370 kfree(sb->s_fs_info); in udf_put_super()
2371 sb->s_fs_info = NULL; in udf_put_super()
2378 mutex_lock(&sbi->s_alloc_mutex); in udf_sync_fs()
2379 if (sbi->s_lvid_dirty) { in udf_sync_fs()
2380 struct buffer_head *bh = sbi->s_lvid_bh; in udf_sync_fs()
2383 lvid = (struct logicalVolIntegrityDesc *)bh->b_data; in udf_sync_fs()
2391 sbi->s_lvid_dirty = 0; in udf_sync_fs()
2393 mutex_unlock(&sbi->s_alloc_mutex); in udf_sync_fs()
2400 struct super_block *sb = dentry->d_sb; in udf_statfs()
2403 u64 id = huge_encode_dev(sb->s_bdev->bd_dev); in udf_statfs()
2406 buf->f_type = UDF_SUPER_MAGIC; in udf_statfs()
2407 buf->f_bsize = sb->s_blocksize; in udf_statfs()
2408 buf->f_blocks = sbi->s_partmaps[sbi->s_partition].s_partition_len; in udf_statfs()
2409 buf->f_bfree = udf_count_free(sb); in udf_statfs()
2410 buf->f_bavail = buf->f_bfree; in udf_statfs()
2415 buf->f_files = (lvidiu != NULL ? (le32_to_cpu(lvidiu->numFiles) + in udf_statfs()
2416 le32_to_cpu(lvidiu->numDirs)) : 0) in udf_statfs()
2417 + buf->f_bfree; in udf_statfs()
2418 buf->f_ffree = buf->f_bfree; in udf_statfs()
2419 buf->f_namelen = UDF_NAME_LEN; in udf_statfs()
2420 buf->f_fsid = u64_to_fsid(id); in udf_statfs()
2438 loc.logicalBlockNum = bitmap->s_extPosition; in udf_count_free_bitmap()
2439 loc.partitionReferenceNum = UDF_SB(sb)->s_partition; in udf_count_free_bitmap()
2444 goto out; in udf_count_free_bitmap()
2448 goto out; in udf_count_free_bitmap()
2451 bm = (struct spaceBitmapDesc *)bh->b_data; in udf_count_free_bitmap()
2452 bytes = le32_to_cpu(bm->numOfBytes); in udf_count_free_bitmap()
2454 ptr = (uint8_t *)bh->b_data; in udf_count_free_bitmap()
2457 u32 cur_bytes = min_t(u32, bytes, sb->s_blocksize - index); in udf_count_free_bitmap()
2460 bytes -= cur_bytes; in udf_count_free_bitmap()
2467 goto out; in udf_count_free_bitmap()
2470 ptr = (uint8_t *)bh->b_data; in udf_count_free_bitmap()
2474 out: in udf_count_free_bitmap()
2487 mutex_lock(&UDF_SB(sb)->s_alloc_mutex); in udf_count_free_table()
2488 epos.block = UDF_I(table)->i_location; in udf_count_free_table()
2493 accum += (elen >> table->i_sb->s_blocksize_bits); in udf_count_free_table()
2496 mutex_unlock(&UDF_SB(sb)->s_alloc_mutex); in udf_count_free_table()
2506 unsigned int part = sbi->s_partition; in udf_count_free()
2507 int ptype = sbi->s_partmaps[part].s_partition_type; in udf_count_free()
2510 part = sbi->s_partmaps[part].s_type_specific.s_metadata. in udf_count_free()
2514 * Filesystems with VAT are append-only and we cannot write to in udf_count_free()
2520 if (sbi->s_lvid_bh) { in udf_count_free()
2523 sbi->s_lvid_bh->b_data; in udf_count_free()
2524 if (le32_to_cpu(lvid->numOfPartitions) > part) { in udf_count_free()
2526 lvid->freeSpaceTable[part]); in udf_count_free()
2535 map = &sbi->s_partmaps[part]; in udf_count_free()
2536 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP) { in udf_count_free()
2538 map->s_uspace.s_bitmap); in udf_count_free()
2543 if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE) { in udf_count_free()
2545 map->s_uspace.s_table); in udf_count_free()