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:
- Fix scheduling latencies in ntfs_fill_super() by dropping the BKL
because the code itself is using the ntfs_lock semaphore which
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.
......
......@@ -402,7 +402,7 @@ int ntfs_readpage(struct file *file, struct page *page)
err = -ENOMEM;
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))) {
err = -ENOENT;
goto put_unm_err_out;
......@@ -1122,7 +1122,7 @@ static int ntfs_writepage(struct page *page, struct writeback_control *wbc)
err = -ENOMEM;
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))) {
err = -ENOENT;
goto err_out;
......@@ -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
* region written to to ntfs_commit_write(). The reason for doing this
* 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(),
* unmap_mft_record().
* Which is obviously a very worthwhile save.
......@@ -1896,7 +1896,7 @@ static int ntfs_commit_write(struct file *file, struct page *page,
err = -ENOMEM;
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))) {
err = -ENOENT;
goto err_out;
......
This diff is collapsed.
......@@ -46,7 +46,7 @@ typedef enum {
* attr_search_context - used in attribute search functions
* @mrec: buffer containing mft record to 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
* 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);
extern runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn,
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 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 VCN lowest_vcn, const u8 *val, const u32 val_len,
attr_search_context *ctx);
......
......@@ -106,8 +106,8 @@ MFT_REF ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
goto err_out;
}
/* Find the index root attribute in the mft record. */
if (!lookup_attr(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, NULL, 0,
ctx)) {
if (!ntfs_attr_lookup(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, NULL,
0, ctx)) {
ntfs_error(sb, "Index root attribute missing in directory "
"inode 0x%lx.", dir_ni->mft_no);
err = -EIO;
......@@ -655,8 +655,8 @@ u64 ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
goto err_out;
}
/* Find the index root attribute in the mft record. */
if (!lookup_attr(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, NULL, 0,
ctx)) {
if (!ntfs_attr_lookup(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0, NULL,
0, ctx)) {
ntfs_error(sb, "Index root attribute missing in directory "
"inode 0x%lx.", dir_ni->mft_no);
err = -EIO;
......@@ -1183,8 +1183,8 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
/* Get the offset into the index root attribute. */
ir_pos = (s64)fpos;
/* Find the index root attribute in the mft record. */
if (unlikely(!lookup_attr(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0,
NULL, 0, ctx))) {
if (unlikely(!ntfs_attr_lookup(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE,
0, NULL, 0, ctx))) {
ntfs_error(sb, "Index root attribute missing in directory "
"inode 0x%lx.", vdir->i_ino);
goto err_out;
......
......@@ -168,7 +168,7 @@ int ntfs_index_lookup(const void *key, const int key_len,
goto err_out;
}
/* 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)) {
ntfs_error(sb, "Index root attribute missing in inode 0x%lx.",
idx_ni->mft_no);
......
......@@ -441,7 +441,7 @@ static int ntfs_is_extended_system_file(attr_search_context *ctx)
nr_links = le16_to_cpu(ctx->mrec->link_count);
/* 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;
ATTR_RECORD *attr = ctx->attr;
u8 *p, *p2;
......@@ -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
* 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)) {
/*
* 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)
/* Find the attribute list attribute if present. */
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)
goto skip_attr_list_load;
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)
/* It is a directory, find index root attribute. */
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)) {
// FIXME: File is corrupt! Hot-fix with empty index
// root attribute if recovery option is set.
......@@ -850,8 +850,8 @@ static int ntfs_read_locked_inode(struct inode *vi)
NInoSetIndexAllocPresent(ni);
/* Find index allocation attribute. */
reinit_attr_search_ctx(ctx);
if (!lookup_attr(AT_INDEX_ALLOCATION, I30, 4, CASE_SENSITIVE,
0, NULL, 0, ctx)) {
if (!ntfs_attr_lookup(AT_INDEX_ALLOCATION, I30, 4,
CASE_SENSITIVE, 0, NULL, 0, ctx)) {
ntfs_error(vi->i_sb, "$INDEX_ALLOCATION attribute "
"is not present but $INDEX_ROOT "
"indicated it is.");
......@@ -946,7 +946,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
ni->name_len = 0;
/* 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 =
ni->allocated_size = 0LL;
/*
......@@ -1169,8 +1169,8 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
}
/* Find the attribute. */
if (!lookup_attr(ni->type, ni->name, ni->name_len, CASE_SENSITIVE, 0,
NULL, 0, ctx))
if (!ntfs_attr_lookup(ni->type, ni->name, ni->name_len, CASE_SENSITIVE,
0, NULL, 0, ctx))
goto unm_err_out;
if (!ctx->attr->non_resident) {
......@@ -1425,8 +1425,8 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
goto unm_err_out;
}
/* Find the index root attribute. */
if (!lookup_attr(AT_INDEX_ROOT, ni->name, ni->name_len, CASE_SENSITIVE,
0, NULL, 0, ctx)) {
if (!ntfs_attr_lookup(AT_INDEX_ROOT, ni->name, ni->name_len,
CASE_SENSITIVE, 0, NULL, 0, ctx)) {
ntfs_error(vi->i_sb, "$INDEX_ROOT attribute is missing.");
goto unm_err_out;
}
......@@ -1506,7 +1506,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
NInoSetIndexAllocPresent(ni);
/* Find index allocation attribute. */
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)) {
ntfs_error(vi->i_sb, "$INDEX_ALLOCATION attribute is not "
"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)
* is not initialized and hence we cannot get at the contents of mft records
* 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
* we don't 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 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
* attribute list is actually present in $MFT inode.
*
* 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
* is found, we decompress_mapping_pairs() including the implied
* merge_runlists(). Each step of the iteration necessarily provides
* else and iterating using ntfs_attr_lookup($DATA) over all extents. As each
* extent is found, we decompress_mapping_pairs() including the implied
* ntfs_merge_runlists(). Each step of the iteration necessarily provides
* sufficient information for the next step to complete.
*
* 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)
}
/* 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;
u8 *al_end;
......@@ -1860,7 +1860,7 @@ int ntfs_read_inode_mount(struct inode *vi)
/* Now load all attribute extents. */
attr = NULL;
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;
/* Cache the current attribute. */
......@@ -2347,7 +2347,7 @@ int ntfs_write_inode(struct inode *vi, int sync)
err = -ENOMEM;
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))) {
put_attr_search_ctx(ctx);
err = -ENOENT;
......
......@@ -205,8 +205,8 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
ATTR_RECORD *a;
u32 val_len;
if (!lookup_attr(AT_FILE_NAME, NULL, 0, 0, 0, NULL, 0,
ctx)) {
if (!ntfs_attr_lookup(AT_FILE_NAME, NULL, 0, 0, 0,
NULL, 0, ctx)) {
ntfs_error(vol->sb, "Inode corrupt: No WIN32 "
"namespace counterpart to DOS "
"file name. Run chkdsk.");
......@@ -385,8 +385,8 @@ struct dentry *ntfs_get_parent(struct dentry *child_dent)
return ERR_PTR(-ENOMEM);
}
try_next:
if (unlikely(!lookup_attr(AT_FILE_NAME, NULL, 0, CASE_SENSITIVE, 0,
NULL, 0, ctx))) {
if (unlikely(!ntfs_attr_lookup(AT_FILE_NAME, NULL, 0, CASE_SENSITIVE,
0, NULL, 0, ctx))) {
put_attr_search_ctx(ctx);
unmap_mft_record(ni);
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)
err = -ENOMEM;
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;
goto put_unm_err_out;
}
......@@ -1432,8 +1433,8 @@ static BOOL load_system_files(ntfs_volume *vol)
ntfs_error(sb, "Failed to get attribute search context.");
goto get_ctx_vol_failed;
}
if (!lookup_attr(AT_VOLUME_INFORMATION, NULL, 0, 0, 0, NULL, 0, ctx) ||
ctx->attr->non_resident || ctx->attr->flags) {
if (!ntfs_attr_lookup(AT_VOLUME_INFORMATION, NULL, 0, 0, 0, NULL, 0,
ctx) || ctx->attr->non_resident || ctx->attr->flags) {
err_put_vol:
put_attr_search_ctx(ctx);
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