Lines Matching refs:vol
95 static bool parse_options(ntfs_volume *vol, char *opt) in parse_options() argument
200 ntfs_warning(vol->sb, "Ignoring obsolete option %s.", in parse_options()
204 ntfs_warning(vol->sb, "Option iocharset is " in parse_options()
215 ntfs_error(vol->sb, "NLS character set " in parse_options()
219 ntfs_error(vol->sb, "NLS character set %s not " in parse_options()
228 ntfs_warning(vol->sb, "Option utf8 is no longer " in parse_options()
242 ntfs_error(vol->sb, "Unrecognized mount option %s.", p); in parse_options()
255 ntfs_warning(vol->sb, "Sloppy option given. Ignoring " in parse_options()
260 ntfs_error(vol->sb, "Invalid errors option argument " in parse_options()
266 if (vol->nls_map && vol->nls_map != nls_map) { in parse_options()
267 ntfs_error(vol->sb, "Cannot change NLS character set " in parse_options()
272 vol->nls_map = nls_map; in parse_options()
274 if (!vol->nls_map) { in parse_options()
275 vol->nls_map = load_nls_default(); in parse_options()
276 if (!vol->nls_map) { in parse_options()
277 ntfs_error(vol->sb, "Failed to load default " in parse_options()
282 vol->nls_map->charset); in parse_options()
286 if (vol->mft_zone_multiplier && vol->mft_zone_multiplier != in parse_options()
288 ntfs_error(vol->sb, "Cannot change mft_zone_multiplier " in parse_options()
293 ntfs_error(vol->sb, "Invalid mft_zone_multiplier. " in parse_options()
297 vol->mft_zone_multiplier = mft_zone_multiplier; in parse_options()
299 if (!vol->mft_zone_multiplier) in parse_options()
300 vol->mft_zone_multiplier = 1; in parse_options()
302 vol->on_errors = on_errors; in parse_options()
303 if (!vol->on_errors || vol->on_errors == ON_ERRORS_RECOVER) in parse_options()
304 vol->on_errors |= ON_ERRORS_CONTINUE; in parse_options()
306 vol->uid = uid; in parse_options()
308 vol->gid = gid; in parse_options()
310 vol->fmask = fmask; in parse_options()
312 vol->dmask = dmask; in parse_options()
315 NVolSetShowSystemFiles(vol); in parse_options()
317 NVolClearShowSystemFiles(vol); in parse_options()
321 NVolSetCaseSensitive(vol); in parse_options()
323 NVolClearCaseSensitive(vol); in parse_options()
327 NVolClearSparseEnabled(vol); in parse_options()
329 if (!NVolSparseEnabled(vol) && in parse_options()
330 vol->major_ver && vol->major_ver < 3) in parse_options()
331 ntfs_warning(vol->sb, "Not enabling sparse " in parse_options()
334 "version 3.0).", vol->major_ver, in parse_options()
335 vol->minor_ver); in parse_options()
337 NVolSetSparseEnabled(vol); in parse_options()
342 ntfs_error(vol->sb, "The %s option requires an argument.", p); in parse_options()
345 ntfs_error(vol->sb, "The %s option requires a boolean argument.", p); in parse_options()
348 ntfs_error(vol->sb, "Invalid %s option argument: %s", p, ov); in parse_options()
369 static int ntfs_write_volume_flags(ntfs_volume *vol, const VOLUME_FLAGS flags) in ntfs_write_volume_flags() argument
371 ntfs_inode *ni = NTFS_I(vol->vol_ino); in ntfs_write_volume_flags()
378 le16_to_cpu(vol->vol_flags), le16_to_cpu(flags)); in ntfs_write_volume_flags()
379 if (vol->vol_flags == flags) in ntfs_write_volume_flags()
398 vol->vol_flags = vi->flags = flags; in ntfs_write_volume_flags()
411 ntfs_error(vol->sb, "Failed with error code %i.", -err); in ntfs_write_volume_flags()
424 static inline int ntfs_set_volume_flags(ntfs_volume *vol, VOLUME_FLAGS flags) in ntfs_set_volume_flags() argument
427 return ntfs_write_volume_flags(vol, vol->vol_flags | flags); in ntfs_set_volume_flags()
439 static inline int ntfs_clear_volume_flags(ntfs_volume *vol, VOLUME_FLAGS flags) in ntfs_clear_volume_flags() argument
442 flags = vol->vol_flags & cpu_to_le16(~le16_to_cpu(flags)); in ntfs_clear_volume_flags()
443 return ntfs_write_volume_flags(vol, flags); in ntfs_clear_volume_flags()
462 ntfs_volume *vol = NTFS_SB(sb); in ntfs_remount() local
488 if (NVolErrors(vol)) { in ntfs_remount()
493 if (vol->vol_flags & VOLUME_IS_DIRTY) { in ntfs_remount()
497 if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) { in ntfs_remount()
502 if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) { in ntfs_remount()
505 (unsigned)le16_to_cpu(vol->vol_flags), in ntfs_remount()
509 if (ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) { in ntfs_remount()
518 if ((vol->major_ver > 1)) { in ntfs_remount()
519 if (ntfs_set_volume_flags(vol, VOLUME_MOUNTED_ON_NT4)) { in ntfs_remount()
522 NVolSetErrors(vol); in ntfs_remount()
527 if (!ntfs_empty_logfile(vol->logfile_ino)) { in ntfs_remount()
530 NVolSetErrors(vol); in ntfs_remount()
533 if (!ntfs_mark_quotas_out_of_date(vol)) { in ntfs_remount()
536 NVolSetErrors(vol); in ntfs_remount()
539 if (!ntfs_stamp_usnjrnl(vol)) { in ntfs_remount()
542 NVolSetErrors(vol); in ntfs_remount()
547 if (!NVolErrors(vol)) { in ntfs_remount()
548 if (ntfs_clear_volume_flags(vol, VOLUME_IS_DIRTY)) in ntfs_remount()
558 if (!parse_options(vol, opt)) in ntfs_remount()
760 static bool parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) in parse_ntfs_boot_sector() argument
766 vol->sector_size = le16_to_cpu(b->bpb.bytes_per_sector); in parse_ntfs_boot_sector()
767 vol->sector_size_bits = ffs(vol->sector_size) - 1; in parse_ntfs_boot_sector()
768 ntfs_debug("vol->sector_size = %i (0x%x)", vol->sector_size, in parse_ntfs_boot_sector()
769 vol->sector_size); in parse_ntfs_boot_sector()
770 ntfs_debug("vol->sector_size_bits = %i (0x%x)", vol->sector_size_bits, in parse_ntfs_boot_sector()
771 vol->sector_size_bits); in parse_ntfs_boot_sector()
772 if (vol->sector_size < vol->sb->s_blocksize) { in parse_ntfs_boot_sector()
773 ntfs_error(vol->sb, "Sector size (%i) is smaller than the " in parse_ntfs_boot_sector()
775 "supported. Sorry.", vol->sector_size, in parse_ntfs_boot_sector()
776 vol->sb->s_blocksize); in parse_ntfs_boot_sector()
785 vol->cluster_size = vol->sector_size << sectors_per_cluster_bits; in parse_ntfs_boot_sector()
786 vol->cluster_size_mask = vol->cluster_size - 1; in parse_ntfs_boot_sector()
787 vol->cluster_size_bits = ffs(vol->cluster_size) - 1; in parse_ntfs_boot_sector()
788 ntfs_debug("vol->cluster_size = %i (0x%x)", vol->cluster_size, in parse_ntfs_boot_sector()
789 vol->cluster_size); in parse_ntfs_boot_sector()
790 ntfs_debug("vol->cluster_size_mask = 0x%x", vol->cluster_size_mask); in parse_ntfs_boot_sector()
791 ntfs_debug("vol->cluster_size_bits = %i", vol->cluster_size_bits); in parse_ntfs_boot_sector()
792 if (vol->cluster_size < vol->sector_size) { in parse_ntfs_boot_sector()
793 ntfs_error(vol->sb, "Cluster size (%i) is smaller than the " in parse_ntfs_boot_sector()
795 "Sorry.", vol->cluster_size, vol->sector_size); in parse_ntfs_boot_sector()
802 vol->mft_record_size = vol->cluster_size << in parse_ntfs_boot_sector()
810 vol->mft_record_size = 1 << -clusters_per_mft_record; in parse_ntfs_boot_sector()
811 vol->mft_record_size_mask = vol->mft_record_size - 1; in parse_ntfs_boot_sector()
812 vol->mft_record_size_bits = ffs(vol->mft_record_size) - 1; in parse_ntfs_boot_sector()
813 ntfs_debug("vol->mft_record_size = %i (0x%x)", vol->mft_record_size, in parse_ntfs_boot_sector()
814 vol->mft_record_size); in parse_ntfs_boot_sector()
816 vol->mft_record_size_mask); in parse_ntfs_boot_sector()
818 vol->mft_record_size_bits, vol->mft_record_size_bits); in parse_ntfs_boot_sector()
823 if (vol->mft_record_size > PAGE_SIZE) { in parse_ntfs_boot_sector()
824 ntfs_error(vol->sb, "Mft record size (%i) exceeds the " in parse_ntfs_boot_sector()
827 vol->mft_record_size, PAGE_SIZE); in parse_ntfs_boot_sector()
831 if (vol->mft_record_size < vol->sector_size) { in parse_ntfs_boot_sector()
832 ntfs_error(vol->sb, "Mft record size (%i) is smaller than the " in parse_ntfs_boot_sector()
834 "Sorry.", vol->mft_record_size, in parse_ntfs_boot_sector()
835 vol->sector_size); in parse_ntfs_boot_sector()
842 vol->index_record_size = vol->cluster_size << in parse_ntfs_boot_sector()
851 vol->index_record_size = 1 << -clusters_per_index_record; in parse_ntfs_boot_sector()
852 vol->index_record_size_mask = vol->index_record_size - 1; in parse_ntfs_boot_sector()
853 vol->index_record_size_bits = ffs(vol->index_record_size) - 1; in parse_ntfs_boot_sector()
855 vol->index_record_size, vol->index_record_size); in parse_ntfs_boot_sector()
857 vol->index_record_size_mask); in parse_ntfs_boot_sector()
859 vol->index_record_size_bits, in parse_ntfs_boot_sector()
860 vol->index_record_size_bits); in parse_ntfs_boot_sector()
862 if (vol->index_record_size < vol->sector_size) { in parse_ntfs_boot_sector()
863 ntfs_error(vol->sb, "Index record size (%i) is smaller than " in parse_ntfs_boot_sector()
865 "supported. Sorry.", vol->index_record_size, in parse_ntfs_boot_sector()
866 vol->sector_size); in parse_ntfs_boot_sector()
876 ntfs_error(vol->sb, "Cannot handle 64-bit clusters. Sorry."); in parse_ntfs_boot_sector()
879 vol->nr_clusters = ll; in parse_ntfs_boot_sector()
880 ntfs_debug("vol->nr_clusters = 0x%llx", (long long)vol->nr_clusters); in parse_ntfs_boot_sector()
887 if ((ll << vol->cluster_size_bits) >= (1ULL << 41)) { in parse_ntfs_boot_sector()
888 ntfs_error(vol->sb, "Volume size (%lluTiB) is too " in parse_ntfs_boot_sector()
892 vol->cluster_size_bits)); in parse_ntfs_boot_sector()
897 if (ll >= vol->nr_clusters) { in parse_ntfs_boot_sector()
898 ntfs_error(vol->sb, "MFT LCN (%lli, 0x%llx) is beyond end of " in parse_ntfs_boot_sector()
903 vol->mft_lcn = ll; in parse_ntfs_boot_sector()
904 ntfs_debug("vol->mft_lcn = 0x%llx", (long long)vol->mft_lcn); in parse_ntfs_boot_sector()
906 if (ll >= vol->nr_clusters) { in parse_ntfs_boot_sector()
907 ntfs_error(vol->sb, "MFTMirr LCN (%lli, 0x%llx) is beyond end " in parse_ntfs_boot_sector()
912 vol->mftmirr_lcn = ll; in parse_ntfs_boot_sector()
913 ntfs_debug("vol->mftmirr_lcn = 0x%llx", (long long)vol->mftmirr_lcn); in parse_ntfs_boot_sector()
923 if (vol->cluster_size <= (4 << vol->mft_record_size_bits)) in parse_ntfs_boot_sector()
924 vol->mftmirr_size = 4; in parse_ntfs_boot_sector()
926 vol->mftmirr_size = vol->cluster_size >> in parse_ntfs_boot_sector()
927 vol->mft_record_size_bits; in parse_ntfs_boot_sector()
928 ntfs_debug("vol->mftmirr_size = %i", vol->mftmirr_size); in parse_ntfs_boot_sector()
930 vol->serial_no = le64_to_cpu(b->volume_serial_number); in parse_ntfs_boot_sector()
932 (unsigned long long)vol->serial_no); in parse_ntfs_boot_sector()
942 static void ntfs_setup_allocators(ntfs_volume *vol) in ntfs_setup_allocators() argument
949 vol->mft_zone_multiplier); in ntfs_setup_allocators()
952 mft_zone_size = vol->nr_clusters; in ntfs_setup_allocators()
953 switch (vol->mft_zone_multiplier) { /* % of volume size in clusters */ in ntfs_setup_allocators()
970 vol->mft_zone_start = vol->mft_zone_pos = vol->mft_lcn; in ntfs_setup_allocators()
972 (unsigned long long)vol->mft_zone_pos); in ntfs_setup_allocators()
982 mft_lcn = (8192 + 2 * vol->cluster_size - 1) / vol->cluster_size; in ntfs_setup_allocators()
983 if (mft_lcn * vol->cluster_size < 16 * 1024) in ntfs_setup_allocators()
984 mft_lcn = (16 * 1024 + vol->cluster_size - 1) / in ntfs_setup_allocators()
985 vol->cluster_size; in ntfs_setup_allocators()
986 if (vol->mft_zone_start <= mft_lcn) in ntfs_setup_allocators()
987 vol->mft_zone_start = 0; in ntfs_setup_allocators()
989 (unsigned long long)vol->mft_zone_start); in ntfs_setup_allocators()
995 vol->mft_zone_end = vol->mft_lcn + mft_zone_size; in ntfs_setup_allocators()
996 while (vol->mft_zone_end >= vol->nr_clusters) { in ntfs_setup_allocators()
998 vol->mft_zone_end = vol->mft_lcn + mft_zone_size; in ntfs_setup_allocators()
1001 (unsigned long long)vol->mft_zone_end); in ntfs_setup_allocators()
1006 vol->data1_zone_pos = vol->mft_zone_end; in ntfs_setup_allocators()
1008 (unsigned long long)vol->data1_zone_pos); in ntfs_setup_allocators()
1009 vol->data2_zone_pos = 0; in ntfs_setup_allocators()
1011 (unsigned long long)vol->data2_zone_pos); in ntfs_setup_allocators()
1014 vol->mft_data_pos = 24; in ntfs_setup_allocators()
1016 (unsigned long long)vol->mft_data_pos); in ntfs_setup_allocators()
1028 static bool load_and_init_mft_mirror(ntfs_volume *vol) in load_and_init_mft_mirror() argument
1035 tmp_ino = ntfs_iget(vol->sb, FILE_MFTMirr); in load_and_init_mft_mirror()
1064 tmp_ni->itype.index.block_size = vol->mft_record_size; in load_and_init_mft_mirror()
1065 tmp_ni->itype.index.block_size_bits = vol->mft_record_size_bits; in load_and_init_mft_mirror()
1066 vol->mftmirr_ino = tmp_ino; in load_and_init_mft_mirror()
1081 static bool check_mft_mirror(ntfs_volume *vol) in check_mft_mirror() argument
1083 struct super_block *sb = vol->sb; in check_mft_mirror()
1093 mrecs_per_page = PAGE_SIZE / vol->mft_record_size; in check_mft_mirror()
1095 BUG_ON(!vol->mftmirr_size); in check_mft_mirror()
1109 mft_page = ntfs_map_page(vol->mft_ino->i_mapping, in check_mft_mirror()
1117 mirr_page = ntfs_map_page(vol->mftmirr_ino->i_mapping, in check_mft_mirror()
1152 bytes > vol->mft_record_size || in check_mft_mirror()
1156 bytes > vol->mft_record_size || in check_mft_mirror()
1158 bytes = vol->mft_record_size; in check_mft_mirror()
1166 kmft += vol->mft_record_size; in check_mft_mirror()
1167 kmirr += vol->mft_record_size; in check_mft_mirror()
1168 } while (++i < vol->mftmirr_size); in check_mft_mirror()
1175 rl2[0].lcn = vol->mftmirr_lcn; in check_mft_mirror()
1176 rl2[0].length = (vol->mftmirr_size * vol->mft_record_size + in check_mft_mirror()
1177 vol->cluster_size - 1) / vol->cluster_size; in check_mft_mirror()
1185 mirr_ni = NTFS_I(vol->mftmirr_ino); in check_mft_mirror()
1210 static bool load_and_check_logfile(ntfs_volume *vol, in load_and_check_logfile() argument
1216 tmp_ino = ntfs_iget(vol->sb, FILE_LogFile); in load_and_check_logfile()
1229 vol->logfile_ino = tmp_ino; in load_and_check_logfile()
1260 static int check_windows_hibernation_status(ntfs_volume *vol) in check_windows_hibernation_status() argument
1281 inode_lock(vol->root_ino); in check_windows_hibernation_status()
1282 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->root_ino), hiberfil, 12, in check_windows_hibernation_status()
1284 inode_unlock(vol->root_ino); in check_windows_hibernation_status()
1294 ntfs_error(vol->sb, "Failed to find inode number for " in check_windows_hibernation_status()
1301 vi = ntfs_iget(vol->sb, MREF(mref)); in check_windows_hibernation_status()
1305 ntfs_error(vol->sb, "Failed to load hiberfil.sys."); in check_windows_hibernation_status()
1316 ntfs_error(vol->sb, "Failed to read from hiberfil.sys."); in check_windows_hibernation_status()
1357 static bool load_and_init_quota(ntfs_volume *vol) in load_and_init_quota() argument
1374 inode_lock(vol->extend_ino); in load_and_init_quota()
1375 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->extend_ino), Quota, 6, in load_and_init_quota()
1377 inode_unlock(vol->extend_ino); in load_and_init_quota()
1390 NVolSetQuotaOutOfDate(vol); in load_and_init_quota()
1394 ntfs_error(vol->sb, "Failed to find inode number for $Quota."); in load_and_init_quota()
1400 tmp_ino = ntfs_iget(vol->sb, MREF(mref)); in load_and_init_quota()
1404 ntfs_error(vol->sb, "Failed to load $Quota."); in load_and_init_quota()
1407 vol->quota_ino = tmp_ino; in load_and_init_quota()
1409 tmp_ino = ntfs_index_iget(vol->quota_ino, Q, 2); in load_and_init_quota()
1411 ntfs_error(vol->sb, "Failed to load $Quota/$Q index."); in load_and_init_quota()
1414 vol->quota_q_ino = tmp_ino; in load_and_init_quota()
1433 static bool load_and_init_usnjrnl(ntfs_volume *vol) in load_and_init_usnjrnl() argument
1457 inode_lock(vol->extend_ino); in load_and_init_usnjrnl()
1458 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->extend_ino), UsnJrnl, 8, in load_and_init_usnjrnl()
1460 inode_unlock(vol->extend_ino); in load_and_init_usnjrnl()
1474 NVolSetUsnJrnlStamped(vol); in load_and_init_usnjrnl()
1478 ntfs_error(vol->sb, "Failed to find inode number for " in load_and_init_usnjrnl()
1485 tmp_ino = ntfs_iget(vol->sb, MREF(mref)); in load_and_init_usnjrnl()
1489 ntfs_error(vol->sb, "Failed to load $UsnJrnl."); in load_and_init_usnjrnl()
1492 vol->usnjrnl_ino = tmp_ino; in load_and_init_usnjrnl()
1497 if (unlikely(vol->vol_flags & VOLUME_DELETE_USN_UNDERWAY)) { in load_and_init_usnjrnl()
1504 tmp_ino = ntfs_attr_iget(vol->usnjrnl_ino, AT_DATA, Max, 4); in load_and_init_usnjrnl()
1506 ntfs_error(vol->sb, "Failed to load $UsnJrnl/$DATA/$Max " in load_and_init_usnjrnl()
1510 vol->usnjrnl_max_ino = tmp_ino; in load_and_init_usnjrnl()
1512 ntfs_error(vol->sb, "Found corrupt $UsnJrnl/$DATA/$Max " in load_and_init_usnjrnl()
1519 tmp_ino = ntfs_attr_iget(vol->usnjrnl_ino, AT_DATA, J, 2); in load_and_init_usnjrnl()
1521 ntfs_error(vol->sb, "Failed to load $UsnJrnl/$DATA/$J " in load_and_init_usnjrnl()
1525 vol->usnjrnl_j_ino = tmp_ino; in load_and_init_usnjrnl()
1527 tmp_ni = NTFS_I(vol->usnjrnl_j_ino); in load_and_init_usnjrnl()
1529 ntfs_error(vol->sb, "$UsnJrnl/$DATA/$J attribute is resident " in load_and_init_usnjrnl()
1534 page = ntfs_map_page(vol->usnjrnl_max_ino->i_mapping, 0); in load_and_init_usnjrnl()
1536 ntfs_error(vol->sb, "Failed to read from $UsnJrnl/$DATA/$Max " in load_and_init_usnjrnl()
1544 ntfs_error(vol->sb, "Allocation delta (0x%llx) exceeds " in load_and_init_usnjrnl()
1556 i_size_read(vol->usnjrnl_j_ino))) { in load_and_init_usnjrnl()
1558 i_size_read(vol->usnjrnl_j_ino))) { in load_and_init_usnjrnl()
1567 ntfs_error(vol->sb, "$UsnJrnl has lowest valid usn (0x%llx) " in load_and_init_usnjrnl()
1571 i_size_read(vol->usnjrnl_j_ino)); in load_and_init_usnjrnl()
1586 static bool load_and_init_attrdef(ntfs_volume *vol) in load_and_init_attrdef() argument
1589 struct super_block *sb = vol->sb; in load_and_init_attrdef()
1608 vol->attrdef = (ATTR_DEF*)ntfs_malloc_nofs(i_size); in load_and_init_attrdef()
1609 if (!vol->attrdef) in load_and_init_attrdef()
1620 memcpy((u8*)vol->attrdef + (index++ << PAGE_SHIFT), in load_and_init_attrdef()
1629 vol->attrdef_size = i_size; in load_and_init_attrdef()
1634 ntfs_free(vol->attrdef); in load_and_init_attrdef()
1635 vol->attrdef = NULL; in load_and_init_attrdef()
1651 static bool load_and_init_upcase(ntfs_volume *vol) in load_and_init_upcase() argument
1654 struct super_block *sb = vol->sb; in load_and_init_upcase()
1677 vol->upcase = (ntfschar*)ntfs_malloc_nofs(i_size); in load_and_init_upcase()
1678 if (!vol->upcase) in load_and_init_upcase()
1689 memcpy((char*)vol->upcase + (index++ << PAGE_SHIFT), in load_and_init_upcase()
1698 vol->upcase_len = i_size >> UCHAR_T_SIZE_BITS; in load_and_init_upcase()
1710 if (max > vol->upcase_len) in load_and_init_upcase()
1711 max = vol->upcase_len; in load_and_init_upcase()
1713 if (vol->upcase[i] != default_upcase[i]) in load_and_init_upcase()
1716 ntfs_free(vol->upcase); in load_and_init_upcase()
1717 vol->upcase = default_upcase; in load_and_init_upcase()
1718 vol->upcase_len = max; in load_and_init_upcase()
1731 ntfs_free(vol->upcase); in load_and_init_upcase()
1732 vol->upcase = NULL; in load_and_init_upcase()
1736 vol->upcase = default_upcase; in load_and_init_upcase()
1737 vol->upcase_len = default_upcase_len; in load_and_init_upcase()
1766 static bool load_system_files(ntfs_volume *vol) in load_system_files() argument
1768 struct super_block *sb = vol->sb; in load_system_files()
1780 if (!load_and_init_mft_mirror(vol) || !check_mft_mirror(vol)) { in load_system_files()
1787 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
1792 !vol->mftmirr_ino ? es1 : es2, in load_system_files()
1798 !vol->mftmirr_ino ? es1 : es2, es3); in load_system_files()
1802 !vol->mftmirr_ino ? es1 : es2, es3); in load_system_files()
1804 NVolSetErrors(vol); in load_system_files()
1808 vol->mftbmp_ino = ntfs_attr_iget(vol->mft_ino, AT_BITMAP, NULL, 0); in load_system_files()
1809 if (IS_ERR(vol->mftbmp_ino)) { in load_system_files()
1813 lockdep_set_class(&NTFS_I(vol->mftbmp_ino)->runlist.lock, in load_system_files()
1815 lockdep_set_class(&NTFS_I(vol->mftbmp_ino)->mrec_lock, in load_system_files()
1818 if (!load_and_init_upcase(vol)) in load_system_files()
1825 if (!load_and_init_attrdef(vol)) in load_system_files()
1833 vol->lcnbmp_ino = ntfs_iget(sb, FILE_Bitmap); in load_system_files()
1834 if (IS_ERR(vol->lcnbmp_ino) || is_bad_inode(vol->lcnbmp_ino)) { in load_system_files()
1835 if (!IS_ERR(vol->lcnbmp_ino)) in load_system_files()
1836 iput(vol->lcnbmp_ino); in load_system_files()
1839 lockdep_set_class(&NTFS_I(vol->lcnbmp_ino)->runlist.lock, in load_system_files()
1841 lockdep_set_class(&NTFS_I(vol->lcnbmp_ino)->mrec_lock, in load_system_files()
1844 NInoSetSparseDisabled(NTFS_I(vol->lcnbmp_ino)); in load_system_files()
1845 if ((vol->nr_clusters + 7) >> 3 > i_size_read(vol->lcnbmp_ino)) { in load_system_files()
1846 iput(vol->lcnbmp_ino); in load_system_files()
1855 vol->vol_ino = ntfs_iget(sb, FILE_Volume); in load_system_files()
1856 if (IS_ERR(vol->vol_ino) || is_bad_inode(vol->vol_ino)) { in load_system_files()
1857 if (!IS_ERR(vol->vol_ino)) in load_system_files()
1858 iput(vol->vol_ino); in load_system_files()
1863 m = map_mft_record(NTFS_I(vol->vol_ino)); in load_system_files()
1866 iput(vol->vol_ino); in load_system_files()
1869 if (!(ctx = ntfs_attr_get_search_ctx(NTFS_I(vol->vol_ino), m))) { in load_system_files()
1878 unmap_mft_record(NTFS_I(vol->vol_ino)); in load_system_files()
1889 vol->vol_flags = vi->flags; in load_system_files()
1890 vol->major_ver = vi->major_ver; in load_system_files()
1891 vol->minor_ver = vi->minor_ver; in load_system_files()
1893 unmap_mft_record(NTFS_I(vol->vol_ino)); in load_system_files()
1894 pr_info("volume version %i.%i.\n", vol->major_ver, in load_system_files()
1895 vol->minor_ver); in load_system_files()
1896 if (vol->major_ver < 3 && NVolSparseEnabled(vol)) { in load_system_files()
1897 ntfs_warning(vol->sb, "Disabling sparse support due to NTFS " in load_system_files()
1899 "3.0).", vol->major_ver, vol->minor_ver); in load_system_files()
1900 NVolClearSparseEnabled(vol); in load_system_files()
1904 if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) { in load_system_files()
1913 if (vol->vol_flags & VOLUME_IS_DIRTY) in load_system_files()
1915 else if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) { in load_system_files()
1922 (unsigned)le16_to_cpu(vol->vol_flags)); in load_system_files()
1926 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
1949 if (!load_and_check_logfile(vol, &rp) || in load_system_files()
1950 !ntfs_is_logfile_clean(vol->logfile_ino, rp)) { in load_system_files()
1956 es1 = !vol->logfile_ino ? es1a : es1b; in load_system_files()
1959 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
1965 if (vol->logfile_ino) { in load_system_files()
1977 NVolSetErrors(vol); in load_system_files()
1982 vol->root_ino = ntfs_iget(sb, FILE_root); in load_system_files()
1983 if (IS_ERR(vol->root_ino) || is_bad_inode(vol->root_ino)) { in load_system_files()
1984 if (!IS_ERR(vol->root_ino)) in load_system_files()
1985 iput(vol->root_ino); in load_system_files()
1997 err = check_windows_hibernation_status(vol); in load_system_files()
2008 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2022 NVolSetErrors(vol); in load_system_files()
2025 if (!sb_rdonly(sb) && ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) { in load_system_files()
2031 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2052 if (!(sb->s_flags & SB_RDONLY) && (vol->major_ver > 1) && in load_system_files()
2053 ntfs_set_volume_flags(vol, VOLUME_MOUNTED_ON_NT4)) { in load_system_files()
2058 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2067 NVolSetErrors(vol); in load_system_files()
2071 if (!sb_rdonly(sb) && !ntfs_empty_logfile(vol->logfile_ino)) { in load_system_files()
2076 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2085 NVolSetErrors(vol); in load_system_files()
2089 if (unlikely(vol->major_ver < 3)) in load_system_files()
2093 vol->secure_ino = ntfs_iget(sb, FILE_Secure); in load_system_files()
2094 if (IS_ERR(vol->secure_ino) || is_bad_inode(vol->secure_ino)) { in load_system_files()
2095 if (!IS_ERR(vol->secure_ino)) in load_system_files()
2096 iput(vol->secure_ino); in load_system_files()
2102 vol->extend_ino = ntfs_iget(sb, FILE_Extend); in load_system_files()
2103 if (IS_ERR(vol->extend_ino) || is_bad_inode(vol->extend_ino) || in load_system_files()
2104 !S_ISDIR(vol->extend_ino->i_mode)) { in load_system_files()
2105 if (!IS_ERR(vol->extend_ino)) in load_system_files()
2106 iput(vol->extend_ino); in load_system_files()
2112 if (!load_and_init_quota(vol)) { in load_system_files()
2118 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2132 NVolSetErrors(vol); in load_system_files()
2135 if (!sb_rdonly(sb) && !ntfs_mark_quotas_out_of_date(vol)) { in load_system_files()
2140 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2149 NVolSetErrors(vol); in load_system_files()
2155 if (!load_and_init_usnjrnl(vol)) { in load_system_files()
2161 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2175 NVolSetErrors(vol); in load_system_files()
2178 if (!sb_rdonly(sb) && !ntfs_stamp_usnjrnl(vol)) { in load_system_files()
2184 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2193 NVolSetErrors(vol); in load_system_files()
2199 iput(vol->usnjrnl_j_ino); in load_system_files()
2200 iput(vol->usnjrnl_max_ino); in load_system_files()
2201 iput(vol->usnjrnl_ino); in load_system_files()
2203 iput(vol->quota_q_ino); in load_system_files()
2204 iput(vol->quota_ino); in load_system_files()
2205 iput(vol->extend_ino); in load_system_files()
2208 iput(vol->secure_ino); in load_system_files()
2210 iput(vol->root_ino); in load_system_files()
2213 iput(vol->logfile_ino); in load_system_files()
2216 iput(vol->vol_ino); in load_system_files()
2218 iput(vol->lcnbmp_ino); in load_system_files()
2220 vol->attrdef_size = 0; in load_system_files()
2221 if (vol->attrdef) { in load_system_files()
2222 ntfs_free(vol->attrdef); in load_system_files()
2223 vol->attrdef = NULL; in load_system_files()
2228 vol->upcase_len = 0; in load_system_files()
2230 if (vol->upcase == default_upcase) { in load_system_files()
2232 vol->upcase = NULL; in load_system_files()
2235 if (vol->upcase) { in load_system_files()
2236 ntfs_free(vol->upcase); in load_system_files()
2237 vol->upcase = NULL; in load_system_files()
2240 iput(vol->mftbmp_ino); in load_system_files()
2243 iput(vol->mftmirr_ino); in load_system_files()
2259 ntfs_volume *vol = NTFS_SB(sb); in ntfs_put_super() local
2268 ntfs_commit_inode(vol->vol_ino); in ntfs_put_super()
2271 if (vol->major_ver >= 3) { in ntfs_put_super()
2272 if (vol->usnjrnl_j_ino) in ntfs_put_super()
2273 ntfs_commit_inode(vol->usnjrnl_j_ino); in ntfs_put_super()
2274 if (vol->usnjrnl_max_ino) in ntfs_put_super()
2275 ntfs_commit_inode(vol->usnjrnl_max_ino); in ntfs_put_super()
2276 if (vol->usnjrnl_ino) in ntfs_put_super()
2277 ntfs_commit_inode(vol->usnjrnl_ino); in ntfs_put_super()
2278 if (vol->quota_q_ino) in ntfs_put_super()
2279 ntfs_commit_inode(vol->quota_q_ino); in ntfs_put_super()
2280 if (vol->quota_ino) in ntfs_put_super()
2281 ntfs_commit_inode(vol->quota_ino); in ntfs_put_super()
2282 if (vol->extend_ino) in ntfs_put_super()
2283 ntfs_commit_inode(vol->extend_ino); in ntfs_put_super()
2284 if (vol->secure_ino) in ntfs_put_super()
2285 ntfs_commit_inode(vol->secure_ino); in ntfs_put_super()
2288 ntfs_commit_inode(vol->root_ino); in ntfs_put_super()
2290 down_write(&vol->lcnbmp_lock); in ntfs_put_super()
2291 ntfs_commit_inode(vol->lcnbmp_ino); in ntfs_put_super()
2292 up_write(&vol->lcnbmp_lock); in ntfs_put_super()
2294 down_write(&vol->mftbmp_lock); in ntfs_put_super()
2295 ntfs_commit_inode(vol->mftbmp_ino); in ntfs_put_super()
2296 up_write(&vol->mftbmp_lock); in ntfs_put_super()
2298 if (vol->logfile_ino) in ntfs_put_super()
2299 ntfs_commit_inode(vol->logfile_ino); in ntfs_put_super()
2301 if (vol->mftmirr_ino) in ntfs_put_super()
2302 ntfs_commit_inode(vol->mftmirr_ino); in ntfs_put_super()
2303 ntfs_commit_inode(vol->mft_ino); in ntfs_put_super()
2310 if (!NVolErrors(vol)) { in ntfs_put_super()
2311 if (ntfs_clear_volume_flags(vol, VOLUME_IS_DIRTY)) in ntfs_put_super()
2315 ntfs_commit_inode(vol->vol_ino); in ntfs_put_super()
2316 ntfs_commit_inode(vol->root_ino); in ntfs_put_super()
2317 if (vol->mftmirr_ino) in ntfs_put_super()
2318 ntfs_commit_inode(vol->mftmirr_ino); in ntfs_put_super()
2319 ntfs_commit_inode(vol->mft_ino); in ntfs_put_super()
2327 iput(vol->vol_ino); in ntfs_put_super()
2328 vol->vol_ino = NULL; in ntfs_put_super()
2331 if (vol->major_ver >= 3) { in ntfs_put_super()
2333 if (vol->usnjrnl_j_ino) { in ntfs_put_super()
2334 iput(vol->usnjrnl_j_ino); in ntfs_put_super()
2335 vol->usnjrnl_j_ino = NULL; in ntfs_put_super()
2337 if (vol->usnjrnl_max_ino) { in ntfs_put_super()
2338 iput(vol->usnjrnl_max_ino); in ntfs_put_super()
2339 vol->usnjrnl_max_ino = NULL; in ntfs_put_super()
2341 if (vol->usnjrnl_ino) { in ntfs_put_super()
2342 iput(vol->usnjrnl_ino); in ntfs_put_super()
2343 vol->usnjrnl_ino = NULL; in ntfs_put_super()
2345 if (vol->quota_q_ino) { in ntfs_put_super()
2346 iput(vol->quota_q_ino); in ntfs_put_super()
2347 vol->quota_q_ino = NULL; in ntfs_put_super()
2349 if (vol->quota_ino) { in ntfs_put_super()
2350 iput(vol->quota_ino); in ntfs_put_super()
2351 vol->quota_ino = NULL; in ntfs_put_super()
2354 if (vol->extend_ino) { in ntfs_put_super()
2355 iput(vol->extend_ino); in ntfs_put_super()
2356 vol->extend_ino = NULL; in ntfs_put_super()
2358 if (vol->secure_ino) { in ntfs_put_super()
2359 iput(vol->secure_ino); in ntfs_put_super()
2360 vol->secure_ino = NULL; in ntfs_put_super()
2364 iput(vol->root_ino); in ntfs_put_super()
2365 vol->root_ino = NULL; in ntfs_put_super()
2367 down_write(&vol->lcnbmp_lock); in ntfs_put_super()
2368 iput(vol->lcnbmp_ino); in ntfs_put_super()
2369 vol->lcnbmp_ino = NULL; in ntfs_put_super()
2370 up_write(&vol->lcnbmp_lock); in ntfs_put_super()
2372 down_write(&vol->mftbmp_lock); in ntfs_put_super()
2373 iput(vol->mftbmp_ino); in ntfs_put_super()
2374 vol->mftbmp_ino = NULL; in ntfs_put_super()
2375 up_write(&vol->mftbmp_lock); in ntfs_put_super()
2378 if (vol->logfile_ino) { in ntfs_put_super()
2379 iput(vol->logfile_ino); in ntfs_put_super()
2380 vol->logfile_ino = NULL; in ntfs_put_super()
2382 if (vol->mftmirr_ino) { in ntfs_put_super()
2384 ntfs_commit_inode(vol->mftmirr_ino); in ntfs_put_super()
2385 ntfs_commit_inode(vol->mft_ino); in ntfs_put_super()
2386 iput(vol->mftmirr_ino); in ntfs_put_super()
2387 vol->mftmirr_ino = NULL; in ntfs_put_super()
2394 ntfs_commit_inode(vol->mft_ino); in ntfs_put_super()
2395 write_inode_now(vol->mft_ino, 1); in ntfs_put_super()
2398 iput(vol->mft_ino); in ntfs_put_super()
2399 vol->mft_ino = NULL; in ntfs_put_super()
2402 vol->attrdef_size = 0; in ntfs_put_super()
2403 if (vol->attrdef) { in ntfs_put_super()
2404 ntfs_free(vol->attrdef); in ntfs_put_super()
2405 vol->attrdef = NULL; in ntfs_put_super()
2407 vol->upcase_len = 0; in ntfs_put_super()
2413 if (vol->upcase == default_upcase) { in ntfs_put_super()
2415 vol->upcase = NULL; in ntfs_put_super()
2421 if (vol->cluster_size <= 4096 && !--ntfs_nr_compression_users) in ntfs_put_super()
2424 if (vol->upcase) { in ntfs_put_super()
2425 ntfs_free(vol->upcase); in ntfs_put_super()
2426 vol->upcase = NULL; in ntfs_put_super()
2429 unload_nls(vol->nls_map); in ntfs_put_super()
2432 kfree(vol); in ntfs_put_super()
2454 static s64 get_nr_free_clusters(ntfs_volume *vol) in get_nr_free_clusters() argument
2456 s64 nr_free = vol->nr_clusters; in get_nr_free_clusters()
2457 struct address_space *mapping = vol->lcnbmp_ino->i_mapping; in get_nr_free_clusters()
2463 down_read(&vol->lcnbmp_lock); in get_nr_free_clusters()
2469 max_index = (((vol->nr_clusters + 7) >> 3) + PAGE_SIZE - 1) >> in get_nr_free_clusters()
2507 if (vol->nr_clusters & 63) in get_nr_free_clusters()
2508 nr_free += 64 - (vol->nr_clusters & 63); in get_nr_free_clusters()
2509 up_read(&vol->lcnbmp_lock); in get_nr_free_clusters()
2534 static unsigned long __get_nr_free_mft_records(ntfs_volume *vol, in __get_nr_free_mft_records() argument
2537 struct address_space *mapping = vol->mftbmp_ino->i_mapping; in __get_nr_free_mft_records()
2604 ntfs_volume *vol = NTFS_SB(sb); in ntfs_statfs() local
2605 ntfs_inode *mft_ni = NTFS_I(vol->mft_ino); in ntfs_statfs()
2619 sfs->f_blocks = vol->nr_clusters << vol->cluster_size_bits >> in ntfs_statfs()
2622 size = get_nr_free_clusters(vol) << vol->cluster_size_bits >> in ntfs_statfs()
2629 down_read(&vol->mftbmp_lock); in ntfs_statfs()
2631 size = i_size_read(vol->mft_ino) >> vol->mft_record_size_bits; in ntfs_statfs()
2637 max_index = ((((mft_ni->initialized_size >> vol->mft_record_size_bits) in ntfs_statfs()
2643 sfs->f_ffree = __get_nr_free_mft_records(vol, size, max_index); in ntfs_statfs()
2644 up_read(&vol->mftbmp_lock); in ntfs_statfs()
2655 sfs->f_fsid = u64_to_fsid(vol->serial_no); in ntfs_statfs()
2707 ntfs_volume *vol; in ntfs_fill_super() local
2729 vol = NTFS_SB(sb); in ntfs_fill_super()
2730 if (!vol) { in ntfs_fill_super()
2738 *vol = (ntfs_volume) { in ntfs_fill_super()
2749 init_rwsem(&vol->mftbmp_lock); in ntfs_fill_super()
2750 init_rwsem(&vol->lcnbmp_lock); in ntfs_fill_super()
2753 NVolSetSparseEnabled(vol); in ntfs_fill_super()
2756 if (!parse_options(vol, (char*)opt)) in ntfs_fill_super()
2784 vol->nr_blocks = sb_bdev_nr_blocks(sb); in ntfs_fill_super()
2785 if (!vol->nr_blocks) { in ntfs_fill_super()
2800 result = parse_ntfs_boot_sector(vol, (NTFS_BOOT_SECTOR*)bh->b_data); in ntfs_fill_super()
2817 if (vol->sector_size > blocksize) { in ntfs_fill_super()
2818 blocksize = sb_set_blocksize(sb, vol->sector_size); in ntfs_fill_super()
2819 if (blocksize != vol->sector_size) { in ntfs_fill_super()
2823 vol->sector_size); in ntfs_fill_super()
2827 vol->nr_blocks = sb_bdev_nr_blocks(sb); in ntfs_fill_super()
2833 ntfs_setup_allocators(vol); in ntfs_fill_super()
2873 if (vol->cluster_size <= 4096 && !ntfs_nr_compression_users++) { in ntfs_fill_super()
2900 if (!load_system_files(vol)) { in ntfs_fill_super()
2906 ihold(vol->root_ino); in ntfs_fill_super()
2907 if ((sb->s_root = d_make_root(vol->root_ino))) { in ntfs_fill_super()
2925 iput(vol->vol_ino); in ntfs_fill_super()
2926 vol->vol_ino = NULL; in ntfs_fill_super()
2928 if (vol->major_ver >= 3) { in ntfs_fill_super()
2930 if (vol->usnjrnl_j_ino) { in ntfs_fill_super()
2931 iput(vol->usnjrnl_j_ino); in ntfs_fill_super()
2932 vol->usnjrnl_j_ino = NULL; in ntfs_fill_super()
2934 if (vol->usnjrnl_max_ino) { in ntfs_fill_super()
2935 iput(vol->usnjrnl_max_ino); in ntfs_fill_super()
2936 vol->usnjrnl_max_ino = NULL; in ntfs_fill_super()
2938 if (vol->usnjrnl_ino) { in ntfs_fill_super()
2939 iput(vol->usnjrnl_ino); in ntfs_fill_super()
2940 vol->usnjrnl_ino = NULL; in ntfs_fill_super()
2942 if (vol->quota_q_ino) { in ntfs_fill_super()
2943 iput(vol->quota_q_ino); in ntfs_fill_super()
2944 vol->quota_q_ino = NULL; in ntfs_fill_super()
2946 if (vol->quota_ino) { in ntfs_fill_super()
2947 iput(vol->quota_ino); in ntfs_fill_super()
2948 vol->quota_ino = NULL; in ntfs_fill_super()
2951 if (vol->extend_ino) { in ntfs_fill_super()
2952 iput(vol->extend_ino); in ntfs_fill_super()
2953 vol->extend_ino = NULL; in ntfs_fill_super()
2955 if (vol->secure_ino) { in ntfs_fill_super()
2956 iput(vol->secure_ino); in ntfs_fill_super()
2957 vol->secure_ino = NULL; in ntfs_fill_super()
2960 iput(vol->root_ino); in ntfs_fill_super()
2961 vol->root_ino = NULL; in ntfs_fill_super()
2962 iput(vol->lcnbmp_ino); in ntfs_fill_super()
2963 vol->lcnbmp_ino = NULL; in ntfs_fill_super()
2964 iput(vol->mftbmp_ino); in ntfs_fill_super()
2965 vol->mftbmp_ino = NULL; in ntfs_fill_super()
2967 if (vol->logfile_ino) { in ntfs_fill_super()
2968 iput(vol->logfile_ino); in ntfs_fill_super()
2969 vol->logfile_ino = NULL; in ntfs_fill_super()
2971 if (vol->mftmirr_ino) { in ntfs_fill_super()
2972 iput(vol->mftmirr_ino); in ntfs_fill_super()
2973 vol->mftmirr_ino = NULL; in ntfs_fill_super()
2977 vol->attrdef_size = 0; in ntfs_fill_super()
2978 if (vol->attrdef) { in ntfs_fill_super()
2979 ntfs_free(vol->attrdef); in ntfs_fill_super()
2980 vol->attrdef = NULL; in ntfs_fill_super()
2982 vol->upcase_len = 0; in ntfs_fill_super()
2984 if (vol->upcase == default_upcase) { in ntfs_fill_super()
2986 vol->upcase = NULL; in ntfs_fill_super()
2989 if (vol->upcase) { in ntfs_fill_super()
2990 ntfs_free(vol->upcase); in ntfs_fill_super()
2991 vol->upcase = NULL; in ntfs_fill_super()
2993 if (vol->nls_map) { in ntfs_fill_super()
2994 unload_nls(vol->nls_map); in ntfs_fill_super()
2995 vol->nls_map = NULL; in ntfs_fill_super()
3008 if (vol->cluster_size <= 4096 && !--ntfs_nr_compression_users) in ntfs_fill_super()
3013 if (vol->mft_ino && vol->mft_ino != tmp_ino) in ntfs_fill_super()
3014 iput(vol->mft_ino); in ntfs_fill_super()
3015 vol->mft_ino = NULL; in ntfs_fill_super()
3019 kfree(vol); in ntfs_fill_super()