• Home
  • Raw
  • Download

Lines Matching +full:translate +full:- +full:errno

2  * reparse.c - Processing of reparse points
4 * This module is part of ntfs-3g library
6 * Copyright (c) 2008-2021 Jean-Pierre Andre
19 * along with this program (in the main directory of the NTFS-3G
21 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include <errno.h>
116 static const char mappingdir[] = ".NTFS-3G/";
122 * Should only be used to translate paths stored with case insensitivity
134 ntfs_volume *vol = dir_ni->vol; in ntfs_fix_file_name()
149 mref = (u64)-1; /* default return (not found) */ in ntfs_fix_file_name()
163 if ((cpuchar < vol->upcase_len) in ntfs_fix_file_name()
164 && (le16_to_cpu(vol->upcase[cpuchar]) < cpuchar)) in ntfs_fix_file_name()
165 find.attr.file_name[i] = vol->upcase[cpuchar]; in ntfs_fix_file_name()
169 olderrno = errno; in ntfs_fix_file_name()
171 if (errno == ENOENT) in ntfs_fix_file_name()
172 errno = olderrno; in ntfs_fix_file_name()
177 if (icx->entry && (icx->entry->ie_flags & INDEX_ENTRY_END)) in ntfs_fix_file_name()
179 entry = ntfs_index_next(icx->entry, icx); in ntfs_fix_file_name()
181 entry = icx->entry; in ntfs_fix_file_name()
183 found = &entry->key.file_name; in ntfs_fix_file_name()
187 found->file_name, found->file_name_length, in ntfs_fix_file_name()
189 vol->upcase, vol->upcase_len)) in ntfs_fix_file_name()
196 lemref = entry->indexed_file; in ntfs_fix_file_name()
198 if (NVolCaseSensitive(vol) || !vol->locase) { in ntfs_fix_file_name()
199 for (i=0; i<found->file_name_length; i++) in ntfs_fix_file_name()
200 uname[i] = found->file_name[i]; in ntfs_fix_file_name()
202 for (i=0; i<found->file_name_length; i++) in ntfs_fix_file_name()
203 uname[i] = vol->locase[le16_to_cpu(found->file_name[i])]; in ntfs_fix_file_name()
234 * Examine and translate the path, until we reach either in search_absolute()
235 * - the end, in search_absolute()
236 * - an unknown item in search_absolute()
237 * - a non-directory in search_absolute()
238 * - another reparse point, in search_absolute()
252 if (inum != (u64)-1) { in search_absolute()
260 && (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) in search_absolute()
261 && !(ni->flags & FILE_ATTR_REPARSE_POINT) in search_absolute()
264 && ((ni->mrec->flags & MFT_RECORD_IS_DIRECTORY ? isdir : !isdir) in search_absolute()
265 || (ni->flags & FILE_ATTR_REPARSE_POINT))) in search_absolute()
307 * Examine and translate the path, until we reach either in search_relative()
308 * - the end, in search_relative()
309 * - an unknown item in search_relative()
310 * - a non-directory in search_relative()
311 * - another reparse point, in search_relative()
317 while (curni && ok && !morelinks && (pos < (count - 1)) && --max) { in search_relative()
344 inum = (u64)-1; in search_relative()
348 || (inum == (u64)-1)) in search_relative()
351 curni = ntfs_inode_open(ni->vol, MREF(inum)); in search_relative()
355 if (curni->flags & FILE_ATTR_REPARSE_POINT) in search_relative()
366 && (ni->mrec->flags ^ curni->mrec->flags) in search_relative()
386 * Check whether a drive letter has been defined in .NTFS-3G
390 * -1 if there was an error (described by errno)
402 ret = -1; in ntfs_drive_letter()
408 *drive += 'A' - 'a'; in ntfs_drive_letter()
411 olderrno = errno; in ntfs_drive_letter()
416 if (errno == ENOENT) { in ntfs_drive_letter()
418 /* avoid errno pollution */ in ntfs_drive_letter()
419 errno = olderrno; in ntfs_drive_letter()
438 res = -EOPNOTSUPP; in ntfs_reparse_check_wsl()
439 switch (reparse->reparse_tag) { in ntfs_reparse_check_wsl()
444 if (!reparse->reparse_data_length in ntfs_reparse_check_wsl()
445 && (ni->flags & FILE_ATTRIBUTE_RECALL_ON_OPEN)) in ntfs_reparse_check_wsl()
452 errno = EOPNOTSUPP; in ntfs_reparse_check_wsl()
459 * Microsoft reparse points have an 8-byte header whereas
460 * non-Microsoft reparse points have a 24-byte header. In each case,
461 * 'reparse_data_length' must equal the number of non-header bytes.
480 && (reparse_attr->reparse_tag != IO_REPARSE_TAG_RESERVED_ZERO) in valid_reparse_data()
481 && (((size_t)le16_to_cpu(reparse_attr->reparse_data_length) in valid_reparse_data()
483 + ((reparse_attr->reparse_tag & in valid_reparse_data()
486 switch (reparse_attr->reparse_tag) { in valid_reparse_data()
494 reparse_attr->reparse_data; in valid_reparse_data()
495 offs = le16_to_cpu(mount_point_data->subst_name_offset); in valid_reparse_data()
496 lth = le16_to_cpu(mount_point_data->subst_name_length); in valid_reparse_data()
498 if (!(ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) in valid_reparse_data()
511 reparse_attr->reparse_data; in valid_reparse_data()
512 offs = le16_to_cpu(symlink_data->subst_name_offset); in valid_reparse_data()
513 lth = le16_to_cpu(symlink_data->subst_name_length); in valid_reparse_data()
521 reparse_attr->reparse_data; in valid_reparse_data()
522 if ((le16_to_cpu(reparse_attr->reparse_data_length) in valid_reparse_data()
523 <= sizeof(wsl_reparse_data->type)) in valid_reparse_data()
524 || (wsl_reparse_data->type != const_cpu_to_le32(2))) in valid_reparse_data()
531 if (reparse_attr->reparse_data_length in valid_reparse_data()
532 || !(ni->flags & FILE_ATTRIBUTE_RECALL_ON_OPEN)) in valid_reparse_data()
540 errno = EINVAL; in valid_reparse_data()
545 * Check and translate the target of a junction point or
551 * - either to the target if found on the same device.
552 * - or into the /.NTFS-3G directory for the user to define
553 * In the first situation, the target is translated to case-sensitive path.
556 * or NULL if there were some problem, as described by errno
572 * where \ is an individual char and x a non-null char in ntfs_get_fulllink()
587 && (junction[count-1] == const_cpu_to_le16('\\'))) in ntfs_get_fulllink()
600 target = search_absolute(vol,&junction[7],count - 7, isdir); in ntfs_get_fulllink()
615 * link to /.NTFS-3G/target which the user can in ntfs_get_fulllink()
621 (kind == VOL_JUNCTION ? count - 5 : count - 4), in ntfs_get_fulllink()
632 target[0] += 'A' - 'a'; in ntfs_get_fulllink()
649 * Check and translate the target of an absolute symbolic link.
654 * - either to the target if found on the same device.
655 * - or into the /.NTFS-3G directory for the user to define
656 * In the first situation, the target is translated to case-sensitive path.
659 * or NULL if there were some problem, as described by errno
676 * where \ is an individual char and x a non-null char in ntfs_get_abslink()
705 count - 1, isdir); in ntfs_get_abslink()
708 count - 3, isdir); in ntfs_get_abslink()
711 strlen(vol->abs_mnt_point) in ntfs_get_abslink()
714 strcpy(fulltarget,vol->abs_mnt_point); in ntfs_get_abslink()
723 * link to /.NTFS-3G/target which the user can in ntfs_get_abslink()
738 target[0] += 'A' - 'a'; in ntfs_get_abslink()
740 strlen(vol->abs_mnt_point) in ntfs_get_abslink()
743 strcpy(fulltarget,vol->abs_mnt_point); in ntfs_get_abslink()
756 * Check and translate the target of a relative symbolic link.
761 * translated to a case-sensitive path.
764 * or NULL if there were some problem, as described by errno
780 * if some error occurred, as described by errno
781 * errno is EOPNOTSUPP if the reparse point is not a valid
803 isdir = (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) in ntfs_make_symlink()
805 vol = ni->vol; in ntfs_make_symlink()
810 switch (reparse_attr->reparse_tag) { in ntfs_make_symlink()
813 reparse_attr->reparse_data; in ntfs_make_symlink()
814 offs = le16_to_cpu(mount_point_data->subst_name_offset); in ntfs_make_symlink()
815 lth = le16_to_cpu(mount_point_data->subst_name_length); in ntfs_make_symlink()
818 (ntfschar*)&mount_point_data->path_buffer[offs], in ntfs_make_symlink()
825 reparse_attr->reparse_data; in ntfs_make_symlink()
826 offs = le16_to_cpu(symlink_data->subst_name_offset); in ntfs_make_symlink()
827 lth = le16_to_cpu(symlink_data->subst_name_length); in ntfs_make_symlink()
828 p = (ntfschar*)&symlink_data->path_buffer[offs]; in ntfs_make_symlink()
844 p--; in ntfs_make_symlink()
848 if (!(symlink_data->flags in ntfs_make_symlink()
858 if (symlink_data->flags in ntfs_make_symlink()
868 if (symlink_data->flags in ntfs_make_symlink()
880 reparse_attr->reparse_data; in ntfs_make_symlink()
881 if (wsl_link_data->type == const_cpu_to_le32(2)) { in ntfs_make_symlink()
883 reparse_attr->reparse_data_length) in ntfs_make_symlink()
884 - sizeof(wsl_link_data->type); in ntfs_make_symlink()
887 memcpy(target, wsl_link_data->link, in ntfs_make_symlink()
898 errno = EOPNOTSUPP; in ntfs_make_symlink()
920 switch (reparse_attr->reparse_tag) { in ntfs_possible_symlink()
937 * -1 if failure, explained by errno
948 seqn = ni->mrec->sequence_number; in set_reparse_index()
949 file_id_cpu = MK_MREF(ni->mft_no,le16_to_cpu(seqn)); in set_reparse_index()
976 * -1 if failure, explained by errno
989 ret = na->data_size; in remove_reparse_index()
994 seqn = na->ni->mrec->sequence_number; in remove_reparse_index()
995 file_id_cpu = MK_MREF(na->ni->mft_no,le16_to_cpu(seqn)); in remove_reparse_index()
1002 ret = -1; in remove_reparse_index()
1004 ret = -1; in remove_reparse_index()
1005 errno = ENODATA; in remove_reparse_index()
1015 * or NULL if an error occurred (errno tells why)
1027 /* do not use path_name_to inode - could reopen root */ in open_reparse_index()
1032 if (inum != (u64)-1) in open_reparse_index()
1054 * -1 if failure, explained by errno
1075 res = -1; in update_reparse_data()
1086 errno = EIO; in update_reparse_data()
1087 res = -1; in update_reparse_data()
1092 ((const REPARSE_POINT*)value)->reparse_tag) in update_reparse_data()
1107 res = -1; in update_reparse_data()
1116 * -1 if failure, explained by errno
1132 * and un-index it in ntfs_delete_reparse_index()
1134 xr = open_reparse_index(ni->vol); in ntfs_delete_reparse_index()
1137 res = -1; in ntfs_delete_reparse_index()
1138 xrni = xr->ni; in ntfs_delete_reparse_index()
1164 if (ni->flags & FILE_ATTR_REPARSE_POINT) { in ntfs_get_ntfs_reparse_data()
1173 errno = EINVAL; in ntfs_get_ntfs_reparse_data()
1178 errno = ENODATA; in ntfs_get_ntfs_reparse_data()
1180 return (attr_size ? (int)attr_size : -errno); in ntfs_get_ntfs_reparse_data()
1188 * Returns 0, or -1 if there is a problem
1206 xr = open_reparse_index(ni->vol); in ntfs_set_ntfs_reparse_data()
1216 if (ni->vol->major_ver >= 3) { in ntfs_set_ntfs_reparse_data()
1222 ni->flags |= in ntfs_set_ntfs_reparse_data()
1228 errno = EOPNOTSUPP; in ntfs_set_ntfs_reparse_data()
1229 res = -1; in ntfs_set_ntfs_reparse_data()
1232 errno = ENODATA; in ntfs_set_ntfs_reparse_data()
1233 res = -1; in ntfs_set_ntfs_reparse_data()
1237 errno = EEXIST; in ntfs_set_ntfs_reparse_data()
1238 res = -1; in ntfs_set_ntfs_reparse_data()
1245 xrni = xr->ni; in ntfs_set_ntfs_reparse_data()
1251 res = -1; in ntfs_set_ntfs_reparse_data()
1254 errno = EINVAL; in ntfs_set_ntfs_reparse_data()
1255 res = -1; in ntfs_set_ntfs_reparse_data()
1257 return (res ? -1 : 0); in ntfs_set_ntfs_reparse_data()
1263 * Returns 0, or -1 if there is a problem
1284 xr = open_reparse_index(ni->vol); in ntfs_remove_ntfs_reparse_data()
1288 res = -1; in ntfs_remove_ntfs_reparse_data()
1293 ni->flags &= in ntfs_remove_ntfs_reparse_data()
1311 xrni = xr->ni; in ntfs_remove_ntfs_reparse_data()
1317 olderrno = errno; in ntfs_remove_ntfs_reparse_data()
1319 /* avoid errno pollution */ in ntfs_remove_ntfs_reparse_data()
1320 if (errno == ENOENT) in ntfs_remove_ntfs_reparse_data()
1321 errno = olderrno; in ntfs_remove_ntfs_reparse_data()
1323 errno = ENODATA; in ntfs_remove_ntfs_reparse_data()
1324 res = -1; in ntfs_remove_ntfs_reparse_data()
1328 errno = EINVAL; in ntfs_remove_ntfs_reparse_data()
1329 res = -1; in ntfs_remove_ntfs_reparse_data()
1331 return (res ? -1 : 0); in ntfs_remove_ntfs_reparse_data()
1348 res = -1; in ntfs_reparse_set_wsl_symlink()
1352 reparse_len = sizeof(REPARSE_POINT) + sizeof(data->type) + len; in ntfs_reparse_set_wsl_symlink()
1356 reparse->reparse_data; in ntfs_reparse_set_wsl_symlink()
1357 reparse->reparse_tag = IO_REPARSE_TAG_LX_SYMLINK; in ntfs_reparse_set_wsl_symlink()
1358 reparse->reparse_data_length in ntfs_reparse_set_wsl_symlink()
1359 = cpu_to_le16(sizeof(data->type) + len); in ntfs_reparse_set_wsl_symlink()
1360 reparse->reserved = const_cpu_to_le16(0); in ntfs_reparse_set_wsl_symlink()
1361 data->type = const_cpu_to_le32(2); in ntfs_reparse_set_wsl_symlink()
1362 memcpy(data->link, utarget, len); in ntfs_reparse_set_wsl_symlink()
1385 res = -1; in ntfs_reparse_set_wsl_not_symlink()
1401 len = -1; in ntfs_reparse_set_wsl_not_symlink()
1402 errno = EOPNOTSUPP; in ntfs_reparse_set_wsl_not_symlink()
1409 reparse->reparse_tag = reparse_tag; in ntfs_reparse_set_wsl_not_symlink()
1410 reparse->reparse_data_length = cpu_to_le16(len); in ntfs_reparse_set_wsl_not_symlink()
1411 reparse->reserved = const_cpu_to_le16(0); in ntfs_reparse_set_wsl_not_symlink()
1425 * NULL otherwise (with errno set according to the cause).
1442 errno = EINVAL; in ntfs_get_reparse_point()
1445 errno = EINVAL; in ntfs_get_reparse_point()