Lines Matching full:attribute
3 * attrib.c - NTFS attribute operations. Part of the Linux-NTFS project.
28 * @ctx: active attribute search context if present or NULL if not
40 * attribute on return as on entry. However, the actual pointers in @ctx may
54 * the attribute has zero allocated size, i.e. there simply is no runlist.
114 * If we already have the attribute extent containing @vcn in in ntfs_map_runlist_nolock()
118 * the right attribute extent. in ntfs_map_runlist_nolock()
145 * needed attribute extent. in ntfs_map_runlist_nolock()
185 * If there is no attribute list, restoring the search context in ntfs_map_runlist_nolock()
187 * the caller supplied context. If there is an attribute list, in ntfs_map_runlist_nolock()
299 * @ni: ntfs inode of the attribute whose runlist to search
303 * Find the virtual cluster number @vcn in the runlist of the ntfs attribute
307 * If the @vcn is not mapped yet, the attempt is made to map the attribute
397 * @ctx: active attribute search context if present or NULL if not
402 * If the @vcn is not mapped yet, the attempt is made to map the attribute
413 * attribute on return as on entry. However, the actual pointers in @ctx may
519 * ntfs_attr_find - find (next) attribute in mft record
520 * @type: attribute type to find
521 * @name: attribute name to find (optional, i.e. NULL means don't care)
522 * @name_len: attribute name length (only needed if @name present)
524 * @val: attribute value to find (optional, resident attributes only)
525 * @val_len: attribute value length
526 * @ctx: search context with mft record and attribute to search from
533 * attribute of @type, optionally @name and @val.
535 * If the attribute is found, ntfs_attr_find() returns 0 and @ctx->attr will
536 * point to the found attribute.
538 * If the attribute is not found, ntfs_attr_find() returns -ENOENT and
539 * @ctx->attr will point to the attribute before which the attribute being
555 * If @name is not present (NULL), we assume that the unnamed attribute is
558 * Finally, the resident attribute value @val is looked for, if present. If
562 * presence of an attribute list attribute (unless it is the one being searched
563 * for, obviously). If you need to take attribute lists into consideration,
567 * attribute list attribute only. - Note that it is possible that the first
568 * extent is only in the attribute list while the last extent is in the base
572 * Warning: Never use @val when looking for attribute types which can be
586 * attribute following that, if @ctx->is_first is 'true'. in ntfs_attr_find()
608 * missing, assume we want an unnamed attribute. in ntfs_attr_find()
611 /* The search failed if the found attribute is named. */ in ntfs_attr_find()
626 * matching attribute. in ntfs_attr_find()
644 * The names match or @name not present and attribute is in ntfs_attr_find()
645 * unnamed. If no @val specified, we have found the attribute in ntfs_attr_find()
659 * If @val collates before the current attribute's in ntfs_attr_find()
660 * value, there is no matching attribute. in ntfs_attr_find()
681 * load_attribute_list - load an attribute list into memory
683 * @runlist: runlist of the attribute list
686 * @initialized_size: initialized size of the attribute list
724 ntfs_error(sb, "Cannot read attribute list since runlist is " in load_attribute_list()
734 /* The attribute list cannot be sparse. */ in load_attribute_list()
737 "read attribute list."); in load_attribute_list()
750 "read attribute list."); in load_attribute_list()
773 * Note: The attribute list can be smaller than its allocation in load_attribute_list()
786 ntfs_error(sb, "Attribute list buffer overflow. Read attribute list " in load_attribute_list()
794 * ntfs_external_attr_find - find an attribute in the attribute list of an inode
795 * @type: attribute type to find
796 * @name: attribute name to find (optional, i.e. NULL means don't care)
797 * @name_len: attribute name length (only needed if @name present)
800 * @val: attribute value to find (optional, resident attributes only)
801 * @val_len: attribute value length
802 * @ctx: search context with mft record and attribute to search from
807 * Find an attribute by searching the attribute list for the corresponding
808 * attribute list entry. Having found the entry, map the mft record if the
809 * attribute is in a different mft record/inode, ntfs_attr_find() the attribute
817 * After finishing with the attribute/mft record you need to call
821 * If the attribute is found, ntfs_external_attr_find() returns 0 and
822 * @ctx->attr will point to the found attribute. @ctx->mrec will point to the
824 * the attribute list entry for the attribute.
826 * If the attribute is not found, ntfs_external_attr_find() returns -ENOENT and
827 * @ctx->attr will point to the attribute in the base mft record before which
828 * the attribute being searched for would need to be inserted if such an action
830 * @ctx->attr is located and @ctx->al_entry will point to the attribute list
831 * entry of the attribute before which the attribute being searched for would
834 * Thus to insert the not found attribute, one wants to add the attribute to
836 * attribute should be placed in a newly allocated extent mft record. The
837 * attribute list entry for the inserted attribute should be inserted in the
838 * attribute list attribute at @ctx->al_entry.
876 * Iterate over entries in attribute list starting at @ctx->al_entry, in ntfs_external_attr_find()
891 /* Catch the end of the attribute list. */ in ntfs_external_attr_find()
907 * missing, assume we want an unnamed attribute. in ntfs_external_attr_find()
923 * matching attribute. in ntfs_external_attr_find()
947 * The names match or @name not present and attribute is in ntfs_external_attr_find()
949 * next attribute list entry still fits @lowest_vcn. Otherwise in ntfs_external_attr_find()
970 "reference in attribute list " in ntfs_external_attr_find()
1012 * mft record containing the attribute represented by the in ntfs_external_attr_find()
1017 * attribute in this mft record but this would be less in ntfs_external_attr_find()
1019 * the attribute instance numbers for example which become in ntfs_external_attr_find()
1020 * important when one plays with attribute lists. Also, in ntfs_external_attr_find()
1021 * because a proper match has been found in the attribute list in ntfs_external_attr_find()
1042 * attribute list entry and the attribute record, there is in ntfs_external_attr_find()
1066 /* Proceed to the next attribute in the current mft record. */ in ntfs_external_attr_find()
1072 "attribute list attribute.%s", base_ni->mft_no, in ntfs_external_attr_find()
1097 * The attribute was not found. Before we return, we want to ensure in ntfs_external_attr_find()
1099 * attribute should be inserted in the base mft record. Since we also in ntfs_external_attr_find()
1121 * keep enumerating until we get an attribute not found response (or in ntfs_external_attr_find()
1122 * another error), otherwise we would keep returning the same attribute in ntfs_external_attr_find()
1135 * ntfs_attr_lookup - find an attribute in an ntfs inode
1136 * @type: attribute type to find
1137 * @name: attribute name to find (optional, i.e. NULL means don't care)
1138 * @name_len: attribute name length (only needed if @name present)
1141 * @val: attribute value to find (optional, resident attributes only)
1142 * @val_len: attribute value length
1143 * @ctx: search context with mft record and attribute to search from
1145 * Find an attribute in an ntfs inode. On first search @ctx->ntfs_ino must
1149 * This function transparently handles attribute lists and @ctx is used to
1152 * After finishing with the attribute/mft record you need to call
1158 * When 0, @ctx->attr is the found attribute and it is in mft record
1159 * @ctx->mrec. If an attribute list attribute is present, @ctx->al_entry is
1160 * the attribute list entry of the found attribute.
1162 * When -ENOENT, @ctx->attr is the attribute which collates just after the
1163 * attribute being searched for, i.e. if one wants to add the attribute to the
1164 * mft record this is the correct place to insert it into. If an attribute
1165 * list attribute is present, @ctx->al_entry is the attribute list entry which
1166 * collates just after the attribute list entry of the attribute being searched
1167 * for, i.e. if one wants to add the attribute to the mft record this is the
1168 * correct place to insert its attribute list entry into.
1196 * ntfs_attr_init_search_ctx - initialize an attribute search context
1197 * @ctx: attribute search context to initialize
1201 * Initialize the attribute search context @ctx with @ni and @mrec.
1217 * ntfs_attr_reinit_search_ctx - reinitialize an attribute search context
1218 * @ctx: attribute search context to reinitialize
1220 * Reinitialize the attribute search context @ctx, unmapping an associated
1223 * This is used when a search for a new attribute is being started to reset
1229 /* No attribute list. */ in ntfs_attr_reinit_search_ctx()
1240 } /* Attribute list. */ in ntfs_attr_reinit_search_ctx()
1248 * ntfs_attr_get_search_ctx - allocate/initialize a new attribute search context
1252 * Allocate a new attribute search context, initialize it with @ni and @mrec,
1266 * ntfs_attr_put_search_ctx - release an attribute search context
1267 * @ctx: attribute search context to free
1269 * Release the attribute search context @ctx, unmapping an associated extent
1283 * ntfs_attr_find_in_attrdef - find an attribute in the $AttrDef system file
1284 * @vol: ntfs volume to which the attribute belongs
1285 * @type: attribute type which to find
1287 * Search for the attribute definition record corresponding to the attribute
1290 * Return the attribute type definition record if found and NULL if not found.
1304 /* We found the attribute; return it. */ in ntfs_attr_find_in_attrdef()
1310 /* Attribute not found. */ in ntfs_attr_find_in_attrdef()
1311 ntfs_debug("Attribute type 0x%x not found in $AttrDef.", in ntfs_attr_find_in_attrdef()
1317 * ntfs_attr_size_bounds_check - check a size of an attribute type for validity
1318 * @vol: ntfs volume to which the attribute belongs
1319 * @type: attribute type which to check
1322 * Check whether the @size in bytes is valid for an attribute of @type on the
1325 * Return 0 if valid, -ERANGE if not valid, or -ENOENT if the attribute is not
1340 /* Get the $AttrDef entry for the attribute @type. */ in ntfs_attr_size_bounds_check()
1354 * ntfs_attr_can_be_non_resident - check if an attribute can be non-resident
1355 * @vol: ntfs volume to which the attribute belongs
1356 * @type: attribute type which to check
1358 * Check whether the attribute of @type on the ntfs volume @vol is allowed to
1361 * Return 0 if the attribute is allowed to be non-resident, -EPERM if not, and
1362 * -ENOENT if the attribute is not listed in $AttrDef.
1368 /* Find the attribute definition record in $AttrDef. */ in ntfs_attr_can_be_non_resident()
1379 * ntfs_attr_can_be_resident - check if an attribute can be resident
1380 * @vol: ntfs volume to which the attribute belongs
1381 * @type: attribute type which to check
1383 * Check whether the attribute of @type on the ntfs volume @vol is allowed to
1389 * Return 0 if the attribute is allowed to be non-resident and -EPERM if not.
1391 * Warning: In the system file $MFT the attribute $Bitmap must be non-resident
1404 * ntfs_attr_record_resize - resize an attribute record
1405 * @m: mft record containing attribute record
1406 * @a: attribute record to resize
1407 * @new_size: new size in bytes to which to resize the attribute record @a
1409 * Resize the attribute record @a, i.e. the resident part of the attribute, in
1427 /* If the actual attribute length has changed, move things around. */ in ntfs_attr_record_resize()
1448 * ntfs_resident_attr_value_resize - resize the value of a resident attribute
1449 * @m: mft record containing attribute record
1450 * @a: attribute record whose value to resize
1451 * @new_size: new size in bytes to which to resize the attribute value of @a
1453 * Resize the value of the attribute @a in the mft record @m to @new_size bytes.
1470 /* Resize the resident part of the attribute record. */ in ntfs_resident_attr_value_resize()
1475 * The resize succeeded! If we made the attribute value bigger, clear in ntfs_resident_attr_value_resize()
1482 /* Finally update the length of the attribute value. */ in ntfs_resident_attr_value_resize()
1488 * ntfs_attr_make_non_resident - convert a resident to a non-resident attribute
1489 * @ni: ntfs inode describing the attribute to convert
1490 * @data_size: size of the resident data to copy to the non-resident attribute
1492 * Convert the resident ntfs attribute described by the ntfs inode @ni to a
1495 * @data_size must be equal to the attribute value size. This is needed since
1503 * -EPERM - The attribute is not allowed to be non-resident.
1506 * -EINVAL - Attribute not defined on the volume.
1513 * again in case the attribute may then fit in a resident state so no need to
1516 * NOTE to self: No changes in the attribute list are required to move from
1517 * a resident to a non-resident attribute.
1538 /* Check that the attribute is allowed to be non-resident. */ in ntfs_attr_make_non_resident()
1542 ntfs_debug("Attribute is not allowed to be " in ntfs_attr_make_non_resident()
1545 ntfs_debug("Attribute not defined on the NTFS " in ntfs_attr_make_non_resident()
1570 /* Start by allocating clusters to hold the attribute value. */ in ntfs_attr_make_non_resident()
1635 * attribute record. in ntfs_attr_make_non_resident()
1640 * attribute value. in ntfs_attr_make_non_resident()
1654 /* Backup the attribute flag. */ in ntfs_attr_make_non_resident()
1656 /* Resize the resident part of the attribute record. */ in ntfs_attr_make_non_resident()
1661 * Convert the resident part of the attribute record to describe a in ntfs_attr_make_non_resident()
1662 * non-resident attribute. in ntfs_attr_make_non_resident()
1665 /* Move the attribute name if it exists and update the offset. */ in ntfs_attr_make_non_resident()
1689 /* Generate the mapping pairs array into the attribute record. */ in ntfs_attr_make_non_resident()
1697 /* Setup the in-memory attribute structure to be non-resident. */ in ntfs_attr_make_non_resident()
1742 /* Convert the attribute back into a resident attribute. */ in ntfs_attr_make_non_resident()
1744 /* Move the attribute name if it exists and update the offset. */ in ntfs_attr_make_non_resident()
1753 /* Resize the resident part of the attribute record. */ in ntfs_attr_make_non_resident()
1759 * If the old size is too small, truncate the attribute, in ntfs_attr_make_non_resident()
1769 "to non-resident attribute " in ntfs_attr_make_non_resident()
1771 "attribute type 0x%x from %i bytes to " in ntfs_attr_make_non_resident()
1779 !ni->name_len) ? "FILE": "ATTRIBUTE"); in ntfs_attr_make_non_resident()
1792 /* Copy the data from the page back to the attribute value. */ in ntfs_attr_make_non_resident()
1832 * ntfs_attr_extend_allocation - extend the allocated space of an attribute
1833 * @ni: ntfs inode of the attribute whose allocation to extend
1838 * Extend the allocated space of an attribute described by the ntfs inode @ni
1847 * of the attribute is extended to @new_data_size. Note that the i_size of the
1848 * vfs inode is not updated. Only the data size in the base attribute record
1853 * For resident attributes this involves resizing the attribute record and if
1855 * converting the attribute to a non-resident attribute which in turn involves
1856 * extending the allocation of a non-resident attribute as described below.
1861 * updating the mapping pairs array of the attribute. This in turn involves
1862 * resizing the attribute record and if necessary moving it and/or other
1863 * attributes into extent mft records and/or splitting the attribute record
1864 * into multiple extent attribute records.
1866 * Also, the attribute list attribute is updated if present and in some of the
1868 * an attribute list attribute is created if not already present.
1882 * attribute can be resized safely and so that it can for example be converted
1885 * TODO: At present attribute list attribute handling is not implemented.
1888 * than the $DATA attribute(s) of an uncompressed and unencrypted file.
1911 ntfs_debug("Entering for i_ino 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
1943 "of inode 0x%lx, attribute " in ntfs_attr_extend_allocation()
1947 "this attribute type.", in ntfs_attr_extend_allocation()
1952 "of inode 0x%lx, attribute " in ntfs_attr_extend_allocation()
1954 "attribute type is not " in ntfs_attr_extend_allocation()
2001 * just converted the attribute from resident to non-resident it is in ntfs_attr_extend_allocation()
2011 * We want the first attribute extent so that we can update the in ntfs_attr_extend_allocation()
2029 /* The total length of the attribute value. */ in ntfs_attr_extend_allocation()
2032 * Extend the attribute record to be able to store the new attribute in ntfs_attr_extend_allocation()
2064 * Not enough space in the mft record, try to make the attribute in ntfs_attr_extend_allocation()
2072 * permitted for this attribute type or there not being enough space, in ntfs_attr_extend_allocation()
2082 "inode 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
2084 "to non-resident attribute failed " in ntfs_attr_extend_allocation()
2099 "attribute value. This case is not " in ntfs_attr_extend_allocation()
2102 ntfs_error(vol->sb, "This attribute type may not be " in ntfs_attr_extend_allocation()
2113 * Both the attribute list attribute and the standard information in ntfs_attr_extend_allocation()
2114 * attribute must remain in the base inode. Thus, if this is one of in ntfs_attr_extend_allocation()
2127 // TODO: Attempt to move this attribute to an extent mft record, but in ntfs_attr_extend_allocation()
2128 // only if it is not already the only attribute in an mft record in in ntfs_attr_extend_allocation()
2144 * $DATA attribute and sparse attributes are enabled on the volume and in ntfs_attr_extend_allocation()
2164 /* If this attribute extent is not mapped, map it now. */ in ntfs_attr_extend_allocation()
2175 "of inode 0x%lx, attribute " in ntfs_attr_extend_allocation()
2195 * there are no valid LCNs in the attribute we let the cluster in ntfs_attr_extend_allocation()
2213 "inode 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
2226 "inode 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
2245 /* Find the runlist element with which the attribute extent starts. */ in ntfs_attr_extend_allocation()
2258 "inode 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
2266 /* Extend the attribute record to fit the bigger mapping pairs array. */ in ntfs_attr_extend_allocation()
2280 "record for the extended attribute " in ntfs_attr_extend_allocation()
2294 "inode 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
2305 * We now have extended the allocated size of the attribute. Reflect in ntfs_attr_extend_allocation()
2306 * this in the ntfs_inode structure and the attribute record. in ntfs_attr_extend_allocation()
2310 * We are not in the first attribute extent, switch to it, but in ntfs_attr_extend_allocation()
2332 * regular files, and only for their $DATA attribute(s). in ntfs_attr_extend_allocation()
2364 "of inode 0x%lx, attribute type 0x%x, because " in ntfs_attr_extend_allocation()
2365 "lookup of first attribute extent failed with " in ntfs_attr_extend_allocation()
2374 ntfs_error(vol->sb, "Failed to find last attribute extent of " in ntfs_attr_extend_allocation()
2375 "attribute in error code path. Run chkdsk to " in ntfs_attr_extend_allocation()
2396 * base attribute extent which chkdsk should be able to fix. in ntfs_attr_extend_allocation()
2415 * longer valid, we cannot resize the attribute record or build the in ntfs_attr_extend_allocation()
2422 "restore attribute search context" : in ntfs_attr_extend_allocation()
2423 "truncate attribute runlist"); in ntfs_attr_extend_allocation()
2427 ntfs_error(vol->sb, "Failed to restore attribute " in ntfs_attr_extend_allocation()
2460 * ntfs_attr_set - fill (a part of) an attribute with a byte
2461 * @ni: ntfs inode describing the attribute to fill
2462 * @ofs: offset inside the attribute at which to start to fill
2464 * @val: the unsigned 8-bit value with which to fill the attribute
2466 * Fill @cnt bytes of the attribute described by the ntfs inode @ni starting at
2467 * byte offset @ofs inside the attribute with the constant byte @val.
2469 * This function is effectively like memset() applied to an ntfs attribute.
2471 * to the ntfs attribute and it marks them dirty after doing the memset().
2476 * that @ofs + @cnt were outside the end of the attribute and no write was
2509 ntfs_error(vol->sb, "Request exceeds end of attribute."); in ntfs_attr_set()