Lines Matching refs:vol
246 * @vol: ntfs volume whose $MFT to load
248 * Load $MFT from @vol and setup @vol with it. After calling this function the
249 * volume @vol is ready for use by all read access functions provided by the
254 static int ntfs_mft_load(ntfs_volume *vol)
264 vol->mft_ni = ntfs_inode_allocate(vol);
265 mb = ntfs_malloc(vol->mft_record_size);
266 if (!vol->mft_ni || !mb) {
270 vol->mft_ni->mft_no = 0;
271 vol->mft_ni->mrec = mb;
273 l = ntfs_mst_pread(vol->dev, vol->mft_lcn << vol->cluster_size_bits, 1,
274 vol->mft_record_size, mb);
282 if (ntfs_mft_record_check(vol, 0, mb))
285 ctx = ntfs_attr_get_search_ctx(vol->mft_ni, NULL);
298 NInoSetAttrList(vol->mft_ni);
305 vol->mft_ni->attr_list_size = l;
306 vol->mft_ni->attr_list = ntfs_malloc(l);
307 if (!vol->mft_ni->attr_list)
310 l = ntfs_get_attribute_value(vol, ctx->attr, vol->mft_ni->attr_list);
315 if ((l != vol->mft_ni->attr_list_size)
319 vol->mft_ni->attr_list_size,
326 if (ntfs_attr_setup_flag(vol->mft_ni))
329 /* We now have a fully setup ntfs inode for $MFT in vol->mft_ni. */
332 vol->mft_na = ntfs_attr_open(vol->mft_ni, AT_DATA, AT_UNNAMED, 0);
333 if (!vol->mft_na) {
339 last_vcn = vol->mft_na->allocated_size >> vol->cluster_size_bits;
365 nrl = ntfs_mapping_pairs_decompress(vol, a, vol->mft_na->rl);
371 if (nrl->lcn != vol->mft_lcn) {
375 vol->mft_na->rl = nrl;
406 vol->mft_ni->data_size = vol->mft_na->data_size;
407 vol->mft_ni->allocated_size = vol->mft_na->allocated_size;
408 set_nino_flag(vol->mft_ni, KnownSize);
413 vol->mftbmp_na = ntfs_attr_open(vol->mft_ni, AT_BITMAP, AT_UNNAMED, 0);
414 if (!vol->mftbmp_na) {
425 if (vol->mft_na) {
426 ntfs_attr_close(vol->mft_na);
427 vol->mft_na = NULL;
429 if (vol->mft_ni) {
430 ntfs_inode_close(vol->mft_ni);
431 vol->mft_ni = NULL;
439 * @vol: ntfs volume whose $MFTMirr to load
441 * Load $MFTMirr from @vol and setup @vol with it. After calling this function
442 * the volume @vol is ready for use by all write access functions provided by
448 static int ntfs_mftmirr_load(ntfs_volume *vol)
452 vol->mftmirr_ni = ntfs_inode_open(vol, FILE_MFTMirr);
453 if (!vol->mftmirr_ni) {
458 vol->mftmirr_na = ntfs_attr_open(vol->mftmirr_ni, AT_DATA, AT_UNNAMED, 0);
459 if (!vol->mftmirr_na) {
464 if (ntfs_attr_map_runlist(vol->mftmirr_na, 0) < 0) {
468 if (vol->mftmirr_na->rl->lcn != vol->mftmirr_lcn) {
470 (long long)vol->mftmirr_na->rl->lcn,
471 (long long)vol->mftmirr_lcn);
479 if (vol->mftmirr_na) {
480 ntfs_attr_close(vol->mftmirr_na);
481 vol->mftmirr_na = NULL;
483 ntfs_inode_close(vol->mftmirr_ni);
484 vol->mftmirr_ni = NULL;
506 ntfs_volume *vol;
521 vol = ntfs_volume_alloc();
522 if (!vol)
526 vol->upcase_len = ntfs_upcase_build_default(&vol->upcase);
527 if (!vol->upcase_len || !vol->upcase)
531 vol->locase = (ntfschar*)NULL;
532 NVolSetCaseSensitive(vol);
535 NVolSetShowSysFiles(vol);
536 NVolSetShowHidFiles(vol);
537 NVolClearHideDotFiles(vol);
540 NVolSetCompression(vol);
542 NVolClearCompression(vol);
545 NVolSetReadOnly(vol);
548 if ((dev->d_ops->open)(dev, NVolReadOnly(vol) ? O_RDONLY: O_RDWR)) {
549 if (!NVolReadOnly(vol) && (errno == EROFS)) {
557 NVolSetReadOnly(vol);
565 vol->dev = dev;
582 if (ntfs_boot_sector_parse(vol, bs) < 0)
588 if (ntfs_device_block_size_set(vol->dev, vol->sector_size))
595 vol->full_zones = 0;
596 mft_zone_size = vol->nr_clusters >> 3; /* 12.5% */
599 vol->mft_zone_start = vol->mft_zone_pos = vol->mft_lcn;
600 ntfs_log_debug("mft_zone_pos = 0x%llx\n", (long long)vol->mft_zone_pos);
611 mft_lcn = (8192 + 2 * vol->cluster_size - 1) / vol->cluster_size;
612 if (mft_lcn * vol->cluster_size < 16 * 1024)
613 mft_lcn = (16 * 1024 + vol->cluster_size - 1) /
614 vol->cluster_size;
615 if (vol->mft_zone_start <= mft_lcn)
616 vol->mft_zone_start = 0;
617 ntfs_log_debug("mft_zone_start = 0x%llx\n", (long long)vol->mft_zone_start);
624 vol->mft_zone_end = vol->mft_lcn + mft_zone_size;
625 while (vol->mft_zone_end >= vol->nr_clusters) {
631 vol->mft_zone_end = vol->mft_lcn + mft_zone_size;
633 ntfs_log_debug("mft_zone_end = 0x%llx\n", (long long)vol->mft_zone_end);
639 vol->data1_zone_pos = vol->mft_zone_end;
640 ntfs_log_debug("data1_zone_pos = %lld\n", (long long)vol->data1_zone_pos);
641 vol->data2_zone_pos = 0;
642 ntfs_log_debug("data2_zone_pos = %lld\n", (long long)vol->data2_zone_pos);
645 vol->mft_data_pos = 24;
652 if (ntfs_mft_load(vol) < 0) {
658 if (ntfs_mftmirr_load(vol) < 0) {
662 return vol;
666 if (vol)
667 __ntfs_volume_release(vol);
674 * @vol: volume on which to check logfile
678 static int ntfs_volume_check_logfile(ntfs_volume *vol)
685 ni = ntfs_inode_open(vol, FILE_LogFile);
733 * @vol: An ntfs volume obtained from ntfs_mount
738 static ntfs_inode *ntfs_hiberfile_open(ntfs_volume *vol)
747 if (!vol) {
752 ni_root = ntfs_inode_open(vol, FILE_root);
771 ni_hibr = ntfs_inode_open(vol, inode);
791 * @vol: volume on which to check hiberfil.sys
796 int ntfs_volume_check_hiberfile(ntfs_volume *vol, int verbose)
803 ni = ntfs_hiberfile_open(vol);
866 static int fix_txf_data(ntfs_volume *vol)
876 ni = ntfs_inode_open(vol, FILE_root);
941 ntfs_volume *vol;
956 vol = ntfs_volume_startup(dev, flags);
957 if (!vol)
961 m = ntfs_malloc(vol->mftmirr_size << vol->mft_record_size_bits);
962 m2 = ntfs_malloc(vol->mftmirr_size << vol->mft_record_size_bits);
966 l = ntfs_attr_mst_pread(vol->mft_na, 0, vol->mftmirr_size,
967 vol->mft_record_size, m);
968 if (l != vol->mftmirr_size) {
974 vol->mftmirr_size);
980 if (ntfs_mft_record_check(vol, FILE_MFT + i,
981 (MFT_RECORD*)(m + i*vol->mft_record_size)))
983 l = ntfs_attr_mst_pread(vol->mftmirr_na, 0, vol->mftmirr_size,
984 vol->mft_record_size, m2);
985 if (l != vol->mftmirr_size) {
990 vol->mftmirr_size = l;
993 if (ntfs_mft_record_check(vol, FILE_MFT + i,
994 (MFT_RECORD*)(m2 + i*vol->mft_record_size)))
998 for (i = 0; (i < vol->mftmirr_size) && (i < FILE_first_user); ++i) {
1012 mrec = (MFT_RECORD*)(m + i * vol->mft_record_size);
1026 mrec2 = (MFT_RECORD*)(m2 + i * vol->mft_record_size);
1042 || (record_size > vol->mft_record_size)
1056 vol->lcnbmp_ni = ntfs_inode_open(vol, FILE_Bitmap);
1057 if (!vol->lcnbmp_ni) {
1062 vol->lcnbmp_na = ntfs_attr_open(vol->lcnbmp_ni, AT_DATA, AT_UNNAMED, 0);
1063 if (!vol->lcnbmp_na) {
1068 if (vol->lcnbmp_na->data_size > vol->lcnbmp_na->allocated_size) {
1070 (long long)vol->lcnbmp_na->data_size,
1071 (long long)vol->lcnbmp_na->allocated_size);
1077 ni = ntfs_inode_open(vol, FILE_UpCase);
1100 if (vol->upcase_len != na->data_size >> 1) {
1101 vol->upcase_len = na->data_size >> 1;
1103 free(vol->upcase);
1104 vol->upcase = ntfs_malloc(na->data_size);
1105 if (!vol->upcase)
1109 l = ntfs_attr_pread(na, 0, na->data_size, vol->upcase);
1125 while ((k < vol->upcase_len)
1127 && (le16_to_cpu(vol->upcase[k])
1137 * vol structure accordingly.
1140 vol->vol_ni = ntfs_inode_open(vol, FILE_Volume);
1141 if (!vol->vol_ni) {
1146 ctx = ntfs_attr_get_search_ctx(vol->vol_ni, NULL);
1176 /* Setup vol from the volume information attribute value. */
1177 vol->major_ver = vinf->major_ver;
1178 vol->minor_ver = vinf->minor_ver;
1181 vol->flags = vinf->flags;
1198 vol->vol_name = ntfs_malloc(1);
1199 if (!vol->vol_name)
1201 vol->vol_name[0] = '\0';
1217 vol->vol_name = NULL;
1218 if (ntfs_ucstombs(vname, u, &vol->vol_name, 0) == -1) {
1223 vol->vol_name = ntfs_malloc(u + 1);
1224 if (!vol->vol_name)
1231 vol->vol_name[j] = (char)uc;
1233 vol->vol_name[u] = '\0';
1240 ni = ntfs_inode_open(vol, FILE_AttrDef);
1258 vol->attrdef_len = na->data_size;
1259 vol->attrdef = ntfs_malloc(na->data_size);
1260 if (!vol->attrdef)
1263 l = ntfs_attr_pread(na, 0, na->data_size, vol->attrdef);
1279 if (ntfs_open_secure(vol))
1288 ntfs_volume_check_hiberfile(vol, 1) < 0) {
1294 if (ntfs_volume_check_logfile(vol) < 0) {
1304 if (ntfs_logfile_reset(vol))
1310 if (fix_txf_data(vol))
1315 NVolSetReadOnly(vol);
1319 return vol;
1332 __ntfs_volume_release(vol);
1343 int ntfs_set_shown_files(ntfs_volume *vol,
1350 if (vol) {
1351 NVolClearShowSysFiles(vol);
1352 NVolClearShowHidFiles(vol);
1353 NVolClearHideDotFiles(vol);
1355 NVolSetShowSysFiles(vol);
1357 NVolSetShowHidFiles(vol);
1359 NVolSetHideDotFiles(vol);
1371 int ntfs_set_ignore_case(ntfs_volume *vol)
1376 if (vol && vol->upcase) {
1377 vol->locase = ntfs_locase_table_build(vol->upcase,
1378 vol->upcase_len);
1379 if (vol->locase) {
1380 NVolClearCaseSensitive(vol);
1419 ntfs_volume *vol;
1426 vol = ntfs_device_mount(dev, flags);
1427 if (!vol) {
1432 ntfs_create_lru_caches(vol);
1433 return vol;
1447 * @vol: address of ntfs_volume structure of volume to close
1450 * Deallocate all structures (including @vol itself) associated with the ntfs
1451 * volume @vol.
1461 * @vol must have previously been returned by a call to ntfs_mount().
1463 * @vol itself is deallocated and should no longer be dereferenced after this
1465 * so it is safe to continue using @vol.
1467 int ntfs_umount(ntfs_volume *vol, const BOOL force __attribute__((unused)))
1472 if (!vol) {
1476 dev = vol->dev;
1477 ret = __ntfs_volume_release(vol);
1635 * @vol: ntfs volume whose version we're interested in.
1649 int ntfs_version_is_supported(ntfs_volume *vol)
1653 if (!vol) {
1658 major = vol->major_ver;
1659 minor = vol->minor_ver;
1676 * @vol: ntfs volume whose $LogFile we intend to reset.
1689 int ntfs_logfile_reset(ntfs_volume *vol)
1695 if (!vol) {
1700 ni = ntfs_inode_open(vol, FILE_LogFile);
1730 * @vol: ntfs volume where we set the volume flags
1734 * on volume @vol to @flags.
1738 int ntfs_volume_write_flags(ntfs_volume *vol, const le16 flags)
1745 if (!vol || !vol->vol_ni) {
1750 ctx = ntfs_attr_get_search_ctx(vol->vol_ni, NULL);
1781 vol->flags = c->flags = flags & VOLUME_FLAGS_MASK;
1783 ntfs_inode_mark_dirty(vol->vol_ni);
1784 if (ntfs_inode_sync(vol->vol_ni))
1879 int ntfs_volume_get_free_space(ntfs_volume *vol)
1885 vol->free_clusters = ntfs_attr_get_free_bits(vol->lcnbmp_na);
1886 if (vol->free_clusters < 0) {
1889 na = vol->mftbmp_na;
1890 vol->free_mft_records = ntfs_attr_get_free_bits(na);
1892 if (vol->free_mft_records >= 0)
1893 vol->free_mft_records += (na->allocated_size - na->data_size) << 3;
1895 if (vol->free_mft_records < 0)
1898 NVolSetFreeSpaceKnown(vol);
1907 * @vol: volume to change the label on
1912 * Change the label on the volume @vol to @label.
1914 int ntfs_volume_rename(ntfs_volume *vol, const ntfschar *label, int label_len)
1922 if (NVolReadOnly(vol)) {
1938 na = ntfs_attr_open(vol->vol_ni, AT_VOLUME_NAME, AT_UNNAMED, 0);
1948 if (ntfs_attr_add(vol->vol_ni, AT_VOLUME_NAME, AT_UNNAMED, 0,
2002 old_vol_name = vol->vol_name;
2003 vol->vol_name = new_vol_name;