Lines Matching full:attribute
2 * attrib.c - NTFS attribute operations. Part of the Linux-NTFS project.
42 * @ctx: active attribute search context if present or NULL if not
54 * attribute on return as on entry. However, the actual pointers in @ctx may
68 * the attribute has zero allocated size, i.e. there simply is no runlist.
128 * If we already have the attribute extent containing @vcn in in ntfs_map_runlist_nolock()
132 * the right attribute extent. in ntfs_map_runlist_nolock()
159 * needed attribute extent. in ntfs_map_runlist_nolock()
199 * If there is no attribute list, restoring the search context in ntfs_map_runlist_nolock()
201 * the caller supplied context. If there is an attribute list, in ntfs_map_runlist_nolock()
313 * @ni: ntfs inode of the attribute whose runlist to search
317 * Find the virtual cluster number @vcn in the runlist of the ntfs attribute
321 * If the @vcn is not mapped yet, the attempt is made to map the attribute
411 * @ctx: active attribute search context if present or NULL if not
416 * If the @vcn is not mapped yet, the attempt is made to map the attribute
427 * attribute on return as on entry. However, the actual pointers in @ctx may
533 * ntfs_attr_find - find (next) attribute in mft record
534 * @type: attribute type to find
535 * @name: attribute name to find (optional, i.e. NULL means don't care)
536 * @name_len: attribute name length (only needed if @name present)
538 * @val: attribute value to find (optional, resident attributes only)
539 * @val_len: attribute value length
540 * @ctx: search context with mft record and attribute to search from
547 * attribute of @type, optionally @name and @val.
549 * If the attribute is found, ntfs_attr_find() returns 0 and @ctx->attr will
550 * point to the found attribute.
552 * If the attribute is not found, ntfs_attr_find() returns -ENOENT and
553 * @ctx->attr will point to the attribute before which the attribute being
569 * If @name is not present (NULL), we assume that the unnamed attribute is
572 * Finally, the resident attribute value @val is looked for, if present. If
576 * presence of an attribute list attribute (unless it is the one being searched
577 * for, obviously). If you need to take attribute lists into consideration,
581 * attribute list attribute only. - Note that it is possible that the first
582 * extent is only in the attribute list while the last extent is in the base
586 * Warning: Never use @val when looking for attribute types which can be
600 * attribute following that, if @ctx->is_first is 'true'. in ntfs_attr_find()
622 * missing, assume we want an unnamed attribute. in ntfs_attr_find()
625 /* The search failed if the found attribute is named. */ in ntfs_attr_find()
640 * matching attribute. in ntfs_attr_find()
658 * The names match or @name not present and attribute is in ntfs_attr_find()
659 * unnamed. If no @val specified, we have found the attribute in ntfs_attr_find()
673 * If @val collates before the current attribute's in ntfs_attr_find()
674 * value, there is no matching attribute. in ntfs_attr_find()
695 * load_attribute_list - load an attribute list into memory
697 * @runlist: runlist of the attribute list
700 * @initialized_size: initialized size of the attribute list
738 ntfs_error(sb, "Cannot read attribute list since runlist is " in load_attribute_list()
748 /* The attribute list cannot be sparse. */ in load_attribute_list()
751 "read attribute list."); in load_attribute_list()
764 "read attribute list."); in load_attribute_list()
787 * Note: The attribute list can be smaller than its allocation in load_attribute_list()
800 ntfs_error(sb, "Attribute list buffer overflow. Read attribute list " in load_attribute_list()
808 * ntfs_external_attr_find - find an attribute in the attribute list of an inode
809 * @type: attribute type to find
810 * @name: attribute name to find (optional, i.e. NULL means don't care)
811 * @name_len: attribute name length (only needed if @name present)
814 * @val: attribute value to find (optional, resident attributes only)
815 * @val_len: attribute value length
816 * @ctx: search context with mft record and attribute to search from
821 * Find an attribute by searching the attribute list for the corresponding
822 * attribute list entry. Having found the entry, map the mft record if the
823 * attribute is in a different mft record/inode, ntfs_attr_find() the attribute
831 * After finishing with the attribute/mft record you need to call
835 * If the attribute is found, ntfs_external_attr_find() returns 0 and
836 * @ctx->attr will point to the found attribute. @ctx->mrec will point to the
838 * the attribute list entry for the attribute.
840 * If the attribute is not found, ntfs_external_attr_find() returns -ENOENT and
841 * @ctx->attr will point to the attribute in the base mft record before which
842 * the attribute being searched for would need to be inserted if such an action
844 * @ctx->attr is located and @ctx->al_entry will point to the attribute list
845 * entry of the attribute before which the attribute being searched for would
848 * Thus to insert the not found attribute, one wants to add the attribute to
850 * attribute should be placed in a newly allocated extent mft record. The
851 * attribute list entry for the inserted attribute should be inserted in the
852 * attribute list attribute at @ctx->al_entry.
890 * Iterate over entries in attribute list starting at @ctx->al_entry, in ntfs_external_attr_find()
905 /* Catch the end of the attribute list. */ in ntfs_external_attr_find()
921 * missing, assume we want an unnamed attribute. in ntfs_external_attr_find()
937 * matching attribute. in ntfs_external_attr_find()
961 * The names match or @name not present and attribute is in ntfs_external_attr_find()
963 * next attribute list entry still fits @lowest_vcn. Otherwise in ntfs_external_attr_find()
984 "reference in attribute list " in ntfs_external_attr_find()
1026 * mft record containing the attribute represented by the in ntfs_external_attr_find()
1031 * attribute in this mft record but this would be less in ntfs_external_attr_find()
1033 * the attribute instance numbers for example which become in ntfs_external_attr_find()
1034 * important when one plays with attribute lists. Also, in ntfs_external_attr_find()
1035 * because a proper match has been found in the attribute list in ntfs_external_attr_find()
1056 * attribute list entry and the attribute record, there is in ntfs_external_attr_find()
1080 /* Proceed to the next attribute in the current mft record. */ in ntfs_external_attr_find()
1086 "attribute list attribute.%s", base_ni->mft_no, in ntfs_external_attr_find()
1111 * The attribute was not found. Before we return, we want to ensure in ntfs_external_attr_find()
1113 * attribute should be inserted in the base mft record. Since we also in ntfs_external_attr_find()
1135 * keep enumerating until we get an attribute not found response (or in ntfs_external_attr_find()
1136 * another error), otherwise we would keep returning the same attribute in ntfs_external_attr_find()
1149 * ntfs_attr_lookup - find an attribute in an ntfs inode
1150 * @type: attribute type to find
1151 * @name: attribute name to find (optional, i.e. NULL means don't care)
1152 * @name_len: attribute name length (only needed if @name present)
1155 * @val: attribute value to find (optional, resident attributes only)
1156 * @val_len: attribute value length
1157 * @ctx: search context with mft record and attribute to search from
1159 * Find an attribute in an ntfs inode. On first search @ctx->ntfs_ino must
1163 * This function transparently handles attribute lists and @ctx is used to
1166 * After finishing with the attribute/mft record you need to call
1172 * When 0, @ctx->attr is the found attribute and it is in mft record
1173 * @ctx->mrec. If an attribute list attribute is present, @ctx->al_entry is
1174 * the attribute list entry of the found attribute.
1176 * When -ENOENT, @ctx->attr is the attribute which collates just after the
1177 * attribute being searched for, i.e. if one wants to add the attribute to the
1178 * mft record this is the correct place to insert it into. If an attribute
1179 * list attribute is present, @ctx->al_entry is the attribute list entry which
1180 * collates just after the attribute list entry of the attribute being searched
1181 * for, i.e. if one wants to add the attribute to the mft record this is the
1182 * correct place to insert its attribute list entry into.
1210 * ntfs_attr_init_search_ctx - initialize an attribute search context
1211 * @ctx: attribute search context to initialize
1215 * Initialize the attribute search context @ctx with @ni and @mrec.
1231 * ntfs_attr_reinit_search_ctx - reinitialize an attribute search context
1232 * @ctx: attribute search context to reinitialize
1234 * Reinitialize the attribute search context @ctx, unmapping an associated
1237 * This is used when a search for a new attribute is being started to reset
1243 /* No attribute list. */ in ntfs_attr_reinit_search_ctx()
1254 } /* Attribute list. */ in ntfs_attr_reinit_search_ctx()
1262 * ntfs_attr_get_search_ctx - allocate/initialize a new attribute search context
1266 * Allocate a new attribute search context, initialize it with @ni and @mrec,
1280 * ntfs_attr_put_search_ctx - release an attribute search context
1281 * @ctx: attribute search context to free
1283 * Release the attribute search context @ctx, unmapping an associated extent
1297 * ntfs_attr_find_in_attrdef - find an attribute in the $AttrDef system file
1298 * @vol: ntfs volume to which the attribute belongs
1299 * @type: attribute type which to find
1301 * Search for the attribute definition record corresponding to the attribute
1304 * Return the attribute type definition record if found and NULL if not found.
1318 /* We found the attribute; return it. */ in ntfs_attr_find_in_attrdef()
1324 /* Attribute not found. */ in ntfs_attr_find_in_attrdef()
1325 ntfs_debug("Attribute type 0x%x not found in $AttrDef.", in ntfs_attr_find_in_attrdef()
1331 * ntfs_attr_size_bounds_check - check a size of an attribute type for validity
1332 * @vol: ntfs volume to which the attribute belongs
1333 * @type: attribute type which to check
1336 * Check whether the @size in bytes is valid for an attribute of @type on the
1339 * Return 0 if valid, -ERANGE if not valid, or -ENOENT if the attribute is not
1354 /* Get the $AttrDef entry for the attribute @type. */ in ntfs_attr_size_bounds_check()
1368 * ntfs_attr_can_be_non_resident - check if an attribute can be non-resident
1369 * @vol: ntfs volume to which the attribute belongs
1370 * @type: attribute type which to check
1372 * Check whether the attribute of @type on the ntfs volume @vol is allowed to
1375 * Return 0 if the attribute is allowed to be non-resident, -EPERM if not, and
1376 * -ENOENT if the attribute is not listed in $AttrDef.
1382 /* Find the attribute definition record in $AttrDef. */ in ntfs_attr_can_be_non_resident()
1393 * ntfs_attr_can_be_resident - check if an attribute can be resident
1394 * @vol: ntfs volume to which the attribute belongs
1395 * @type: attribute type which to check
1397 * Check whether the attribute of @type on the ntfs volume @vol is allowed to
1403 * Return 0 if the attribute is allowed to be non-resident and -EPERM if not.
1405 * Warning: In the system file $MFT the attribute $Bitmap must be non-resident
1418 * ntfs_attr_record_resize - resize an attribute record
1419 * @m: mft record containing attribute record
1420 * @a: attribute record to resize
1421 * @new_size: new size in bytes to which to resize the attribute record @a
1423 * Resize the attribute record @a, i.e. the resident part of the attribute, in
1441 /* If the actual attribute length has changed, move things around. */ in ntfs_attr_record_resize()
1462 * ntfs_resident_attr_value_resize - resize the value of a resident attribute
1463 * @m: mft record containing attribute record
1464 * @a: attribute record whose value to resize
1465 * @new_size: new size in bytes to which to resize the attribute value of @a
1467 * Resize the value of the attribute @a in the mft record @m to @new_size bytes.
1484 /* Resize the resident part of the attribute record. */ in ntfs_resident_attr_value_resize()
1489 * The resize succeeded! If we made the attribute value bigger, clear in ntfs_resident_attr_value_resize()
1496 /* Finally update the length of the attribute value. */ in ntfs_resident_attr_value_resize()
1502 * ntfs_attr_make_non_resident - convert a resident to a non-resident attribute
1503 * @ni: ntfs inode describing the attribute to convert
1504 * @data_size: size of the resident data to copy to the non-resident attribute
1506 * Convert the resident ntfs attribute described by the ntfs inode @ni to a
1509 * @data_size must be equal to the attribute value size. This is needed since
1517 * -EPERM - The attribute is not allowed to be non-resident.
1520 * -EINVAL - Attribute not defined on the volume.
1527 * again in case the attribute may then fit in a resident state so no need to
1530 * NOTE to self: No changes in the attribute list are required to move from
1531 * a resident to a non-resident attribute.
1552 /* Check that the attribute is allowed to be non-resident. */ in ntfs_attr_make_non_resident()
1556 ntfs_debug("Attribute is not allowed to be " in ntfs_attr_make_non_resident()
1559 ntfs_debug("Attribute not defined on the NTFS " in ntfs_attr_make_non_resident()
1584 /* Start by allocating clusters to hold the attribute value. */ in ntfs_attr_make_non_resident()
1649 * attribute record. in ntfs_attr_make_non_resident()
1654 * attribute value. in ntfs_attr_make_non_resident()
1668 /* Backup the attribute flag. */ in ntfs_attr_make_non_resident()
1670 /* Resize the resident part of the attribute record. */ in ntfs_attr_make_non_resident()
1675 * Convert the resident part of the attribute record to describe a in ntfs_attr_make_non_resident()
1676 * non-resident attribute. in ntfs_attr_make_non_resident()
1679 /* Move the attribute name if it exists and update the offset. */ in ntfs_attr_make_non_resident()
1703 /* Generate the mapping pairs array into the attribute record. */ in ntfs_attr_make_non_resident()
1711 /* Setup the in-memory attribute structure to be non-resident. */ in ntfs_attr_make_non_resident()
1756 /* Convert the attribute back into a resident attribute. */ in ntfs_attr_make_non_resident()
1758 /* Move the attribute name if it exists and update the offset. */ in ntfs_attr_make_non_resident()
1767 /* Resize the resident part of the attribute record. */ in ntfs_attr_make_non_resident()
1773 * If the old size is too small, truncate the attribute, in ntfs_attr_make_non_resident()
1783 "to non-resident attribute " in ntfs_attr_make_non_resident()
1785 "attribute type 0x%x from %i bytes to " in ntfs_attr_make_non_resident()
1793 !ni->name_len) ? "FILE": "ATTRIBUTE"); in ntfs_attr_make_non_resident()
1806 /* Copy the data from the page back to the attribute value. */ in ntfs_attr_make_non_resident()
1846 * ntfs_attr_extend_allocation - extend the allocated space of an attribute
1847 * @ni: ntfs inode of the attribute whose allocation to extend
1852 * Extend the allocated space of an attribute described by the ntfs inode @ni
1861 * of the attribute is extended to @new_data_size. Note that the i_size of the
1862 * vfs inode is not updated. Only the data size in the base attribute record
1867 * For resident attributes this involves resizing the attribute record and if
1869 * converting the attribute to a non-resident attribute which in turn involves
1870 * extending the allocation of a non-resident attribute as described below.
1875 * updating the mapping pairs array of the attribute. This in turn involves
1876 * resizing the attribute record and if necessary moving it and/or other
1877 * attributes into extent mft records and/or splitting the attribute record
1878 * into multiple extent attribute records.
1880 * Also, the attribute list attribute is updated if present and in some of the
1882 * an attribute list attribute is created if not already present.
1896 * attribute can be resized safely and so that it can for example be converted
1899 * TODO: At present attribute list attribute handling is not implemented.
1902 * than the $DATA attribute(s) of an uncompressed and unencrypted file.
1925 ntfs_debug("Entering for i_ino 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
1957 "of inode 0x%lx, attribute " in ntfs_attr_extend_allocation()
1961 "this attribute type.", in ntfs_attr_extend_allocation()
1966 "of inode 0x%lx, attribute " in ntfs_attr_extend_allocation()
1968 "attribute type is not " in ntfs_attr_extend_allocation()
2015 * just converted the attribute from resident to non-resident it is in ntfs_attr_extend_allocation()
2025 * We want the first attribute extent so that we can update the in ntfs_attr_extend_allocation()
2043 /* The total length of the attribute value. */ in ntfs_attr_extend_allocation()
2046 * Extend the attribute record to be able to store the new attribute in ntfs_attr_extend_allocation()
2078 * Not enough space in the mft record, try to make the attribute in ntfs_attr_extend_allocation()
2086 * permitted for this attribute type or there not being enough space, in ntfs_attr_extend_allocation()
2096 "inode 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
2098 "to non-resident attribute failed " in ntfs_attr_extend_allocation()
2113 "attribute value. This case is not " in ntfs_attr_extend_allocation()
2116 ntfs_error(vol->sb, "This attribute type may not be " in ntfs_attr_extend_allocation()
2127 * Both the attribute list attribute and the standard information in ntfs_attr_extend_allocation()
2128 * attribute must remain in the base inode. Thus, if this is one of in ntfs_attr_extend_allocation()
2141 // TODO: Attempt to move this attribute to an extent mft record, but in ntfs_attr_extend_allocation()
2142 // only if it is not already the only attribute in an mft record in in ntfs_attr_extend_allocation()
2158 * $DATA attribute and sparse attributes are enabled on the volume and in ntfs_attr_extend_allocation()
2178 /* If this attribute extent is not mapped, map it now. */ in ntfs_attr_extend_allocation()
2189 "of inode 0x%lx, attribute " in ntfs_attr_extend_allocation()
2209 * there are no valid LCNs in the attribute we let the cluster in ntfs_attr_extend_allocation()
2227 "inode 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
2240 "inode 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
2259 /* Find the runlist element with which the attribute extent starts. */ in ntfs_attr_extend_allocation()
2272 "inode 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
2280 /* Extend the attribute record to fit the bigger mapping pairs array. */ in ntfs_attr_extend_allocation()
2294 "record for the extended attribute " in ntfs_attr_extend_allocation()
2308 "inode 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
2319 * We now have extended the allocated size of the attribute. Reflect in ntfs_attr_extend_allocation()
2320 * this in the ntfs_inode structure and the attribute record. in ntfs_attr_extend_allocation()
2324 * We are not in the first attribute extent, switch to it, but in ntfs_attr_extend_allocation()
2346 * regular files, and only for their $DATA attribute(s). in ntfs_attr_extend_allocation()
2378 "of inode 0x%lx, attribute type 0x%x, because " in ntfs_attr_extend_allocation()
2379 "lookup of first attribute extent failed with " in ntfs_attr_extend_allocation()
2388 ntfs_error(vol->sb, "Failed to find last attribute extent of " in ntfs_attr_extend_allocation()
2389 "attribute in error code path. Run chkdsk to " in ntfs_attr_extend_allocation()
2410 * base attribute extent which chkdsk should be able to fix. in ntfs_attr_extend_allocation()
2429 * longer valid, we cannot resize the attribute record or build the in ntfs_attr_extend_allocation()
2436 "restore attribute search context" : in ntfs_attr_extend_allocation()
2437 "truncate attribute runlist"); in ntfs_attr_extend_allocation()
2441 ntfs_error(vol->sb, "Failed to restore attribute " in ntfs_attr_extend_allocation()
2474 * ntfs_attr_set - fill (a part of) an attribute with a byte
2475 * @ni: ntfs inode describing the attribute to fill
2476 * @ofs: offset inside the attribute at which to start to fill
2478 * @val: the unsigned 8-bit value with which to fill the attribute
2480 * Fill @cnt bytes of the attribute described by the ntfs inode @ni starting at
2481 * byte offset @ofs inside the attribute with the constant byte @val.
2483 * This function is effectively like memset() applied to an ntfs attribute.
2485 * to the ntfs attribute and it marks them dirty after doing the memset().
2490 * that @ofs + @cnt were outside the end of the attribute and no write was
2523 ntfs_error(vol->sb, "Request exceeds end of attribute."); in ntfs_attr_set()