Lines Matching refs:vol

74 int ntfs_init_volume(ntfs_volume *vol, char *boot)  in ntfs_init_volume()  argument
81 vol->at_standard_information = 0x10; in ntfs_init_volume()
82 vol->at_attribute_list = 0x20; in ntfs_init_volume()
83 vol->at_file_name = 0x30; in ntfs_init_volume()
84 vol->at_volume_version = 0x40; in ntfs_init_volume()
85 vol->at_security_descriptor = 0x50; in ntfs_init_volume()
86 vol->at_volume_name = 0x60; in ntfs_init_volume()
87 vol->at_volume_information = 0x70; in ntfs_init_volume()
88 vol->at_data = 0x80; in ntfs_init_volume()
89 vol->at_index_root = 0x90; in ntfs_init_volume()
90 vol->at_index_allocation = 0xA0; in ntfs_init_volume()
91 vol->at_bitmap = 0xB0; in ntfs_init_volume()
92 vol->at_symlink = 0xC0; in ntfs_init_volume()
94 vol->sector_size = NTFS_GETU16(boot + 0xB); in ntfs_init_volume()
96 vol->sector_size); in ntfs_init_volume()
102 vol->mft_clusters_per_record = NTFS_GETS8(boot + 0x40); in ntfs_init_volume()
104 " = 0x%x\n", vol->mft_clusters_per_record); in ntfs_init_volume()
105 vol->index_clusters_per_record = NTFS_GETS8(boot + 0x44); in ntfs_init_volume()
108 vol->index_clusters_per_record); in ntfs_init_volume()
109 vol->cluster_size = vol->sector_size << sectors_per_cluster_bits; in ntfs_init_volume()
110 vol->cluster_size_bits = ffs(vol->cluster_size) - 1; in ntfs_init_volume()
112 vol->cluster_size); in ntfs_init_volume()
114 "0x%x\n", vol->cluster_size_bits); in ntfs_init_volume()
115 if (vol->mft_clusters_per_record > 0) in ntfs_init_volume()
116 vol->mft_record_size = vol->cluster_size << in ntfs_init_volume()
117 (ffs(vol->mft_clusters_per_record) - 1); in ntfs_init_volume()
124 vol->mft_record_size = 1 << -vol->mft_clusters_per_record; in ntfs_init_volume()
125 vol->mft_record_size_bits = ffs(vol->mft_record_size) - 1; in ntfs_init_volume()
127 "\n", vol->mft_record_size); in ntfs_init_volume()
129 "0x%x\n", vol->mft_record_size_bits); in ntfs_init_volume()
130 if (vol->index_clusters_per_record > 0) in ntfs_init_volume()
131 vol->index_record_size = vol->cluster_size << in ntfs_init_volume()
132 (ffs(vol->index_clusters_per_record) - 1); in ntfs_init_volume()
140 vol->index_record_size = 1 << -vol->index_clusters_per_record; in ntfs_init_volume()
141 vol->index_record_size_bits = ffs(vol->index_record_size) - 1; in ntfs_init_volume()
143 "0x%x\n", vol->index_record_size); in ntfs_init_volume()
145 "= 0x%x\n", vol->index_record_size_bits); in ntfs_init_volume()
158 vol->nr_clusters = (ntfs_cluster_t)ll; in ntfs_init_volume()
160 vol->nr_clusters); in ntfs_init_volume()
161 vol->mft_lcn = (ntfs_cluster_t)NTFS_GETS64(boot + 0x30); in ntfs_init_volume()
162 vol->mft_mirr_lcn = (ntfs_cluster_t)NTFS_GETS64(boot + 0x38); in ntfs_init_volume()
164 mft_zone_size = vol->nr_clusters; in ntfs_init_volume()
165 switch (vol->mft_zone_multiplier) { /* % of volume size in clusters */ in ntfs_init_volume()
181 vol->mft_zone_start = vol->mft_zone_pos = vol->mft_lcn; in ntfs_init_volume()
183 vol->mft_zone_pos); in ntfs_init_volume()
193 tc = (8192 + 2 * vol->cluster_size - 1) / vol->cluster_size; in ntfs_init_volume()
194 if (tc * vol->cluster_size < 16 * 1024) in ntfs_init_volume()
195 tc = (16 * 1024 + vol->cluster_size - 1) / vol->cluster_size; in ntfs_init_volume()
196 if (vol->mft_zone_start <= tc) in ntfs_init_volume()
197 vol->mft_zone_start = (ntfs_cluster_t)0; in ntfs_init_volume()
199 vol->mft_zone_start); in ntfs_init_volume()
205 vol->mft_zone_end = vol->mft_lcn + mft_zone_size; in ntfs_init_volume()
206 while (vol->mft_zone_end >= vol->nr_clusters) { in ntfs_init_volume()
208 vol->mft_zone_end = vol->mft_lcn + mft_zone_size; in ntfs_init_volume()
211 vol->mft_zone_end); in ntfs_init_volume()
216 vol->data1_zone_pos = vol->mft_zone_end; in ntfs_init_volume()
218 vol->data1_zone_pos); in ntfs_init_volume()
219 vol->data2_zone_pos = (ntfs_cluster_t)0; in ntfs_init_volume()
221 vol->data2_zone_pos); in ntfs_init_volume()
223 vol->mft_data_pos = 24UL; in ntfs_init_volume()
225 vol->upcase = 0; in ntfs_init_volume()
226 vol->upcase_length = 0; in ntfs_init_volume()
227 vol->mft_ino = 0; in ntfs_init_volume()
235 upcase->vol->upcase = ntfs_malloc(UPCASE_LENGTH << 1); in ntfs_init_upcase()
236 if (!upcase->vol->upcase) in ntfs_init_upcase()
240 io.param = (char*)upcase->vol->upcase; in ntfs_init_upcase()
242 ntfs_read_attr(upcase, upcase->vol->at_data, 0, 0, &io); in ntfs_init_upcase()
243 upcase->vol->upcase_length = io.size >> 1; in ntfs_init_upcase()
250 ntfs_volume *vol = attrdef->vol; in process_attrdef() local
259 vol->at_standard_information = type; in process_attrdef()
262 vol->at_attribute_list = type; in process_attrdef()
265 vol->at_file_name = type; in process_attrdef()
268 vol->at_volume_version = type; in process_attrdef()
271 vol->at_security_descriptor = type; in process_attrdef()
274 vol->at_volume_name = type; in process_attrdef()
277 vol->at_volume_information = type; in process_attrdef()
280 vol->at_data = type; in process_attrdef()
283 vol->at_index_root = type; in process_attrdef()
286 vol->at_index_allocation = type; in process_attrdef()
289 vol->at_bitmap = type; in process_attrdef()
293 vol->at_symlink = type; in process_attrdef()
323 data = ntfs_find_attr(attrdef, attrdef->vol->at_data, 0); in ntfs_init_attrdef()
362 volinfo = ntfs_find_attr(volume, volume->vol->at_volume_information, 0); in ntfs_get_version()
373 int ntfs_load_special_files(ntfs_volume *vol) in ntfs_load_special_files() argument
378 vol->mft_ino = (ntfs_inode*)ntfs_calloc(sizeof(ntfs_inode)); in ntfs_load_special_files()
379 vol->mftmirr = (ntfs_inode*)ntfs_calloc(sizeof(ntfs_inode)); in ntfs_load_special_files()
380 vol->bitmap = (ntfs_inode*)ntfs_calloc(sizeof(ntfs_inode)); in ntfs_load_special_files()
381 vol->ino_flags = 4 | 2 | 1; in ntfs_load_special_files()
384 if (!vol->mft_ino || (error = ntfs_init_inode(vol->mft_ino, vol, in ntfs_load_special_files()
390 if ((error = ntfs_init_inode(vol->mftmirr, vol, FILE_MftMirr))) { in ntfs_load_special_files()
395 if ((error = ntfs_init_inode(vol->bitmap, vol, FILE_BitMap))) { in ntfs_load_special_files()
400 error = ntfs_init_inode(&upcase, vol, FILE_UpCase); in ntfs_load_special_files()
406 error = ntfs_init_inode(&attrdef, vol, FILE_AttrDef); in ntfs_load_special_files()
417 error = ntfs_init_inode(&volume, vol, FILE_Volume); in ntfs_load_special_files()
421 !(NTFS_SB(vol)->s_flags & MS_RDONLY)) { in ntfs_load_special_files()
422 NTFS_SB(vol)->s_flags |= MS_RDONLY; in ntfs_load_special_files()
434 int ntfs_release_volume(ntfs_volume *vol) in ntfs_release_volume() argument
436 if (((vol->ino_flags & 1) == 1) && vol->mft_ino) { in ntfs_release_volume()
437 ntfs_clear_inode(vol->mft_ino); in ntfs_release_volume()
438 ntfs_free(vol->mft_ino); in ntfs_release_volume()
439 vol->mft_ino = 0; in ntfs_release_volume()
441 if (((vol->ino_flags & 2) == 2) && vol->mftmirr) { in ntfs_release_volume()
442 ntfs_clear_inode(vol->mftmirr); in ntfs_release_volume()
443 ntfs_free(vol->mftmirr); in ntfs_release_volume()
444 vol->mftmirr = 0; in ntfs_release_volume()
446 if (((vol->ino_flags & 4) == 4) && vol->bitmap) { in ntfs_release_volume()
447 ntfs_clear_inode(vol->bitmap); in ntfs_release_volume()
448 ntfs_free(vol->bitmap); in ntfs_release_volume()
449 vol->bitmap = 0; in ntfs_release_volume()
451 ntfs_free(vol->mft); in ntfs_release_volume()
452 ntfs_free(vol->upcase); in ntfs_release_volume()
460 int ntfs_get_volumesize(ntfs_volume *vol, ntfs_s64 *vol_size) in ntfs_get_volumesize() argument
467 cluster0 = ntfs_malloc(vol->cluster_size); in ntfs_get_volumesize()
474 io.size = vol->cluster_size; in ntfs_get_volumesize()
475 ntfs_getput_clusters(vol, 0, 0, &io); in ntfs_get_volumesize()
498 error = ntfs_read_attr(bitmap, bitmap->vol->at_data, 0, offset, in ntfs_get_free_cluster_count()
627 int ntfs_allocate_clusters(ntfs_volume *vol, ntfs_cluster_t *location, in ntfs_allocate_clusters() argument
655 data = ntfs_find_attr(vol->bitmap, vol->at_data, 0); in ntfs_allocate_clusters()
681 zone_start = vol->data1_zone_pos; in ntfs_allocate_clusters()
683 zone_start = vol->mft_zone_pos; in ntfs_allocate_clusters()
690 } else if (zone_start >= vol->mft_zone_start && zone_start < in ntfs_allocate_clusters()
691 vol->mft_zone_end && zone == DATA_ZONE) { in ntfs_allocate_clusters()
692 zone_start = vol->mft_zone_end; in ntfs_allocate_clusters()
694 } else if ((zone_start < vol->mft_zone_start || zone_start >= in ntfs_allocate_clusters()
695 vol->mft_zone_end) && zone == MFT_ZONE) { in ntfs_allocate_clusters()
696 zone_start = vol->mft_lcn; in ntfs_allocate_clusters()
697 if (!vol->mft_zone_end) in ntfs_allocate_clusters()
704 if (zone_start >= vol->mft_zone_end) { in ntfs_allocate_clusters()
705 zone_end = vol->nr_clusters; in ntfs_allocate_clusters()
708 zone_end = vol->mft_zone_start; in ntfs_allocate_clusters()
712 zone_end = vol->mft_zone_end; in ntfs_allocate_clusters()
745 err = ntfs_readwrite_attr(vol->bitmap, data, last_read_pos, in ntfs_allocate_clusters()
892 vol->mft_zone_pos); in ntfs_allocate_clusters()
893 if (tc >= vol->mft_zone_end) { in ntfs_allocate_clusters()
894 vol->mft_zone_pos = in ntfs_allocate_clusters()
895 vol->mft_lcn; in ntfs_allocate_clusters()
896 if (!vol->mft_zone_end) in ntfs_allocate_clusters()
897 vol->mft_zone_pos = in ntfs_allocate_clusters()
900 vol->mft_zone_pos || in ntfs_allocate_clusters()
901 tc > vol->mft_zone_pos) in ntfs_allocate_clusters()
902 && tc >= vol->mft_lcn) in ntfs_allocate_clusters()
903 vol->mft_zone_pos = tc; in ntfs_allocate_clusters()
908 vol->mft_zone_pos); in ntfs_allocate_clusters()
915 vol->data1_zone_pos); in ntfs_allocate_clusters()
916 if (tc >= vol->nr_clusters) in ntfs_allocate_clusters()
917 vol->data1_zone_pos = in ntfs_allocate_clusters()
918 vol->mft_zone_end; in ntfs_allocate_clusters()
920 vol->data1_zone_pos || in ntfs_allocate_clusters()
921 tc > vol->data1_zone_pos) in ntfs_allocate_clusters()
922 && tc >= vol->mft_zone_end) in ntfs_allocate_clusters()
923 vol->data1_zone_pos = tc; in ntfs_allocate_clusters()
928 vol->data1_zone_pos); in ntfs_allocate_clusters()
935 vol->data2_zone_pos); in ntfs_allocate_clusters()
936 if (tc >= vol->mft_zone_start) in ntfs_allocate_clusters()
937 vol->data2_zone_pos = in ntfs_allocate_clusters()
940 vol->data2_zone_pos || in ntfs_allocate_clusters()
941 tc > vol->data2_zone_pos) in ntfs_allocate_clusters()
942 vol->data2_zone_pos = tc; in ntfs_allocate_clusters()
947 vol->data2_zone_pos); in ntfs_allocate_clusters()
969 err = ntfs_readwrite_attr(vol->bitmap, data, in ntfs_allocate_clusters()
998 zone_start = vol->mft_zone_start; in ntfs_allocate_clusters()
1001 zone_start = vol->mft_zone_end; in ntfs_allocate_clusters()
1044 vol->mft_zone_pos); in ntfs_allocate_clusters()
1047 if (tc >= vol->mft_zone_end) { in ntfs_allocate_clusters()
1048 vol->mft_zone_pos = in ntfs_allocate_clusters()
1049 vol->mft_lcn; in ntfs_allocate_clusters()
1050 if (!vol->mft_zone_end) in ntfs_allocate_clusters()
1051 vol->mft_zone_pos = in ntfs_allocate_clusters()
1054 vol->mft_zone_pos || in ntfs_allocate_clusters()
1055 tc > vol->mft_zone_pos) in ntfs_allocate_clusters()
1056 && tc >= vol->mft_lcn) in ntfs_allocate_clusters()
1057 vol->mft_zone_pos = tc; in ntfs_allocate_clusters()
1062 vol->mft_zone_pos); in ntfs_allocate_clusters()
1067 vol->data1_zone_pos; in ntfs_allocate_clusters()
1068 zone_end = vol->nr_clusters; in ntfs_allocate_clusters()
1069 if (zone_start == vol->mft_zone_end) in ntfs_allocate_clusters()
1072 vol->data1_zone_pos = zone_start = in ntfs_allocate_clusters()
1073 vol->mft_zone_end; in ntfs_allocate_clusters()
1088 vol->data1_zone_pos); in ntfs_allocate_clusters()
1091 if (tc >= vol->nr_clusters) in ntfs_allocate_clusters()
1092 vol->data1_zone_pos = in ntfs_allocate_clusters()
1093 vol->mft_zone_end; in ntfs_allocate_clusters()
1095 vol->data1_zone_pos || in ntfs_allocate_clusters()
1096 tc > vol->data1_zone_pos) in ntfs_allocate_clusters()
1097 && tc >= vol->mft_zone_end) in ntfs_allocate_clusters()
1098 vol->data1_zone_pos = tc; in ntfs_allocate_clusters()
1103 vol->data1_zone_pos); in ntfs_allocate_clusters()
1108 vol->data2_zone_pos; in ntfs_allocate_clusters()
1109 zone_end = vol->mft_zone_start; in ntfs_allocate_clusters()
1113 vol->data2_zone_pos = zone_start = in ntfs_allocate_clusters()
1130 vol->data2_zone_pos); in ntfs_allocate_clusters()
1133 if (tc >= vol->mft_zone_start) in ntfs_allocate_clusters()
1134 vol->data2_zone_pos = in ntfs_allocate_clusters()
1137 vol->data2_zone_pos || in ntfs_allocate_clusters()
1138 tc > vol->data2_zone_pos) in ntfs_allocate_clusters()
1139 vol->data2_zone_pos = tc; in ntfs_allocate_clusters()
1144 vol->data2_zone_pos); in ntfs_allocate_clusters()
1175 mft_zone_size = vol->mft_zone_end - vol->mft_zone_start; in ntfs_allocate_clusters()
1178 "0x%x.\n", __FUNCTION__, vol->mft_zone_start, in ntfs_allocate_clusters()
1179 vol->mft_zone_end, mft_zone_size); in ntfs_allocate_clusters()
1190 zone_end = vol->mft_zone_end; in ntfs_allocate_clusters()
1193 vol->mft_zone_end = vol->mft_zone_start + mft_zone_size; in ntfs_allocate_clusters()
1195 vol->data2_zone_pos = vol->mft_zone_start = in ntfs_allocate_clusters()
1196 vol->mft_zone_end = (ntfs_cluster_t)0; in ntfs_allocate_clusters()
1197 if (vol->mft_zone_pos >= vol->mft_zone_end) { in ntfs_allocate_clusters()
1198 vol->mft_zone_pos = vol->mft_lcn; in ntfs_allocate_clusters()
1199 if (!vol->mft_zone_end) in ntfs_allocate_clusters()
1200 vol->mft_zone_pos = (ntfs_cluster_t)0; in ntfs_allocate_clusters()
1203 vol->data1_zone_pos = vol->mft_zone_end; in ntfs_allocate_clusters()
1215 vol->mft_zone_start, vol->mft_zone_end, in ntfs_allocate_clusters()
1216 vol->mft_zone_pos, done_zones, zone_start, in ntfs_allocate_clusters()
1217 zone_end, vol->data1_zone_pos); in ntfs_allocate_clusters()
1232 err = ntfs_readwrite_attr(vol->bitmap, data, last_read_pos, in ntfs_allocate_clusters()
1253 if (ntfs_update_inode(vol->bitmap)) in ntfs_allocate_clusters()
1273 ntfs_deallocate_clusters(vol, rl2, rlpos); in ntfs_allocate_clusters()
1279 *location = vol->data1_zone_pos; /* Irrelevant... */ in ntfs_allocate_clusters()
1299 __err = ntfs_readwrite_attr(vol->bitmap, data, last_read_pos, in ntfs_allocate_clusters()
1344 err = ntfs_read_attr(bitmap, bitmap->vol->at_data, 0, start_bit >> 3, in ntfs_clear_bitrange()
1371 err = ntfs_write_attr(bitmap, bitmap->vol->at_data, 0, start_bit >> 3, in ntfs_clear_bitrange()
1387 int ntfs_deallocate_cluster_run(const ntfs_volume *vol, in ntfs_deallocate_cluster_run() argument
1393 err = ntfs_clear_bitrange(vol->bitmap, lcn, len); in ntfs_deallocate_cluster_run()
1405 int ntfs_deallocate_clusters(const ntfs_volume *vol, const ntfs_runlist *rl, in ntfs_deallocate_clusters() argument
1412 err = ntfs_clear_bitrange(vol->bitmap, rl[i].lcn, rl[i].len); in ntfs_deallocate_clusters()