Commit c8d3aeee authored by Anton Altaparmakov's avatar Anton Altaparmakov Committed by Richard Russon

NTFS: Rename {find,lookup}_attr() to ntfs_attr_{find,lookup}() as well as

      find_external_attr() to ntfs_external_attr_find() to cleanup the
      namespace a bit and to be more consistent with libntfs.
Signed-off-by: default avatarAnton Altaparmakov <aia21@cantab.net>
parent e0f5cb89
...@@ -28,6 +28,13 @@ ToDo/Notes: ...@@ -28,6 +28,13 @@ ToDo/Notes:
- Fix scheduling latencies in ntfs_fill_super() by dropping the BKL - Fix scheduling latencies in ntfs_fill_super() by dropping the BKL
because the code itself is using the ntfs_lock semaphore which because the code itself is using the ntfs_lock semaphore which
provides safe locking. (Ingo Molnar) provides safe locking. (Ingo Molnar)
- Fix a potential bug in fs/ntfs/mft.c::map_extent_mft_record() that
could occur in the future for when we start closing/freeing extent
inodes if we don't set base_ni->ext.extent_ntfs_inos to NULL after
we free it.
- Rename {find,lookup}_attr() to ntfs_attr_{find,lookup}() as well as
find_external_attr() to ntfs_external_attr_find() to cleanup the
namespace a bit and to be more consistent with libntfs.
2.1.17 - Fix bugs in mount time error code paths and other updates. 2.1.17 - Fix bugs in mount time error code paths and other updates.
......
...@@ -402,7 +402,7 @@ int ntfs_readpage(struct file *file, struct page *page) ...@@ -402,7 +402,7 @@ int ntfs_readpage(struct file *file, struct page *page)
err = -ENOMEM; err = -ENOMEM;
goto unm_err_out; goto unm_err_out;
} }
if (unlikely(!lookup_attr(ni->type, ni->name, ni->name_len, if (unlikely(!ntfs_attr_lookup(ni->type, ni->name, ni->name_len,
CASE_SENSITIVE, 0, NULL, 0, ctx))) { CASE_SENSITIVE, 0, NULL, 0, ctx))) {
err = -ENOENT; err = -ENOENT;
goto put_unm_err_out; goto put_unm_err_out;
...@@ -1122,7 +1122,7 @@ static int ntfs_writepage(struct page *page, struct writeback_control *wbc) ...@@ -1122,7 +1122,7 @@ static int ntfs_writepage(struct page *page, struct writeback_control *wbc)
err = -ENOMEM; err = -ENOMEM;
goto err_out; goto err_out;
} }
if (unlikely(!lookup_attr(ni->type, ni->name, ni->name_len, if (unlikely(!ntfs_attr_lookup(ni->type, ni->name, ni->name_len,
CASE_SENSITIVE, 0, NULL, 0, ctx))) { CASE_SENSITIVE, 0, NULL, 0, ctx))) {
err = -ENOENT; err = -ENOENT;
goto err_out; goto err_out;
...@@ -1683,7 +1683,7 @@ static int ntfs_prepare_write(struct file *file, struct page *page, ...@@ -1683,7 +1683,7 @@ static int ntfs_prepare_write(struct file *file, struct page *page,
* We thus defer the uptodate bringing of the page region outside the * We thus defer the uptodate bringing of the page region outside the
* region written to to ntfs_commit_write(). The reason for doing this * region written to to ntfs_commit_write(). The reason for doing this
* is that we save one round of: * is that we save one round of:
* map_mft_record(), get_attr_search_ctx(), lookup_attr(), * map_mft_record(), get_attr_search_ctx(), ntfs_attr_lookup(),
* kmap_atomic(), kunmap_atomic(), put_attr_search_ctx(), * kmap_atomic(), kunmap_atomic(), put_attr_search_ctx(),
* unmap_mft_record(). * unmap_mft_record().
* Which is obviously a very worthwhile save. * Which is obviously a very worthwhile save.
...@@ -1896,7 +1896,7 @@ static int ntfs_commit_write(struct file *file, struct page *page, ...@@ -1896,7 +1896,7 @@ static int ntfs_commit_write(struct file *file, struct page *page,
err = -ENOMEM; err = -ENOMEM;
goto err_out; goto err_out;
} }
if (unlikely(!lookup_attr(ni->type, ni->name, ni->name_len, if (unlikely(!ntfs_attr_lookup(ni->type, ni->name, ni->name_len,
CASE_SENSITIVE, 0, NULL, 0, ctx))) { CASE_SENSITIVE, 0, NULL, 0, ctx))) {
err = -ENOENT; err = -ENOENT;
goto err_out; goto err_out;
......
...@@ -966,8 +966,8 @@ int ntfs_map_runlist(ntfs_inode *ni, VCN vcn) ...@@ -966,8 +966,8 @@ int ntfs_map_runlist(ntfs_inode *ni, VCN vcn)
err = -ENOMEM; err = -ENOMEM;
goto err_out; goto err_out;
} }
if (!lookup_attr(ni->type, ni->name, ni->name_len, CASE_SENSITIVE, vcn, if (!ntfs_attr_lookup(ni->type, ni->name, ni->name_len, CASE_SENSITIVE,
NULL, 0, ctx)) { vcn, NULL, 0, ctx)) {
put_attr_search_ctx(ctx); put_attr_search_ctx(ctx);
err = -ENOENT; err = -ENOENT;
goto err_out; goto err_out;
...@@ -1148,7 +1148,7 @@ runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn, ...@@ -1148,7 +1148,7 @@ runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn,
} }
/** /**
* find_attr - find (next) attribute in mft record * ntfs_attr_find - find (next) attribute in mft record
* @type: attribute type to find * @type: attribute type to find
* @name: attribute name to find (optional, i.e. NULL means don't care) * @name: attribute name to find (optional, i.e. NULL means don't care)
* @name_len: attribute name length (only needed if @name present) * @name_len: attribute name length (only needed if @name present)
...@@ -1157,47 +1157,49 @@ runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn, ...@@ -1157,47 +1157,49 @@ runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn,
* @val_len: attribute value length * @val_len: attribute value length
* @ctx: search context with mft record and attribute to search from * @ctx: search context with mft record and attribute to search from
* *
* You shouldn't need to call this function directly. Use lookup_attr() instead. * You should not need to call this function directly. Use ntfs_attr_lookup()
* instead.
* *
* find_attr() takes a search context @ctx as parameter and searches the mft * ntfs_attr_find() takes a search context @ctx as parameter and searches the
* record specified by @ctx->mrec, beginning at @ctx->attr, for an attribute of * mft record specified by @ctx->mrec, beginning at @ctx->attr, for an
* @type, optionally @name and @val. If found, find_attr() returns TRUE and * attribute of @type, optionally @name and @val. If found, ntfs_attr_find()
* @ctx->attr will point to the found attribute. If not found, find_attr() * returns TRUE and @ctx->attr will point to the found attribute. If not
* returns FALSE and @ctx->attr is undefined (i.e. do not rely on it not * found, ntfs_attr_find() returns FALSE and @ctx->attr is undefined (i.e. do
* changing). * not rely on it not changing).
* *
* If @ctx->is_first is TRUE, the search begins with @ctx->attr itself. If it * If @ctx->is_first is TRUE, the search begins with @ctx->attr itself. If it
* is FALSE, the search begins after @ctx->attr. * is FALSE, the search begins after @ctx->attr.
* *
* If @ic is IGNORE_CASE, the @name comparisson is not case sensitive and * If @ic is IGNORE_CASE, the @name comparisson is not case sensitive and
* @ctx->ntfs_ino must be set to the ntfs inode to which the mft record * @ctx->ntfs_ino must be set to the ntfs inode to which the mft record
* @ctx->mrec belongs. This is so we can get at the ntfs volume and hence at * @ctx->mrec belongs. This is so we can get at the ntfs volume and hence at
* the upcase table. If @ic is CASE_SENSITIVE, the comparison is case * the upcase table. If @ic is CASE_SENSITIVE, the comparison is case
* sensitive. When @name is present, @name_len is the @name length in Unicode * sensitive. When @name is present, @name_len is the @name length in Unicode
* characters. * characters.
* *
* If @name is not present (NULL), we assume that the unnamed attribute is * If @name is not present (NULL), we assume that the unnamed attribute is
* being searched for. * being searched for.
* *
* Finally, the resident attribute value @val is looked for, if present. If @val * Finally, the resident attribute value @val is looked for, if present. If
* is not present (NULL), @val_len is ignored. * @val is not present (NULL), @val_len is ignored.
* *
* find_attr() only searches the specified mft record and it ignores the * ntfs_attr_find() only searches the specified mft record and it ignores the
* presence of an attribute list attribute (unless it is the one being searched * presence of an attribute list attribute (unless it is the one being searched
* for, obviously). If you need to take attribute lists into consideration, use * for, obviously). If you need to take attribute lists into consideration,
* lookup_attr() instead (see below). This also means that you cannot use * use ntfs_attr_lookup() instead (see below). This also means that you cannot
* find_attr() to search for extent records of non-resident attributes, as * use ntfs_attr_find() to search for extent records of non-resident
* extents with lowest_vcn != 0 are usually described by the attribute list * attributes, as extents with lowest_vcn != 0 are usually described by the
* attribute only. - Note that it is possible that the first extent is only in * attribute list attribute only. - Note that it is possible that the first
* the attribute list while the last extent is in the base mft record, so don't * extent is only in the attribute list while the last extent is in the base
* rely on being able to find the first extent in the base mft record. * mft record, so do not rely on being able to find the first extent in the
* base mft record.
* *
* Warning: Never use @val when looking for attribute types which can be * Warning: Never use @val when looking for attribute types which can be
* non-resident as this most likely will result in a crash! * non-resident as this most likely will result in a crash!
*/ */
BOOL find_attr(const ATTR_TYPES type, const ntfschar *name, const u32 name_len, BOOL ntfs_attr_find(const ATTR_TYPES type, const ntfschar *name,
const IGNORE_CASE_BOOL ic, const u8 *val, const u32 val_len, const u32 name_len, const IGNORE_CASE_BOOL ic,
attr_search_context *ctx) const u8 *val, const u32 val_len, attr_search_context *ctx)
{ {
ATTR_RECORD *a; ATTR_RECORD *a;
ntfs_volume *vol; ntfs_volume *vol;
...@@ -1419,7 +1421,7 @@ int load_attribute_list(ntfs_volume *vol, runlist *runlist, u8 *al_start, ...@@ -1419,7 +1421,7 @@ int load_attribute_list(ntfs_volume *vol, runlist *runlist, u8 *al_start,
} }
/** /**
* find_external_attr - find an attribute in the attribute list of an ntfs inode * ntfs_external_attr_find - find an attribute in the attribute list of an inode
* @type: attribute type to find * @type: attribute type to find
* @name: attribute name to find (optional, i.e. NULL means don't care) * @name: attribute name to find (optional, i.e. NULL means don't care)
* @name_len: attribute name length (only needed if @name present) * @name_len: attribute name length (only needed if @name present)
...@@ -1429,34 +1431,35 @@ int load_attribute_list(ntfs_volume *vol, runlist *runlist, u8 *al_start, ...@@ -1429,34 +1431,35 @@ int load_attribute_list(ntfs_volume *vol, runlist *runlist, u8 *al_start,
* @val_len: attribute value length * @val_len: attribute value length
* @ctx: search context with mft record and attribute to search from * @ctx: search context with mft record and attribute to search from
* *
* You shouldn't need to call this function directly. Use lookup_attr() instead. * You should not need to call this function directly. Use ntfs_attr_lookup()
* instead.
* *
* Find an attribute by searching the attribute list for the corresponding * Find an attribute by searching the attribute list for the corresponding
* attribute list entry. Having found the entry, map the mft record for read * attribute list entry. Having found the entry, map the mft record if the
* if the attribute is in a different mft record/inode, find_attr the attribute * attribute is in a different mft record/inode, ntfs_attr_find() the attribute
* in there and return it. * in there and return it.
* *
* On first search @ctx->ntfs_ino must be the base mft record and @ctx must * On first search @ctx->ntfs_ino must be the base mft record and @ctx must
* have been obtained from a call to get_attr_search_ctx(). On subsequent calls * have been obtained from a call to get_attr_search_ctx(). On subsequent
* @ctx->ntfs_ino can be any extent inode, too (@ctx->base_ntfs_ino is then the * calls @ctx->ntfs_ino can be any extent inode, too (@ctx->base_ntfs_ino is
* base inode). * then the base inode).
* *
* After finishing with the attribute/mft record you need to call * After finishing with the attribute/mft record you need to call
* put_attr_search_ctx() to cleanup the search context (unmapping any mapped * put_attr_search_ctx() to cleanup the search context (unmapping any mapped
* inodes, etc). * inodes, etc).
* *
* Return TRUE if the search was successful and FALSE if not. When TRUE, * Return TRUE if the search was successful and FALSE if not. When TRUE,
* @ctx->attr is the found attribute and it is in mft record @ctx->mrec. When * @ctx->attr is the found attribute and it is in mft record @ctx->mrec. When
* FALSE, @ctx->attr is the attribute which collates just after the attribute * FALSE, @ctx->attr is the attribute which collates just after the attribute
* being searched for in the base ntfs inode, i.e. if one wants to add the * being searched for in the base ntfs inode, i.e. if one wants to add the
* attribute to the mft record this is the correct place to insert it into * attribute to the mft record this is the correct place to insert it into
* and if there is not enough space, the attribute should be placed in an * and if there is not enough space, the attribute should be placed in an
* extent mft record. * extent mft record.
*/ */
static BOOL find_external_attr(const ATTR_TYPES type, const ntfschar *name, static BOOL ntfs_external_attr_find(const ATTR_TYPES type,
const u32 name_len, const IGNORE_CASE_BOOL ic, const ntfschar *name, const u32 name_len,
const VCN lowest_vcn, const u8 *val, const u32 val_len, const IGNORE_CASE_BOOL ic, const VCN lowest_vcn,
attr_search_context *ctx) const u8 *val, const u32 val_len, attr_search_context *ctx)
{ {
ntfs_inode *base_ni, *ni; ntfs_inode *base_ni, *ni;
ntfs_volume *vol; ntfs_volume *vol;
...@@ -1538,10 +1541,11 @@ static BOOL find_external_attr(const ATTR_TYPES type, const ntfschar *name, ...@@ -1538,10 +1541,11 @@ static BOOL find_external_attr(const ATTR_TYPES type, const ntfschar *name,
continue; continue;
/* /*
* FIXME: Reverse engineering showed 0, IGNORE_CASE but * FIXME: Reverse engineering showed 0, IGNORE_CASE but
* that is inconsistent with find_attr(). The subsequent * that is inconsistent with ntfs_attr_find(). The
* rc checks were also different. Perhaps I made a * subsequent rc checks were also different. Perhaps I
* mistake in one of the two. Need to recheck which is * made a mistake in one of the two. Need to recheck
* correct or at least see what is going on... (AIA) * which is correct or at least see what is going on...
* (AIA)
*/ */
rc = ntfs_collate_names(name, name_len, al_name, rc = ntfs_collate_names(name, name_len, al_name,
al_name_len, 1, CASE_SENSITIVE, al_name_len, 1, CASE_SENSITIVE,
...@@ -1609,14 +1613,14 @@ static BOOL find_external_attr(const ATTR_TYPES type, const ntfschar *name, ...@@ -1609,14 +1613,14 @@ static BOOL find_external_attr(const ATTR_TYPES type, const ntfschar *name,
* current al_entry. * current al_entry.
*/ */
/* /*
* We could call into find_attr() to find the right attribute * We could call into ntfs_attr_ind() to find the right
* in this mft record but this would be less efficient and not * attribute in this mft record but this would be less
* quite accurate as find_attr() ignores the attribute instance * efficient and not quite accurate as ntfs_attr_find() ignores
* numbers for example which become important when one plays * the attribute instance numbers for example which become
* with attribute lists. Also, because a proper match has been * important when one plays with attribute lists. Also,
* found in the attribute list entry above, the comparison can * because a proper match has been found in the attribute list
* now be optimized. So it is worth re-implementing a * entry above, the comparison can now be optimized. So it is
* simplified find_attr() here. * worth re-implementing a simplified ntfs_attr_find() here.
*/ */
a = ctx->attr; a = ctx->attr;
/* /*
...@@ -1689,13 +1693,13 @@ static BOOL find_external_attr(const ATTR_TYPES type, const ntfschar *name, ...@@ -1689,13 +1693,13 @@ static BOOL find_external_attr(const ATTR_TYPES type, const ntfschar *name,
* FIXME: Do we really want to do this here? Think about it... (AIA) * FIXME: Do we really want to do this here? Think about it... (AIA)
*/ */
reinit_attr_search_ctx(ctx); reinit_attr_search_ctx(ctx);
find_attr(type, name, name_len, ic, val, val_len, ctx); ntfs_attr_find(type, name, name_len, ic, val, val_len, ctx);
ntfs_debug("Done, not found."); ntfs_debug("Done, not found.");
return FALSE; return FALSE;
} }
/** /**
* lookup_attr - find an attribute in an ntfs inode * ntfs_attr_lookup - find an attribute in an ntfs inode
* @type: attribute type to find * @type: attribute type to find
* @name: attribute name to find (optional, i.e. NULL means don't care) * @name: attribute name to find (optional, i.e. NULL means don't care)
* @name_len: attribute name length (only needed if @name present) * @name_len: attribute name length (only needed if @name present)
...@@ -1722,7 +1726,7 @@ static BOOL find_external_attr(const ATTR_TYPES type, const ntfschar *name, ...@@ -1722,7 +1726,7 @@ static BOOL find_external_attr(const ATTR_TYPES type, const ntfschar *name,
* being searched for, i.e. if one wants to add the attribute to the mft * being searched for, i.e. if one wants to add the attribute to the mft
* record this is the correct place to insert it into. * record this is the correct place to insert it into.
*/ */
BOOL lookup_attr(const ATTR_TYPES type, const ntfschar *name, BOOL ntfs_attr_lookup(const ATTR_TYPES type, const ntfschar *name,
const u32 name_len, const IGNORE_CASE_BOOL ic, const u32 name_len, const IGNORE_CASE_BOOL ic,
const VCN lowest_vcn, const u8 *val, const u32 val_len, const VCN lowest_vcn, const u8 *val, const u32 val_len,
attr_search_context *ctx) attr_search_context *ctx)
...@@ -1737,9 +1741,10 @@ BOOL lookup_attr(const ATTR_TYPES type, const ntfschar *name, ...@@ -1737,9 +1741,10 @@ BOOL lookup_attr(const ATTR_TYPES type, const ntfschar *name,
/* Sanity check, just for debugging really. */ /* Sanity check, just for debugging really. */
BUG_ON(!base_ni); BUG_ON(!base_ni);
if (!NInoAttrList(base_ni)) if (!NInoAttrList(base_ni))
return find_attr(type, name, name_len, ic, val, val_len, ctx); return ntfs_attr_find(type, name, name_len, ic, val, val_len,
return find_external_attr(type, name, name_len, ic, lowest_vcn, val, ctx);
val_len, ctx); return ntfs_external_attr_find(type, name, name_len, ic, lowest_vcn,
val, val_len, ctx);
} }
/** /**
......
...@@ -46,7 +46,7 @@ typedef enum { ...@@ -46,7 +46,7 @@ typedef enum {
* attr_search_context - used in attribute search functions * attr_search_context - used in attribute search functions
* @mrec: buffer containing mft record to search * @mrec: buffer containing mft record to search
* @attr: attribute record in @mrec where to begin/continue search * @attr: attribute record in @mrec where to begin/continue search
* @is_first: if true lookup_attr() begins search with @attr, else after @attr * @is_first: if true ntfs_attr_lookup() begins search with @attr, else after
* *
* Structure must be initialized to zero before the first call to one of the * Structure must be initialized to zero before the first call to one of the
* attribute search functions. Initialize @mrec to point to the mft record to * attribute search functions. Initialize @mrec to point to the mft record to
...@@ -81,11 +81,11 @@ extern LCN ntfs_vcn_to_lcn(const runlist_element *rl, const VCN vcn); ...@@ -81,11 +81,11 @@ extern LCN ntfs_vcn_to_lcn(const runlist_element *rl, const VCN vcn);
extern runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn, extern runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn,
const BOOL need_write); const BOOL need_write);
extern BOOL find_attr(const ATTR_TYPES type, const ntfschar *name, extern BOOL ntfs_attr_find(const ATTR_TYPES type, const ntfschar *name,
const u32 name_len, const IGNORE_CASE_BOOL ic, const u8 *val, const u32 name_len, const IGNORE_CASE_BOOL ic, const u8 *val,
const u32 val_len, attr_search_context *ctx); const u32 val_len, attr_search_context *ctx);
BOOL lookup_attr(const ATTR_TYPES type, const ntfschar *name, BOOL ntfs_attr_lookup(const ATTR_TYPES type, const ntfschar *name,
const u32 name_len, const IGNORE_CASE_BOOL ic, const u32 name_len, const IGNORE_CASE_BOOL ic,
const VCN lowest_vcn, const u8 *val, const u32 val_len, const VCN lowest_vcn, const u8 *val, const u32 val_len,
attr_search_context *ctx); attr_search_context *ctx);
......
...@@ -106,8 +106,8 @@ MFT_REF ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname, ...@@ -106,8 +106,8 @@ MFT_REF ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
goto err_out; goto err_out;
} }
/* Find the index root attribute in the mft record. */ /* Find the index root attribute in the mft record. */
if (!lookup_attr(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, NULL, 0, if (!ntfs_attr_lookup(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, NULL,
ctx)) { 0, ctx)) {
ntfs_error(sb, "Index root attribute missing in directory " ntfs_error(sb, "Index root attribute missing in directory "
"inode 0x%lx.", dir_ni->mft_no); "inode 0x%lx.", dir_ni->mft_no);
err = -EIO; err = -EIO;
...@@ -655,8 +655,8 @@ u64 ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname, ...@@ -655,8 +655,8 @@ u64 ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
goto err_out; goto err_out;
} }
/* Find the index root attribute in the mft record. */ /* Find the index root attribute in the mft record. */
if (!lookup_attr(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, NULL, 0, if (!ntfs_attr_lookup(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, NULL,
ctx)) { 0, ctx)) {
ntfs_error(sb, "Index root attribute missing in directory " ntfs_error(sb, "Index root attribute missing in directory "
"inode 0x%lx.", dir_ni->mft_no); "inode 0x%lx.", dir_ni->mft_no);
err = -EIO; err = -EIO;
...@@ -1183,8 +1183,8 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -1183,8 +1183,8 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
/* Get the offset into the index root attribute. */ /* Get the offset into the index root attribute. */
ir_pos = (s64)fpos; ir_pos = (s64)fpos;
/* Find the index root attribute in the mft record. */ /* Find the index root attribute in the mft record. */
if (unlikely(!lookup_attr(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, if (unlikely(!ntfs_attr_lookup(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE,
NULL, 0, ctx))) { 0, NULL, 0, ctx))) {
ntfs_error(sb, "Index root attribute missing in directory " ntfs_error(sb, "Index root attribute missing in directory "
"inode 0x%lx.", vdir->i_ino); "inode 0x%lx.", vdir->i_ino);
goto err_out; goto err_out;
......
...@@ -168,7 +168,7 @@ int ntfs_index_lookup(const void *key, const int key_len, ...@@ -168,7 +168,7 @@ int ntfs_index_lookup(const void *key, const int key_len,
goto err_out; goto err_out;
} }
/* Find the index root attribute in the mft record. */ /* Find the index root attribute in the mft record. */
if (!lookup_attr(AT_INDEX_ROOT, idx_ni->name, idx_ni->name_len, if (!ntfs_attr_lookup(AT_INDEX_ROOT, idx_ni->name, idx_ni->name_len,
CASE_SENSITIVE, 0, NULL, 0, actx)) { CASE_SENSITIVE, 0, NULL, 0, actx)) {
ntfs_error(sb, "Index root attribute missing in inode 0x%lx.", ntfs_error(sb, "Index root attribute missing in inode 0x%lx.",
idx_ni->mft_no); idx_ni->mft_no);
......
...@@ -441,7 +441,7 @@ static int ntfs_is_extended_system_file(attr_search_context *ctx) ...@@ -441,7 +441,7 @@ static int ntfs_is_extended_system_file(attr_search_context *ctx)
nr_links = le16_to_cpu(ctx->mrec->link_count); nr_links = le16_to_cpu(ctx->mrec->link_count);
/* Loop through all hard links. */ /* Loop through all hard links. */
while (lookup_attr(AT_FILE_NAME, NULL, 0, 0, 0, NULL, 0, ctx)) { while (ntfs_attr_lookup(AT_FILE_NAME, NULL, 0, 0, 0, NULL, 0, ctx)) {
FILE_NAME_ATTR *file_name_attr; FILE_NAME_ATTR *file_name_attr;
ATTR_RECORD *attr = ctx->attr; ATTR_RECORD *attr = ctx->attr;
u8 *p, *p2; u8 *p, *p2;
...@@ -608,7 +608,7 @@ static int ntfs_read_locked_inode(struct inode *vi) ...@@ -608,7 +608,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
* in fact fail if the standard information is in an extent record, but * in fact fail if the standard information is in an extent record, but
* I don't think this actually ever happens. * I don't think this actually ever happens.
*/ */
if (!lookup_attr(AT_STANDARD_INFORMATION, NULL, 0, 0, 0, NULL, 0, if (!ntfs_attr_lookup(AT_STANDARD_INFORMATION, NULL, 0, 0, 0, NULL, 0,
ctx)) { ctx)) {
/* /*
* TODO: We should be performing a hot fix here (if the recover * TODO: We should be performing a hot fix here (if the recover
...@@ -647,7 +647,7 @@ static int ntfs_read_locked_inode(struct inode *vi) ...@@ -647,7 +647,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
/* Find the attribute list attribute if present. */ /* Find the attribute list attribute if present. */
reinit_attr_search_ctx(ctx); reinit_attr_search_ctx(ctx);
if (lookup_attr(AT_ATTRIBUTE_LIST, NULL, 0, 0, 0, NULL, 0, ctx)) { if (ntfs_attr_lookup(AT_ATTRIBUTE_LIST, NULL, 0, 0, 0, NULL, 0, ctx)) {
if (vi->i_ino == FILE_MFT) if (vi->i_ino == FILE_MFT)
goto skip_attr_list_load; goto skip_attr_list_load;
ntfs_debug("Attribute list found in inode 0x%lx.", vi->i_ino); ntfs_debug("Attribute list found in inode 0x%lx.", vi->i_ino);
...@@ -734,7 +734,7 @@ static int ntfs_read_locked_inode(struct inode *vi) ...@@ -734,7 +734,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
/* It is a directory, find index root attribute. */ /* It is a directory, find index root attribute. */
reinit_attr_search_ctx(ctx); reinit_attr_search_ctx(ctx);
if (!lookup_attr(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, if (!ntfs_attr_lookup(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0,
NULL, 0, ctx)) { NULL, 0, ctx)) {
// FIXME: File is corrupt! Hot-fix with empty index // FIXME: File is corrupt! Hot-fix with empty index
// root attribute if recovery option is set. // root attribute if recovery option is set.
...@@ -850,8 +850,8 @@ static int ntfs_read_locked_inode(struct inode *vi) ...@@ -850,8 +850,8 @@ static int ntfs_read_locked_inode(struct inode *vi)
NInoSetIndexAllocPresent(ni); NInoSetIndexAllocPresent(ni);
/* Find index allocation attribute. */ /* Find index allocation attribute. */
reinit_attr_search_ctx(ctx); reinit_attr_search_ctx(ctx);
if (!lookup_attr(AT_INDEX_ALLOCATION, I30, 4, CASE_SENSITIVE, if (!ntfs_attr_lookup(AT_INDEX_ALLOCATION, I30, 4,
0, NULL, 0, ctx)) { CASE_SENSITIVE, 0, NULL, 0, ctx)) {
ntfs_error(vi->i_sb, "$INDEX_ALLOCATION attribute " ntfs_error(vi->i_sb, "$INDEX_ALLOCATION attribute "
"is not present but $INDEX_ROOT " "is not present but $INDEX_ROOT "
"indicated it is."); "indicated it is.");
...@@ -946,7 +946,7 @@ static int ntfs_read_locked_inode(struct inode *vi) ...@@ -946,7 +946,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
ni->name_len = 0; ni->name_len = 0;
/* Find first extent of the unnamed data attribute. */ /* Find first extent of the unnamed data attribute. */
if (!lookup_attr(AT_DATA, NULL, 0, 0, 0, NULL, 0, ctx)) { if (!ntfs_attr_lookup(AT_DATA, NULL, 0, 0, 0, NULL, 0, ctx)) {
vi->i_size = ni->initialized_size = vi->i_size = ni->initialized_size =
ni->allocated_size = 0LL; ni->allocated_size = 0LL;
/* /*
...@@ -1169,8 +1169,8 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi) ...@@ -1169,8 +1169,8 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
} }
/* Find the attribute. */ /* Find the attribute. */
if (!lookup_attr(ni->type, ni->name, ni->name_len, CASE_SENSITIVE, 0, if (!ntfs_attr_lookup(ni->type, ni->name, ni->name_len, CASE_SENSITIVE,
NULL, 0, ctx)) 0, NULL, 0, ctx))
goto unm_err_out; goto unm_err_out;
if (!ctx->attr->non_resident) { if (!ctx->attr->non_resident) {
...@@ -1425,8 +1425,8 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi) ...@@ -1425,8 +1425,8 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
goto unm_err_out; goto unm_err_out;
} }
/* Find the index root attribute. */ /* Find the index root attribute. */
if (!lookup_attr(AT_INDEX_ROOT, ni->name, ni->name_len, CASE_SENSITIVE, if (!ntfs_attr_lookup(AT_INDEX_ROOT, ni->name, ni->name_len,
0, NULL, 0, ctx)) { CASE_SENSITIVE, 0, NULL, 0, ctx)) {
ntfs_error(vi->i_sb, "$INDEX_ROOT attribute is missing."); ntfs_error(vi->i_sb, "$INDEX_ROOT attribute is missing.");
goto unm_err_out; goto unm_err_out;
} }
...@@ -1506,7 +1506,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi) ...@@ -1506,7 +1506,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
NInoSetIndexAllocPresent(ni); NInoSetIndexAllocPresent(ni);
/* Find index allocation attribute. */ /* Find index allocation attribute. */
reinit_attr_search_ctx(ctx); reinit_attr_search_ctx(ctx);
if (!lookup_attr(AT_INDEX_ALLOCATION, ni->name, ni->name_len, if (!ntfs_attr_lookup(AT_INDEX_ALLOCATION, ni->name, ni->name_len,
CASE_SENSITIVE, 0, NULL, 0, ctx)) { CASE_SENSITIVE, 0, NULL, 0, ctx)) {
ntfs_error(vi->i_sb, "$INDEX_ALLOCATION attribute is not " ntfs_error(vi->i_sb, "$INDEX_ALLOCATION attribute is not "
"present but $INDEX_ROOT indicated it is."); "present but $INDEX_ROOT indicated it is.");
...@@ -1619,16 +1619,16 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi) ...@@ -1619,16 +1619,16 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
* is not initialized and hence we cannot get at the contents of mft records * is not initialized and hence we cannot get at the contents of mft records
* by calling map_mft_record*(). * by calling map_mft_record*().
* *
* Further it needs to cope with the circular references problem, i.e. can't * Further it needs to cope with the circular references problem, i.e. cannot
* load any attributes other than $ATTRIBUTE_LIST until $DATA is loaded, because * load any attributes other than $ATTRIBUTE_LIST until $DATA is loaded, because
* we don't know where the other extent mft records are yet and again, because * we do not know where the other extent mft records are yet and again, because
* we cannot call map_mft_record*() yet. Obviously this applies only when an * we cannot call map_mft_record*() yet. Obviously this applies only when an
* attribute list is actually present in $MFT inode. * attribute list is actually present in $MFT inode.
* *
* We solve these problems by starting with the $DATA attribute before anything * We solve these problems by starting with the $DATA attribute before anything
* else and iterating using lookup_attr($DATA) over all extents. As each extent * else and iterating using ntfs_attr_lookup($DATA) over all extents. As each
* is found, we decompress_mapping_pairs() including the implied * extent is found, we decompress_mapping_pairs() including the implied
* merge_runlists(). Each step of the iteration necessarily provides * ntfs_merge_runlists(). Each step of the iteration necessarily provides
* sufficient information for the next step to complete. * sufficient information for the next step to complete.
* *
* This should work but there are two possible pit falls (see inline comments * This should work but there are two possible pit falls (see inline comments
...@@ -1726,7 +1726,7 @@ int ntfs_read_inode_mount(struct inode *vi) ...@@ -1726,7 +1726,7 @@ int ntfs_read_inode_mount(struct inode *vi)
} }
/* Find the attribute list attribute if present. */ /* Find the attribute list attribute if present. */
if (lookup_attr(AT_ATTRIBUTE_LIST, NULL, 0, 0, 0, NULL, 0, ctx)) { if (ntfs_attr_lookup(AT_ATTRIBUTE_LIST, NULL, 0, 0, 0, NULL, 0, ctx)) {
ATTR_LIST_ENTRY *al_entry, *next_al_entry; ATTR_LIST_ENTRY *al_entry, *next_al_entry;
u8 *al_end; u8 *al_end;
...@@ -1860,7 +1860,7 @@ int ntfs_read_inode_mount(struct inode *vi) ...@@ -1860,7 +1860,7 @@ int ntfs_read_inode_mount(struct inode *vi)
/* Now load all attribute extents. */ /* Now load all attribute extents. */
attr = NULL; attr = NULL;
next_vcn = last_vcn = highest_vcn = 0; next_vcn = last_vcn = highest_vcn = 0;
while (lookup_attr(AT_DATA, NULL, 0, 0, next_vcn, NULL, 0, ctx)) { while (ntfs_attr_lookup(AT_DATA, NULL, 0, 0, next_vcn, NULL, 0, ctx)) {
runlist_element *nrl; runlist_element *nrl;
/* Cache the current attribute. */ /* Cache the current attribute. */
...@@ -2347,7 +2347,7 @@ int ntfs_write_inode(struct inode *vi, int sync) ...@@ -2347,7 +2347,7 @@ int ntfs_write_inode(struct inode *vi, int sync)
err = -ENOMEM; err = -ENOMEM;
goto unm_err_out; goto unm_err_out;
} }
if (unlikely(!lookup_attr(AT_STANDARD_INFORMATION, NULL, 0, if (unlikely(!ntfs_attr_lookup(AT_STANDARD_INFORMATION, NULL, 0,
CASE_SENSITIVE, 0, NULL, 0, ctx))) { CASE_SENSITIVE, 0, NULL, 0, ctx))) {
put_attr_search_ctx(ctx); put_attr_search_ctx(ctx);
err = -ENOENT; err = -ENOENT;
......
...@@ -205,8 +205,8 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent, ...@@ -205,8 +205,8 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
ATTR_RECORD *a; ATTR_RECORD *a;
u32 val_len; u32 val_len;
if (!lookup_attr(AT_FILE_NAME, NULL, 0, 0, 0, NULL, 0, if (!ntfs_attr_lookup(AT_FILE_NAME, NULL, 0, 0, 0,
ctx)) { NULL, 0, ctx)) {
ntfs_error(vol->sb, "Inode corrupt: No WIN32 " ntfs_error(vol->sb, "Inode corrupt: No WIN32 "
"namespace counterpart to DOS " "namespace counterpart to DOS "
"file name. Run chkdsk."); "file name. Run chkdsk.");
...@@ -385,8 +385,8 @@ struct dentry *ntfs_get_parent(struct dentry *child_dent) ...@@ -385,8 +385,8 @@ struct dentry *ntfs_get_parent(struct dentry *child_dent)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
try_next: try_next:
if (unlikely(!lookup_attr(AT_FILE_NAME, NULL, 0, CASE_SENSITIVE, 0, if (unlikely(!ntfs_attr_lookup(AT_FILE_NAME, NULL, 0, CASE_SENSITIVE,
NULL, 0, ctx))) { 0, NULL, 0, ctx))) {
put_attr_search_ctx(ctx); put_attr_search_ctx(ctx);
unmap_mft_record(ni); unmap_mft_record(ni);
ntfs_error(vi->i_sb, "Inode 0x%lx does not have a file name " ntfs_error(vi->i_sb, "Inode 0x%lx does not have a file name "
......
...@@ -336,7 +336,8 @@ static int ntfs_write_volume_flags(ntfs_volume *vol, const VOLUME_FLAGS flags) ...@@ -336,7 +336,8 @@ static int ntfs_write_volume_flags(ntfs_volume *vol, const VOLUME_FLAGS flags)
err = -ENOMEM; err = -ENOMEM;
goto put_unm_err_out; goto put_unm_err_out;
} }
if (!lookup_attr(AT_VOLUME_INFORMATION, NULL, 0, 0, 0, NULL, 0, ctx)) { if (!ntfs_attr_lookup(AT_VOLUME_INFORMATION, NULL, 0, 0, 0, NULL, 0,
ctx)) {
err = -EIO; err = -EIO;
goto put_unm_err_out; goto put_unm_err_out;
} }
...@@ -1432,8 +1433,8 @@ static BOOL load_system_files(ntfs_volume *vol) ...@@ -1432,8 +1433,8 @@ static BOOL load_system_files(ntfs_volume *vol)
ntfs_error(sb, "Failed to get attribute search context."); ntfs_error(sb, "Failed to get attribute search context.");
goto get_ctx_vol_failed; goto get_ctx_vol_failed;
} }
if (!lookup_attr(AT_VOLUME_INFORMATION, NULL, 0, 0, 0, NULL, 0, ctx) || if (!ntfs_attr_lookup(AT_VOLUME_INFORMATION, NULL, 0, 0, 0, NULL, 0,
ctx->attr->non_resident || ctx->attr->flags) { ctx) || ctx->attr->non_resident || ctx->attr->flags) {
err_put_vol: err_put_vol:
put_attr_search_ctx(ctx); put_attr_search_ctx(ctx);
get_ctx_vol_failed: get_ctx_vol_failed:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment