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()
603 /* check whether Attribute Record Header is within bounds */ in ntfs_attr_find()
632 * missing, assume we want an unnamed attribute. in ntfs_attr_find()
635 /* The search failed if the found attribute is named. */ in ntfs_attr_find()
650 * matching attribute. in ntfs_attr_find()
668 * The names match or @name not present and attribute is in ntfs_attr_find()
669 * unnamed. If no @val specified, we have found the attribute in ntfs_attr_find()
683 * If @val collates before the current attribute's in ntfs_attr_find()
684 * value, there is no matching attribute. in ntfs_attr_find()
705 * load_attribute_list - load an attribute list into memory
707 * @runlist: runlist of the attribute list
710 * @initialized_size: initialized size of the attribute list
748 ntfs_error(sb, "Cannot read attribute list since runlist is " in load_attribute_list()
758 /* The attribute list cannot be sparse. */ in load_attribute_list()
761 "read attribute list."); in load_attribute_list()
774 "read attribute list."); in load_attribute_list()
797 * Note: The attribute list can be smaller than its allocation in load_attribute_list()
810 ntfs_error(sb, "Attribute list buffer overflow. Read attribute list " in load_attribute_list()
818 * ntfs_external_attr_find - find an attribute in the attribute list of an inode
819 * @type: attribute type to find
820 * @name: attribute name to find (optional, i.e. NULL means don't care)
821 * @name_len: attribute name length (only needed if @name present)
824 * @val: attribute value to find (optional, resident attributes only)
825 * @val_len: attribute value length
826 * @ctx: search context with mft record and attribute to search from
831 * Find an attribute by searching the attribute list for the corresponding
832 * attribute list entry. Having found the entry, map the mft record if the
833 * attribute is in a different mft record/inode, ntfs_attr_find() the attribute
841 * After finishing with the attribute/mft record you need to call
845 * If the attribute is found, ntfs_external_attr_find() returns 0 and
846 * @ctx->attr will point to the found attribute. @ctx->mrec will point to the
848 * the attribute list entry for the attribute.
850 * If the attribute is not found, ntfs_external_attr_find() returns -ENOENT and
851 * @ctx->attr will point to the attribute in the base mft record before which
852 * the attribute being searched for would need to be inserted if such an action
854 * @ctx->attr is located and @ctx->al_entry will point to the attribute list
855 * entry of the attribute before which the attribute being searched for would
858 * Thus to insert the not found attribute, one wants to add the attribute to
860 * attribute should be placed in a newly allocated extent mft record. The
861 * attribute list entry for the inserted attribute should be inserted in the
862 * attribute list attribute at @ctx->al_entry.
900 * Iterate over entries in attribute list starting at @ctx->al_entry, in ntfs_external_attr_find()
915 /* Catch the end of the attribute list. */ in ntfs_external_attr_find()
931 * missing, assume we want an unnamed attribute. in ntfs_external_attr_find()
947 * matching attribute. in ntfs_external_attr_find()
971 * The names match or @name not present and attribute is in ntfs_external_attr_find()
973 * next attribute list entry still fits @lowest_vcn. Otherwise in ntfs_external_attr_find()
994 "reference in attribute list " in ntfs_external_attr_find()
1036 * mft record containing the attribute represented by the in ntfs_external_attr_find()
1041 * attribute in this mft record but this would be less in ntfs_external_attr_find()
1043 * the attribute instance numbers for example which become in ntfs_external_attr_find()
1044 * important when one plays with attribute lists. Also, in ntfs_external_attr_find()
1045 * because a proper match has been found in the attribute list in ntfs_external_attr_find()
1066 * attribute list entry and the attribute record, there is in ntfs_external_attr_find()
1090 /* Proceed to the next attribute in the current mft record. */ in ntfs_external_attr_find()
1096 "attribute list attribute.%s", base_ni->mft_no, in ntfs_external_attr_find()
1121 * The attribute was not found. Before we return, we want to ensure in ntfs_external_attr_find()
1123 * attribute should be inserted in the base mft record. Since we also in ntfs_external_attr_find()
1145 * keep enumerating until we get an attribute not found response (or in ntfs_external_attr_find()
1146 * another error), otherwise we would keep returning the same attribute in ntfs_external_attr_find()
1159 * ntfs_attr_lookup - find an attribute in an ntfs inode
1160 * @type: attribute type to find
1161 * @name: attribute name to find (optional, i.e. NULL means don't care)
1162 * @name_len: attribute name length (only needed if @name present)
1165 * @val: attribute value to find (optional, resident attributes only)
1166 * @val_len: attribute value length
1167 * @ctx: search context with mft record and attribute to search from
1169 * Find an attribute in an ntfs inode. On first search @ctx->ntfs_ino must
1173 * This function transparently handles attribute lists and @ctx is used to
1176 * After finishing with the attribute/mft record you need to call
1182 * When 0, @ctx->attr is the found attribute and it is in mft record
1183 * @ctx->mrec. If an attribute list attribute is present, @ctx->al_entry is
1184 * the attribute list entry of the found attribute.
1186 * When -ENOENT, @ctx->attr is the attribute which collates just after the
1187 * attribute being searched for, i.e. if one wants to add the attribute to the
1188 * mft record this is the correct place to insert it into. If an attribute
1189 * list attribute is present, @ctx->al_entry is the attribute list entry which
1190 * collates just after the attribute list entry of the attribute being searched
1191 * for, i.e. if one wants to add the attribute to the mft record this is the
1192 * correct place to insert its attribute list entry into.
1220 * ntfs_attr_init_search_ctx - initialize an attribute search context
1221 * @ctx: attribute search context to initialize
1225 * Initialize the attribute search context @ctx with @ni and @mrec.
1241 * ntfs_attr_reinit_search_ctx - reinitialize an attribute search context
1242 * @ctx: attribute search context to reinitialize
1244 * Reinitialize the attribute search context @ctx, unmapping an associated
1247 * This is used when a search for a new attribute is being started to reset
1253 /* No attribute list. */ in ntfs_attr_reinit_search_ctx()
1264 } /* Attribute list. */ in ntfs_attr_reinit_search_ctx()
1272 * ntfs_attr_get_search_ctx - allocate/initialize a new attribute search context
1276 * Allocate a new attribute search context, initialize it with @ni and @mrec,
1290 * ntfs_attr_put_search_ctx - release an attribute search context
1291 * @ctx: attribute search context to free
1293 * Release the attribute search context @ctx, unmapping an associated extent
1307 * ntfs_attr_find_in_attrdef - find an attribute in the $AttrDef system file
1308 * @vol: ntfs volume to which the attribute belongs
1309 * @type: attribute type which to find
1311 * Search for the attribute definition record corresponding to the attribute
1314 * Return the attribute type definition record if found and NULL if not found.
1328 /* We found the attribute; return it. */ in ntfs_attr_find_in_attrdef()
1334 /* Attribute not found. */ in ntfs_attr_find_in_attrdef()
1335 ntfs_debug("Attribute type 0x%x not found in $AttrDef.", in ntfs_attr_find_in_attrdef()
1341 * ntfs_attr_size_bounds_check - check a size of an attribute type for validity
1342 * @vol: ntfs volume to which the attribute belongs
1343 * @type: attribute type which to check
1346 * Check whether the @size in bytes is valid for an attribute of @type on the
1349 * Return 0 if valid, -ERANGE if not valid, or -ENOENT if the attribute is not
1364 /* Get the $AttrDef entry for the attribute @type. */ in ntfs_attr_size_bounds_check()
1378 * ntfs_attr_can_be_non_resident - check if an attribute can be non-resident
1379 * @vol: ntfs volume to which the attribute belongs
1380 * @type: attribute type which to check
1382 * Check whether the attribute of @type on the ntfs volume @vol is allowed to
1385 * Return 0 if the attribute is allowed to be non-resident, -EPERM if not, and
1386 * -ENOENT if the attribute is not listed in $AttrDef.
1392 /* Find the attribute definition record in $AttrDef. */ in ntfs_attr_can_be_non_resident()
1403 * ntfs_attr_can_be_resident - check if an attribute can be resident
1404 * @vol: ntfs volume to which the attribute belongs
1405 * @type: attribute type which to check
1407 * Check whether the attribute of @type on the ntfs volume @vol is allowed to
1413 * Return 0 if the attribute is allowed to be non-resident and -EPERM if not.
1415 * Warning: In the system file $MFT the attribute $Bitmap must be non-resident
1428 * ntfs_attr_record_resize - resize an attribute record
1429 * @m: mft record containing attribute record
1430 * @a: attribute record to resize
1431 * @new_size: new size in bytes to which to resize the attribute record @a
1433 * Resize the attribute record @a, i.e. the resident part of the attribute, in
1451 /* If the actual attribute length has changed, move things around. */ in ntfs_attr_record_resize()
1472 * ntfs_resident_attr_value_resize - resize the value of a resident attribute
1473 * @m: mft record containing attribute record
1474 * @a: attribute record whose value to resize
1475 * @new_size: new size in bytes to which to resize the attribute value of @a
1477 * Resize the value of the attribute @a in the mft record @m to @new_size bytes.
1494 /* Resize the resident part of the attribute record. */ in ntfs_resident_attr_value_resize()
1499 * The resize succeeded! If we made the attribute value bigger, clear in ntfs_resident_attr_value_resize()
1506 /* Finally update the length of the attribute value. */ in ntfs_resident_attr_value_resize()
1512 * ntfs_attr_make_non_resident - convert a resident to a non-resident attribute
1513 * @ni: ntfs inode describing the attribute to convert
1514 * @data_size: size of the resident data to copy to the non-resident attribute
1516 * Convert the resident ntfs attribute described by the ntfs inode @ni to a
1519 * @data_size must be equal to the attribute value size. This is needed since
1527 * -EPERM - The attribute is not allowed to be non-resident.
1530 * -EINVAL - Attribute not defined on the volume.
1537 * again in case the attribute may then fit in a resident state so no need to
1540 * NOTE to self: No changes in the attribute list are required to move from
1541 * a resident to a non-resident attribute.
1562 /* Check that the attribute is allowed to be non-resident. */ in ntfs_attr_make_non_resident()
1566 ntfs_debug("Attribute is not allowed to be " in ntfs_attr_make_non_resident()
1569 ntfs_debug("Attribute not defined on the NTFS " in ntfs_attr_make_non_resident()
1594 /* Start by allocating clusters to hold the attribute value. */ in ntfs_attr_make_non_resident()
1659 * attribute record. in ntfs_attr_make_non_resident()
1664 * attribute value. in ntfs_attr_make_non_resident()
1678 /* Backup the attribute flag. */ in ntfs_attr_make_non_resident()
1680 /* Resize the resident part of the attribute record. */ in ntfs_attr_make_non_resident()
1685 * Convert the resident part of the attribute record to describe a in ntfs_attr_make_non_resident()
1686 * non-resident attribute. in ntfs_attr_make_non_resident()
1689 /* Move the attribute name if it exists and update the offset. */ in ntfs_attr_make_non_resident()
1713 /* Generate the mapping pairs array into the attribute record. */ in ntfs_attr_make_non_resident()
1721 /* Setup the in-memory attribute structure to be non-resident. */ in ntfs_attr_make_non_resident()
1766 /* Convert the attribute back into a resident attribute. */ in ntfs_attr_make_non_resident()
1768 /* Move the attribute name if it exists and update the offset. */ in ntfs_attr_make_non_resident()
1777 /* Resize the resident part of the attribute record. */ in ntfs_attr_make_non_resident()
1783 * If the old size is too small, truncate the attribute, in ntfs_attr_make_non_resident()
1793 "to non-resident attribute " in ntfs_attr_make_non_resident()
1795 "attribute type 0x%x from %i bytes to " in ntfs_attr_make_non_resident()
1803 !ni->name_len) ? "FILE": "ATTRIBUTE"); in ntfs_attr_make_non_resident()
1816 /* Copy the data from the page back to the attribute value. */ in ntfs_attr_make_non_resident()
1856 * ntfs_attr_extend_allocation - extend the allocated space of an attribute
1857 * @ni: ntfs inode of the attribute whose allocation to extend
1862 * Extend the allocated space of an attribute described by the ntfs inode @ni
1871 * of the attribute is extended to @new_data_size. Note that the i_size of the
1872 * vfs inode is not updated. Only the data size in the base attribute record
1877 * For resident attributes this involves resizing the attribute record and if
1879 * converting the attribute to a non-resident attribute which in turn involves
1880 * extending the allocation of a non-resident attribute as described below.
1885 * updating the mapping pairs array of the attribute. This in turn involves
1886 * resizing the attribute record and if necessary moving it and/or other
1887 * attributes into extent mft records and/or splitting the attribute record
1888 * into multiple extent attribute records.
1890 * Also, the attribute list attribute is updated if present and in some of the
1892 * an attribute list attribute is created if not already present.
1906 * attribute can be resized safely and so that it can for example be converted
1909 * TODO: At present attribute list attribute handling is not implemented.
1912 * than the $DATA attribute(s) of an uncompressed and unencrypted file.
1935 ntfs_debug("Entering for i_ino 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
1967 "of inode 0x%lx, attribute " in ntfs_attr_extend_allocation()
1971 "this attribute type.", in ntfs_attr_extend_allocation()
1976 "of inode 0x%lx, attribute " in ntfs_attr_extend_allocation()
1978 "attribute type is not " in ntfs_attr_extend_allocation()
2025 * just converted the attribute from resident to non-resident it is in ntfs_attr_extend_allocation()
2035 * We want the first attribute extent so that we can update the in ntfs_attr_extend_allocation()
2053 /* The total length of the attribute value. */ in ntfs_attr_extend_allocation()
2056 * Extend the attribute record to be able to store the new attribute in ntfs_attr_extend_allocation()
2088 * Not enough space in the mft record, try to make the attribute in ntfs_attr_extend_allocation()
2096 * permitted for this attribute type or there not being enough space, in ntfs_attr_extend_allocation()
2106 "inode 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
2108 "to non-resident attribute failed " in ntfs_attr_extend_allocation()
2123 "attribute value. This case is not " in ntfs_attr_extend_allocation()
2126 ntfs_error(vol->sb, "This attribute type may not be " in ntfs_attr_extend_allocation()
2137 * Both the attribute list attribute and the standard information in ntfs_attr_extend_allocation()
2138 * attribute must remain in the base inode. Thus, if this is one of in ntfs_attr_extend_allocation()
2151 // TODO: Attempt to move this attribute to an extent mft record, but in ntfs_attr_extend_allocation()
2152 // only if it is not already the only attribute in an mft record in in ntfs_attr_extend_allocation()
2168 * $DATA attribute and sparse attributes are enabled on the volume and in ntfs_attr_extend_allocation()
2188 /* If this attribute extent is not mapped, map it now. */ in ntfs_attr_extend_allocation()
2199 "of inode 0x%lx, attribute " in ntfs_attr_extend_allocation()
2219 * there are no valid LCNs in the attribute we let the cluster in ntfs_attr_extend_allocation()
2237 "inode 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
2250 "inode 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
2269 /* Find the runlist element with which the attribute extent starts. */ in ntfs_attr_extend_allocation()
2282 "inode 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
2290 /* Extend the attribute record to fit the bigger mapping pairs array. */ in ntfs_attr_extend_allocation()
2304 "record for the extended attribute " in ntfs_attr_extend_allocation()
2318 "inode 0x%lx, attribute type 0x%x, " in ntfs_attr_extend_allocation()
2329 * We now have extended the allocated size of the attribute. Reflect in ntfs_attr_extend_allocation()
2330 * this in the ntfs_inode structure and the attribute record. in ntfs_attr_extend_allocation()
2334 * We are not in the first attribute extent, switch to it, but in ntfs_attr_extend_allocation()
2356 * regular files, and only for their $DATA attribute(s). in ntfs_attr_extend_allocation()
2388 "of inode 0x%lx, attribute type 0x%x, because " in ntfs_attr_extend_allocation()
2389 "lookup of first attribute extent failed with " in ntfs_attr_extend_allocation()
2398 ntfs_error(vol->sb, "Failed to find last attribute extent of " in ntfs_attr_extend_allocation()
2399 "attribute in error code path. Run chkdsk to " in ntfs_attr_extend_allocation()
2420 * base attribute extent which chkdsk should be able to fix. in ntfs_attr_extend_allocation()
2439 * longer valid, we cannot resize the attribute record or build the in ntfs_attr_extend_allocation()
2446 "restore attribute search context" : in ntfs_attr_extend_allocation()
2447 "truncate attribute runlist"); in ntfs_attr_extend_allocation()
2451 ntfs_error(vol->sb, "Failed to restore attribute " in ntfs_attr_extend_allocation()
2484 * ntfs_attr_set - fill (a part of) an attribute with a byte
2485 * @ni: ntfs inode describing the attribute to fill
2486 * @ofs: offset inside the attribute at which to start to fill
2488 * @val: the unsigned 8-bit value with which to fill the attribute
2490 * Fill @cnt bytes of the attribute described by the ntfs inode @ni starting at
2491 * byte offset @ofs inside the attribute with the constant byte @val.
2493 * This function is effectively like memset() applied to an ntfs attribute.
2495 * to the ntfs attribute and it marks them dirty after doing the memset().
2500 * that @ofs + @cnt were outside the end of the attribute and no write was
2533 ntfs_error(vol->sb, "Request exceeds end of attribute."); in ntfs_attr_set()