Lines Matching +full:force +full:- +full:load +full:- +full:on +full:- +full:access
2 * volume.c - NTFS volume handling code. Originated from the Linux-NTFS project.
4 * Copyright (c) 2000-2006 Anton Altaparmakov
5 * Copyright (c) 2002-2009 Szabolcs Szakacsits
6 * Copyright (c) 2004-2005 Richard Russon
7 * Copyright (c) 2010 Jean-Pierre Andre
20 * along with this program (in the main directory of the NTFS-3G
22 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
80 "News, support and information: https://github.com/tuxera/ntfs-3g/\n";
89 "SoftRAID/FakeRAID hardware. In the first case run chkdsk /f on Windows\n"
99 "read-only with the 'ro' mount option.\n";
102 "Falling back to read-only mount because the NTFS partition is in an\n"
107 "Write access is denied because the disk wasn't safely powered\n"
122 "Please check '%s' and the ntfs-3g binary permissions,\n"
124 "https://github.com/tuxera/ntfs-3g/wiki/NTFS-3G-FAQ\n";
127 * ntfs_volume_alloc - Create an NTFS volume object and initialise it
148 int ret = -1; in ntfs_inode_free()
165 * __ntfs_volume_release - Destroy an NTFS volume object
179 if (ntfs_inode_free(&v->vol_ni)) in __ntfs_volume_release()
185 if (v->lcnbmp_ni && NInoDirty(v->lcnbmp_ni)) in __ntfs_volume_release()
186 ntfs_inode_sync(v->lcnbmp_ni); in __ntfs_volume_release()
187 ntfs_attr_free(&v->lcnbmp_na); in __ntfs_volume_release()
188 if (ntfs_inode_free(&v->lcnbmp_ni)) in __ntfs_volume_release()
191 if (v->mft_ni && NInoDirty(v->mft_ni)) in __ntfs_volume_release()
192 ntfs_inode_sync(v->mft_ni); in __ntfs_volume_release()
193 ntfs_attr_free(&v->mftbmp_na); in __ntfs_volume_release()
194 ntfs_attr_free(&v->mft_na); in __ntfs_volume_release()
195 if (ntfs_inode_free(&v->mft_ni)) in __ntfs_volume_release()
198 if (v->mftmirr_ni && NInoDirty(v->mftmirr_ni)) in __ntfs_volume_release()
199 ntfs_inode_sync(v->mftmirr_ni); in __ntfs_volume_release()
200 ntfs_attr_free(&v->mftmirr_na); in __ntfs_volume_release()
201 if (ntfs_inode_free(&v->mftmirr_ni)) in __ntfs_volume_release()
204 if (v->dev) { in __ntfs_volume_release()
205 struct ntfs_device *dev = v->dev; in __ntfs_volume_release()
207 if (dev->d_ops->sync(dev)) in __ntfs_volume_release()
209 if (dev->d_ops->close(dev)) in __ntfs_volume_release()
214 free(v->vol_name); in __ntfs_volume_release()
215 free(v->upcase); in __ntfs_volume_release()
216 if (v->locase) free(v->locase); in __ntfs_volume_release()
217 free(v->attrdef); in __ntfs_volume_release()
221 return errno ? -1 : 0; in __ntfs_volume_release()
234 ni->flags = si->file_attributes; in ntfs_attr_setup_flag()
239 r = -1; in ntfs_attr_setup_flag()
245 * ntfs_mft_load - load the $MFT and setup the ntfs volume with it
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
252 * Return 0 on success and -1 on error with errno set to the error code.
264 vol->mft_ni = ntfs_inode_allocate(vol); in ntfs_mft_load()
265 mb = ntfs_malloc(vol->mft_record_size); in ntfs_mft_load()
266 if (!vol->mft_ni || !mb) { in ntfs_mft_load()
270 vol->mft_ni->mft_no = 0; in ntfs_mft_load()
271 vol->mft_ni->mrec = mb; in ntfs_mft_load()
273 l = ntfs_mst_pread(vol->dev, vol->mft_lcn << vol->cluster_size_bits, 1, in ntfs_mft_load()
274 vol->mft_record_size, mb); in ntfs_mft_load()
276 if (l != -1) in ntfs_mft_load()
285 ctx = ntfs_attr_get_search_ctx(vol->mft_ni, NULL); in ntfs_mft_load()
298 NInoSetAttrList(vol->mft_ni); in ntfs_mft_load()
299 l = ntfs_get_attribute_value_length(ctx->attr); in ntfs_mft_load()
305 vol->mft_ni->attr_list_size = l; in ntfs_mft_load()
306 vol->mft_ni->attr_list = ntfs_malloc(l); in ntfs_mft_load()
307 if (!vol->mft_ni->attr_list) in ntfs_mft_load()
310 l = ntfs_get_attribute_value(vol, ctx->attr, vol->mft_ni->attr_list); in ntfs_mft_load()
315 if ((l != vol->mft_ni->attr_list_size) in ntfs_mft_load()
319 vol->mft_ni->attr_list_size, in ntfs_mft_load()
326 if (ntfs_attr_setup_flag(vol->mft_ni)) in ntfs_mft_load()
329 /* We now have a fully setup ntfs inode for $MFT in vol->mft_ni. */ in ntfs_mft_load()
332 vol->mft_na = ntfs_attr_open(vol->mft_ni, AT_DATA, AT_UNNAMED, 0); in ntfs_mft_load()
333 if (!vol->mft_na) { in ntfs_mft_load()
339 last_vcn = vol->mft_na->allocated_size >> vol->cluster_size_bits; in ntfs_mft_load()
346 a = ctx->attr; in ntfs_mft_load()
347 /* $MFT must be non-resident. */ in ntfs_mft_load()
348 if (!a->non_resident) { in ntfs_mft_load()
349 ntfs_log_error("$MFT must be non-resident.\n"); in ntfs_mft_load()
353 if (a->flags & ATTR_COMPRESSION_MASK || in ntfs_mft_load()
354 a->flags & ATTR_IS_ENCRYPTED) { in ntfs_mft_load()
362 * as we have exclusive access to the inode at this time and we in ntfs_mft_load()
365 nrl = ntfs_mapping_pairs_decompress(vol, a, vol->mft_na->rl); in ntfs_mft_load()
371 if (nrl->lcn != vol->mft_lcn) { in ntfs_mft_load()
372 ntfs_log_perror("The MFT is not self-contained"); in ntfs_mft_load()
375 vol->mft_na->rl = nrl; in ntfs_mft_load()
378 highest_vcn = sle64_to_cpu(a->highest_vcn); in ntfs_mft_load()
386 if (next_vcn < sle64_to_cpu(a->lowest_vcn)) { in ntfs_mft_load()
395 if (highest_vcn && highest_vcn != last_vcn - 1) { in ntfs_mft_load()
396 ntfs_log_error("Failed to load runlist for $MFT/$DATA.\n"); in ntfs_mft_load()
397 ntfs_log_error("highest_vcn = 0x%llx, last_vcn - 1 = 0x%llx\n", in ntfs_mft_load()
398 (long long)highest_vcn, (long long)last_vcn - 1); in ntfs_mft_load()
406 vol->mft_ni->data_size = vol->mft_na->data_size; in ntfs_mft_load()
407 vol->mft_ni->allocated_size = vol->mft_na->allocated_size; in ntfs_mft_load()
408 set_nino_flag(vol->mft_ni, KnownSize); in ntfs_mft_load()
411 * The volume is now setup so we can use all read access functions. in ntfs_mft_load()
413 vol->mftbmp_na = ntfs_attr_open(vol->mft_ni, AT_BITMAP, AT_UNNAMED, 0); in ntfs_mft_load()
414 if (!vol->mftbmp_na) { in ntfs_mft_load()
425 if (vol->mft_na) { in ntfs_mft_load()
426 ntfs_attr_close(vol->mft_na); in ntfs_mft_load()
427 vol->mft_na = NULL; in ntfs_mft_load()
429 if (vol->mft_ni) { in ntfs_mft_load()
430 ntfs_inode_close(vol->mft_ni); in ntfs_mft_load()
431 vol->mft_ni = NULL; in ntfs_mft_load()
434 return -1; in ntfs_mft_load()
438 * ntfs_mftmirr_load - load the $MFTMirr and setup the ntfs volume with it
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
446 * Return 0 on success and -1 on error with errno set to the error code.
452 vol->mftmirr_ni = ntfs_inode_open(vol, FILE_MFTMirr); in ntfs_mftmirr_load()
453 if (!vol->mftmirr_ni) { in ntfs_mftmirr_load()
455 return -1; in ntfs_mftmirr_load()
458 vol->mftmirr_na = ntfs_attr_open(vol->mftmirr_ni, AT_DATA, AT_UNNAMED, 0); in ntfs_mftmirr_load()
459 if (!vol->mftmirr_na) { in ntfs_mftmirr_load()
464 if (ntfs_attr_map_runlist(vol->mftmirr_na, 0) < 0) { in ntfs_mftmirr_load()
468 if (vol->mftmirr_na->rl->lcn != vol->mftmirr_lcn) { in ntfs_mftmirr_load()
470 (long long)vol->mftmirr_na->rl->lcn, in ntfs_mftmirr_load()
471 (long long)vol->mftmirr_lcn); in ntfs_mftmirr_load()
479 if (vol->mftmirr_na) { in ntfs_mftmirr_load()
480 ntfs_attr_close(vol->mftmirr_na); in ntfs_mftmirr_load()
481 vol->mftmirr_na = NULL; in ntfs_mftmirr_load()
483 ntfs_inode_close(vol->mftmirr_ni); in ntfs_mftmirr_load()
484 vol->mftmirr_ni = NULL; in ntfs_mftmirr_load()
486 return -1; in ntfs_mftmirr_load()
490 * ntfs_volume_startup - allocate and setup an ntfs volume
494 * Load, verify, and parse bootsector; load and setup $MFT and $MFTMirr. After
496 * and write access functions provided by the library.
498 * Return the allocated volume structure on success and NULL on error with
510 if (!dev || !dev->d_ops || !dev->d_name) { in ntfs_volume_startup()
526 vol->upcase_len = ntfs_upcase_build_default(&vol->upcase); in ntfs_volume_startup()
527 if (!vol->upcase_len || !vol->upcase) in ntfs_volume_startup()
531 vol->locase = (ntfschar*)NULL; in ntfs_volume_startup()
547 /* ...->open needs bracketing to compile with glibc 2.7 */ in ntfs_volume_startup()
548 if ((dev->d_ops->open)(dev, NVolReadOnly(vol) ? O_RDONLY: O_RDWR)) { in ntfs_volume_startup()
550 if ((dev->d_ops->open)(dev, O_RDONLY)) { in ntfs_volume_startup()
551 ntfs_log_perror("Error opening read-only '%s'", in ntfs_volume_startup()
552 dev->d_name); in ntfs_volume_startup()
555 ntfs_log_info("Error opening '%s' read-write\n", in ntfs_volume_startup()
556 dev->d_name); in ntfs_volume_startup()
560 ntfs_log_perror("Error opening '%s'", dev->d_name); in ntfs_volume_startup()
565 vol->dev = dev; in ntfs_volume_startup()
570 if (br != -1) in ntfs_volume_startup()
588 if (ntfs_device_block_size_set(vol->dev, vol->sector_size)) in ntfs_volume_startup()
595 vol->full_zones = 0; in ntfs_volume_startup()
596 mft_zone_size = vol->nr_clusters >> 3; /* 12.5% */ in ntfs_volume_startup()
599 vol->mft_zone_start = vol->mft_zone_pos = vol->mft_lcn; in ntfs_volume_startup()
600 ntfs_log_debug("mft_zone_pos = 0x%llx\n", (long long)vol->mft_zone_pos); in ntfs_volume_startup()
608 * On non-standard volumes we don't protect it as the overhead would be in ntfs_volume_startup()
611 mft_lcn = (8192 + 2 * vol->cluster_size - 1) / vol->cluster_size; in ntfs_volume_startup()
612 if (mft_lcn * vol->cluster_size < 16 * 1024) in ntfs_volume_startup()
613 mft_lcn = (16 * 1024 + vol->cluster_size - 1) / in ntfs_volume_startup()
614 vol->cluster_size; in ntfs_volume_startup()
615 if (vol->mft_zone_start <= mft_lcn) in ntfs_volume_startup()
616 vol->mft_zone_start = 0; in ntfs_volume_startup()
617 ntfs_log_debug("mft_zone_start = 0x%llx\n", (long long)vol->mft_zone_start); in ntfs_volume_startup()
620 * Need to cap the mft zone on non-standard volumes so that it does in ntfs_volume_startup()
624 vol->mft_zone_end = vol->mft_lcn + mft_zone_size; in ntfs_volume_startup()
625 while (vol->mft_zone_end >= vol->nr_clusters) { in ntfs_volume_startup()
631 vol->mft_zone_end = vol->mft_lcn + mft_zone_size; in ntfs_volume_startup()
633 ntfs_log_debug("mft_zone_end = 0x%llx\n", (long long)vol->mft_zone_end); in ntfs_volume_startup()
639 vol->data1_zone_pos = vol->mft_zone_end; in ntfs_volume_startup()
640 ntfs_log_debug("data1_zone_pos = %lld\n", (long long)vol->data1_zone_pos); in ntfs_volume_startup()
641 vol->data2_zone_pos = 0; in ntfs_volume_startup()
642 ntfs_log_debug("data2_zone_pos = %lld\n", (long long)vol->data2_zone_pos); in ntfs_volume_startup()
645 vol->mft_data_pos = 24; in ntfs_volume_startup()
653 ntfs_log_perror("Failed to load $MFT"); in ntfs_volume_startup()
659 ntfs_log_perror("Failed to load $MFTMirr"); in ntfs_volume_startup()
673 * ntfs_volume_check_logfile - check logfile on target volume
674 * @vol: volume on which to check logfile
676 * Return 0 on success and -1 on error with errno set error code.
689 return -1; in ntfs_volume_check_logfile()
705 * Hibernation will be seen the same way on a non in ntfs_volume_check_logfile()
706 * Windows-system partition, so we have to use the same in ntfs_volume_check_logfile()
709 * when access to the file system is terminated abruptly in ntfs_volume_check_logfile()
714 && (rp->major_ver == const_cpu_to_le16(2)) in ntfs_volume_check_logfile()
715 && (rp->minor_ver == const_cpu_to_le16(0))) { in ntfs_volume_check_logfile()
726 return -1; in ntfs_volume_check_logfile()
732 * ntfs_hiberfile_open - Find and open '/hiberfil.sys'
765 if (inode == (u64)-1) { in ntfs_hiberfile_open()
789 * ntfs_volume_check_hiberfile - check hiberfil.sys whether Windows is
790 * hibernated on the target volume
791 * @vol: volume on which to check hiberfil.sys
794 * -1 otherwise and errno is set to the appropriate value
807 return -1; in ntfs_volume_check_hiberfile()
821 if (bytes_read == -1) { in ntfs_volume_check_hiberfile()
827 ntfs_log_error("Hibernated non-system partition, " in ntfs_volume_check_hiberfile()
849 return errno ? -1 : 0; in ntfs_volume_check_hiberfile()
854 * on the root directory is resident.
855 * When it is non-resident, the partition cannot be mounted on Vista
863 * -1 if there was an error, explained by errno
879 res = -1; in fix_txf_data()
898 res = -1; in fix_txf_data()
910 res = -1; in fix_txf_data()
917 * ntfs_device_mount - open ntfs volume
927 * NTFS_MNT_RDONLY - mount volume read-only
932 * bootsector. It proceeds to load the necessary system files and completes
935 * Return the allocated volume structure on success and NULL on error with
960 /* Load data from $MFT and $MFTMirr and compare the contents. */ in ntfs_device_mount()
961 m = ntfs_malloc(vol->mftmirr_size << vol->mft_record_size_bits); in ntfs_device_mount()
962 m2 = ntfs_malloc(vol->mftmirr_size << vol->mft_record_size_bits); in ntfs_device_mount()
966 l = ntfs_attr_mst_pread(vol->mft_na, 0, vol->mftmirr_size, in ntfs_device_mount()
967 vol->mft_record_size, m); in ntfs_device_mount()
968 if (l != vol->mftmirr_size) { in ntfs_device_mount()
969 if (l == -1) in ntfs_device_mount()
974 vol->mftmirr_size); in ntfs_device_mount()
981 (MFT_RECORD*)(m + i*vol->mft_record_size))) in ntfs_device_mount()
983 l = ntfs_attr_mst_pread(vol->mftmirr_na, 0, vol->mftmirr_size, in ntfs_device_mount()
984 vol->mft_record_size, m2); in ntfs_device_mount()
985 if (l != vol->mftmirr_size) { in ntfs_device_mount()
986 if (l == -1) { in ntfs_device_mount()
990 vol->mftmirr_size = l; in ntfs_device_mount()
994 (MFT_RECORD*)(m2 + i*vol->mft_record_size))) in ntfs_device_mount()
998 for (i = 0; (i < vol->mftmirr_size) && (i < FILE_first_user); ++i) { in ntfs_device_mount()
1012 mrec = (MFT_RECORD*)(m + i * vol->mft_record_size); in ntfs_device_mount()
1013 if (mrec->flags & MFT_RECORD_IN_USE) { in ntfs_device_mount()
1014 if (ntfs_is_baad_record(mrec->magic)) { in ntfs_device_mount()
1020 if (!ntfs_is_mft_record(mrec->magic)) { in ntfs_device_mount()
1026 mrec2 = (MFT_RECORD*)(m2 + i * vol->mft_record_size); in ntfs_device_mount()
1027 if (mrec2->flags & MFT_RECORD_IN_USE) { in ntfs_device_mount()
1028 if (ntfs_is_baad_record(mrec2->magic)) { in ntfs_device_mount()
1034 if (!ntfs_is_mft_record(mrec2->magic)) { in ntfs_device_mount()
1042 || (record_size > vol->mft_record_size) in ntfs_device_mount()
1054 /* Now load the bitmap from $Bitmap. */ in ntfs_device_mount()
1056 vol->lcnbmp_ni = ntfs_inode_open(vol, FILE_Bitmap); in ntfs_device_mount()
1057 if (!vol->lcnbmp_ni) { in ntfs_device_mount()
1062 vol->lcnbmp_na = ntfs_attr_open(vol->lcnbmp_ni, AT_DATA, AT_UNNAMED, 0); in ntfs_device_mount()
1063 if (!vol->lcnbmp_na) { in ntfs_device_mount()
1068 if (vol->lcnbmp_na->data_size > vol->lcnbmp_na->allocated_size) { in ntfs_device_mount()
1070 (long long)vol->lcnbmp_na->data_size, in ntfs_device_mount()
1071 (long long)vol->lcnbmp_na->allocated_size); in ntfs_device_mount()
1075 /* Now load the upcase table from $UpCase. */ in ntfs_device_mount()
1091 * 2-byte Unicode characters. Anyway we currently can only process in ntfs_device_mount()
1094 if ((na->data_size - 2) & ~0x1fffeULL) { in ntfs_device_mount()
1100 if (vol->upcase_len != na->data_size >> 1) { in ntfs_device_mount()
1101 vol->upcase_len = na->data_size >> 1; in ntfs_device_mount()
1103 free(vol->upcase); in ntfs_device_mount()
1104 vol->upcase = ntfs_malloc(na->data_size); in ntfs_device_mount()
1105 if (!vol->upcase) in ntfs_device_mount()
1109 l = ntfs_attr_pread(na, 0, na->data_size, vol->upcase); in ntfs_device_mount()
1110 if (l != na->data_size) { in ntfs_device_mount()
1113 (long long)na->data_size); in ntfs_device_mount()
1125 while ((k < vol->upcase_len) in ntfs_device_mount()
1127 && (le16_to_cpu(vol->upcase[k]) in ntfs_device_mount()
1128 == ((k < 'a') || (k > 'z') ? k : k + 'A' - 'a'))) in ntfs_device_mount()
1136 * Now load $Volume and set the version information and flags in the in ntfs_device_mount()
1140 vol->vol_ni = ntfs_inode_open(vol, FILE_Volume); in ntfs_device_mount()
1141 if (!vol->vol_ni) { in ntfs_device_mount()
1146 ctx = ntfs_attr_get_search_ctx(vol->vol_ni, NULL); in ntfs_device_mount()
1157 a = ctx->attr; in ntfs_device_mount()
1159 if (a->non_resident) { in ntfs_device_mount()
1166 vinf = (VOLUME_INFORMATION*)(le16_to_cpu(a->value_offset) + (char*)a); in ntfs_device_mount()
1168 if ((char*)vinf + le32_to_cpu(a->value_length) > (char*)ctx->mrec + in ntfs_device_mount()
1169 le32_to_cpu(ctx->mrec->bytes_in_use) || in ntfs_device_mount()
1170 le16_to_cpu(a->value_offset) + le32_to_cpu( in ntfs_device_mount()
1171 a->value_length) > le32_to_cpu(a->length)) { in ntfs_device_mount()
1177 vol->major_ver = vinf->major_ver; in ntfs_device_mount()
1178 vol->minor_ver = vinf->minor_ver; in ntfs_device_mount()
1181 vol->flags = vinf->flags; in ntfs_device_mount()
1198 vol->vol_name = ntfs_malloc(1); in ntfs_device_mount()
1199 if (!vol->vol_name) in ntfs_device_mount()
1201 vol->vol_name[0] = '\0'; in ntfs_device_mount()
1203 a = ctx->attr; in ntfs_device_mount()
1205 if (a->non_resident) { in ntfs_device_mount()
1211 vname = (ntfschar*)(le16_to_cpu(a->value_offset) + (char*)a); in ntfs_device_mount()
1212 u = le32_to_cpu(a->value_length) / 2; in ntfs_device_mount()
1217 vol->vol_name = NULL; in ntfs_device_mount()
1218 if (ntfs_ucstombs(vname, u, &vol->vol_name, 0) == -1) { in ntfs_device_mount()
1222 "non-ASCII characters with underscores.\n"); in ntfs_device_mount()
1223 vol->vol_name = ntfs_malloc(u + 1); in ntfs_device_mount()
1224 if (!vol->vol_name) in ntfs_device_mount()
1231 vol->vol_name[j] = (char)uc; in ntfs_device_mount()
1233 vol->vol_name[u] = '\0'; in ntfs_device_mount()
1238 /* Now load the attribute definitions from $AttrDef. */ in ntfs_device_mount()
1251 /* Check we don't overflow 24-bits. */ in ntfs_device_mount()
1252 if ((u64)na->data_size > 0xffffffLL) { in ntfs_device_mount()
1254 "24-bit allowed).\n"); in ntfs_device_mount()
1258 vol->attrdef_len = na->data_size; in ntfs_device_mount()
1259 vol->attrdef = ntfs_malloc(na->data_size); in ntfs_device_mount()
1260 if (!vol->attrdef) in ntfs_device_mount()
1263 l = ntfs_attr_pread(na, 0, na->data_size, vol->attrdef); in ntfs_device_mount()
1264 if (l != na->data_size) { in ntfs_device_mount()
1267 (long long)na->data_size); in ntfs_device_mount()
1284 * We care only about read-write mounts. in ntfs_device_mount()
1303 "closed on Windows. Fixing.\n"); in ntfs_device_mount()
1308 /* make $TXF_DATA resident if present on the root directory */ in ntfs_device_mount()
1349 res = -1; in ntfs_set_shown_files()
1375 res = -1; in ntfs_set_ignore_case()
1376 if (vol && vol->upcase) { in ntfs_set_ignore_case()
1377 vol->locase = ntfs_locase_table_build(vol->upcase, in ntfs_set_ignore_case()
1378 vol->upcase_len); in ntfs_set_ignore_case()
1379 if (vol->locase) { in ntfs_set_ignore_case()
1390 * ntfs_mount - open ntfs volume
1400 * NTFS_MNT_RDONLY - mount volume read-only
1405 * bootsector. It proceeds to load the necessary system files and completes
1408 * Return the allocated volume structure on success and NULL on error with
1446 * ntfs_umount - close ntfs volume
1448 * @force: if true force close the volume even if it is busy
1453 * Return 0 on success. On error return -1 with errno set appropriately
1458 * If @force is true (i.e. not zero) this function will close the volume even
1467 int ntfs_umount(ntfs_volume *vol, const BOOL force __attribute__((unused))) in ntfs_umount() argument
1474 return -1; in ntfs_umount()
1476 dev = vol->dev; in ntfs_umount()
1485 * ntfs_mntent_check - desc
1488 * ntfs_check_if_mounted(), you just didn't realize. (-:
1501 return -1; in ntfs_mntent_check()
1517 if (!ntfs_realpath_canonicalize(mnt->mnt_fsname, real_fsname)) in ntfs_mntent_check()
1526 if (!strcmp(mnt->mnt_dir, "/")) in ntfs_mntent_check()
1537 return -1; in ntfs_mntent_check()
1555 return -1; in ntfs_mntent_check()
1571 if (!ntfs_realpath_canonicalize(mnt->mnt_special, real_fsname)) in ntfs_mntent_check()
1575 if (!strcmp(mnt->mnt_mountp, "/")) in ntfs_mntent_check()
1589 return -1; in ntfs_mntent_check()
1598 * ntfs_check_if_mounted - check if an ntfs volume is currently mounted
1606 * to find the device @file in /etc/mtab (or wherever this is kept on the
1615 * Finally, check if the file system is mounted read-only, and if so set the
1618 * On success return 0 with *@mnt_flags set to the ntfs mount flags.
1620 * On error return -1 with errno set to the error code.
1634 * ntfs_version_is_supported - check if NTFS version is supported.
1643 * Return 0 if NTFS version is supported otherwise -1 with errno set.
1646 * EOPNOTSUPP - Unknown NTFS version
1647 * EINVAL - Invalid argument
1655 return -1; in ntfs_version_is_supported()
1658 major = vol->major_ver; in ntfs_version_is_supported()
1659 minor = vol->minor_ver; in ntfs_version_is_supported()
1671 return -1; in ntfs_version_is_supported()
1675 * ntfs_logfile_reset - "empty" $LogFile data attribute value
1685 * On success return 0.
1687 * On error return -1 with errno set to the error code.
1697 return -1; in ntfs_logfile_reset()
1703 return -1; in ntfs_logfile_reset()
1725 return -1; in ntfs_logfile_reset()
1729 * ntfs_volume_write_flags - set the flags of an ntfs volume
1733 * Set the on-disk volume flags in the mft record of $Volume and
1734 * on volume @vol to @flags.
1736 * Return 0 if successful and -1 if not with errno set to the error code.
1743 int ret = -1; /* failure */ in ntfs_volume_write_flags()
1745 if (!vol || !vol->vol_ni) { in ntfs_volume_write_flags()
1747 return -1; in ntfs_volume_write_flags()
1750 ctx = ntfs_attr_get_search_ctx(vol->vol_ni, NULL); in ntfs_volume_write_flags()
1752 return -1; in ntfs_volume_write_flags()
1760 a = ctx->attr; in ntfs_volume_write_flags()
1762 if (a->non_resident) { in ntfs_volume_write_flags()
1769 c = (VOLUME_INFORMATION*)(le16_to_cpu(a->value_offset) + (char*)a); in ntfs_volume_write_flags()
1771 if ((char*)c + le32_to_cpu(a->value_length) > (char*)ctx->mrec + in ntfs_volume_write_flags()
1772 le32_to_cpu(ctx->mrec->bytes_in_use) || in ntfs_volume_write_flags()
1773 le16_to_cpu(a->value_offset) + in ntfs_volume_write_flags()
1774 le32_to_cpu(a->value_length) > le32_to_cpu(a->length)) { in ntfs_volume_write_flags()
1781 vol->flags = c->flags = flags & VOLUME_FLAGS_MASK; in ntfs_volume_write_flags()
1783 ntfs_inode_mark_dirty(vol->vol_ni); in ntfs_volume_write_flags()
1784 if (ntfs_inode_sync(vol->vol_ni)) in ntfs_volume_write_flags()
1810 * same way on a non Windows-system partition. in ntfs_volume_error()
1884 ret = -1; /* default return */ in ntfs_volume_get_free_space()
1885 vol->free_clusters = ntfs_attr_get_free_bits(vol->lcnbmp_na); in ntfs_volume_get_free_space()
1886 if (vol->free_clusters < 0) { in ntfs_volume_get_free_space()
1889 na = vol->mftbmp_na; in ntfs_volume_get_free_space()
1890 vol->free_mft_records = ntfs_attr_get_free_bits(na); in ntfs_volume_get_free_space()
1892 if (vol->free_mft_records >= 0) in ntfs_volume_get_free_space()
1893 vol->free_mft_records += (na->allocated_size - na->data_size) << 3; in ntfs_volume_get_free_space()
1895 if (vol->free_mft_records < 0) in ntfs_volume_get_free_space()
1906 * ntfs_volume_rename - change the current label on a volume
1907 * @vol: volume to change the label on
1912 * Change the label on the volume @vol to @label.
1923 ntfs_log_error("Refusing to change label on read-only mounted " in ntfs_volume_rename()
1926 return -1; in ntfs_volume_rename()
1935 return -1; in ntfs_volume_rename()
1938 na = ntfs_attr_open(vol->vol_ni, AT_VOLUME_NAME, AT_UNNAMED, 0); in ntfs_volume_rename()
1948 if (ntfs_attr_add(vol->vol_ni, AT_VOLUME_NAME, AT_UNNAMED, 0, in ntfs_volume_rename()
1967 if (na->data_size != label_len) { in ntfs_volume_rename()
1978 if (written == -1) { in ntfs_volume_rename()
1996 if (new_vol_name_len == -1) { in ntfs_volume_rename()
2002 old_vol_name = vol->vol_name; in ntfs_volume_rename()
2003 vol->vol_name = new_vol_name; in ntfs_volume_rename()
2012 return err ? -1 : 0; in ntfs_volume_rename()