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

NTFS: Rename {{re,}init,get,put}_attr_search_ctx() to

      ntfs_attr_{{re,}init,get,put}_search_ctx() as well as the type
      attr_search_context to ntfs_attr_search_ctx.
Signed-off-by: default avatarAnton Altaparmakov <aia21@cantab.net>
parent c8d3aeee
......@@ -35,6 +35,9 @@ ToDo/Notes:
- 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.
- Rename {{re,}init,get,put}_attr_search_ctx() to
ntfs_attr_{{re,}init,get,put}_search_ctx() as well as the type
attr_search_context to ntfs_attr_search_ctx.
2.1.17 - Fix bugs in mount time error code paths and other updates.
......
......@@ -348,7 +348,7 @@ int ntfs_readpage(struct file *file, struct page *page)
s64 attr_pos;
ntfs_inode *ni, *base_ni;
u8 *kaddr;
attr_search_context *ctx;
ntfs_attr_search_ctx *ctx;
MFT_RECORD *mrec;
u32 attr_len;
int err = 0;
......@@ -397,7 +397,7 @@ int ntfs_readpage(struct file *file, struct page *page)
err = PTR_ERR(mrec);
goto err_out;
}
ctx = get_attr_search_ctx(base_ni, mrec);
ctx = ntfs_attr_get_search_ctx(base_ni, mrec);
if (unlikely(!ctx)) {
err = -ENOMEM;
goto unm_err_out;
......@@ -433,7 +433,7 @@ int ntfs_readpage(struct file *file, struct page *page)
SetPageUptodate(page);
put_unm_err_out:
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unm_err_out:
unmap_mft_record(base_ni);
err_out:
......@@ -1030,7 +1030,7 @@ static int ntfs_writepage(struct page *page, struct writeback_control *wbc)
struct inode *vi;
ntfs_inode *ni, *base_ni;
char *kaddr;
attr_search_context *ctx;
ntfs_attr_search_ctx *ctx;
MFT_RECORD *m;
u32 attr_len, bytes;
int err;
......@@ -1117,7 +1117,7 @@ static int ntfs_writepage(struct page *page, struct writeback_control *wbc)
ctx = NULL;
goto err_out;
}
ctx = get_attr_search_ctx(base_ni, m);
ctx = ntfs_attr_get_search_ctx(base_ni, m);
if (unlikely(!ctx)) {
err = -ENOMEM;
goto err_out;
......@@ -1201,7 +1201,7 @@ static int ntfs_writepage(struct page *page, struct writeback_control *wbc)
/* Mark the mft record dirty, so it gets written back. */
mark_mft_record_dirty(ctx->ntfs_ino);
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(base_ni);
return 0;
err_out:
......@@ -1221,7 +1221,7 @@ static int ntfs_writepage(struct page *page, struct writeback_control *wbc)
}
unlock_page(page);
if (ctx)
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
if (m)
unmap_mft_record(base_ni);
return err;
......@@ -1683,9 +1683,9 @@ 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(), ntfs_attr_lookup(),
* kmap_atomic(), kunmap_atomic(), put_attr_search_ctx(),
* unmap_mft_record().
* map_mft_record(), ntfs_attr_get_search_ctx(),
* ntfs_attr_lookup(), kmap_atomic(), kunmap_atomic(),
* ntfs_attr_put_search_ctx(), unmap_mft_record().
* Which is obviously a very worthwhile save.
*
* Thus we just return success now...
......@@ -1804,7 +1804,7 @@ static int ntfs_commit_write(struct file *file, struct page *page,
struct inode *vi;
ntfs_inode *ni, *base_ni;
char *kaddr, *kattr;
attr_search_context *ctx;
ntfs_attr_search_ctx *ctx;
MFT_RECORD *m;
u32 attr_len, bytes;
int err;
......@@ -1891,7 +1891,7 @@ static int ntfs_commit_write(struct file *file, struct page *page,
ctx = NULL;
goto err_out;
}
ctx = get_attr_search_ctx(base_ni, m);
ctx = ntfs_attr_get_search_ctx(base_ni, m);
if (unlikely(!ctx)) {
err = -ENOMEM;
goto err_out;
......@@ -1966,7 +1966,7 @@ static int ntfs_commit_write(struct file *file, struct page *page,
/* Mark the mft record dirty, so it gets written back. */
mark_mft_record_dirty(ctx->ntfs_ino);
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(base_ni);
ntfs_debug("Done.");
return 0;
......@@ -1993,7 +1993,7 @@ static int ntfs_commit_write(struct file *file, struct page *page,
SetPageError(page);
}
if (ctx)
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
if (m)
unmap_mft_record(base_ni);
return err;
......
......@@ -946,7 +946,7 @@ runlist_element *decompress_mapping_pairs(const ntfs_volume *vol,
int ntfs_map_runlist(ntfs_inode *ni, VCN vcn)
{
ntfs_inode *base_ni;
attr_search_context *ctx;
ntfs_attr_search_ctx *ctx;
MFT_RECORD *mrec;
int err = 0;
......@@ -961,14 +961,14 @@ int ntfs_map_runlist(ntfs_inode *ni, VCN vcn)
mrec = map_mft_record(base_ni);
if (IS_ERR(mrec))
return PTR_ERR(mrec);
ctx = get_attr_search_ctx(base_ni, mrec);
ctx = ntfs_attr_get_search_ctx(base_ni, mrec);
if (!ctx) {
err = -ENOMEM;
goto err_out;
}
if (!ntfs_attr_lookup(ni->type, ni->name, ni->name_len, CASE_SENSITIVE,
vcn, NULL, 0, ctx)) {
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
err = -ENOENT;
goto err_out;
}
......@@ -987,7 +987,7 @@ int ntfs_map_runlist(ntfs_inode *ni, VCN vcn)
}
up_write(&ni->runlist.lock);
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
err_out:
unmap_mft_record(base_ni);
return err;
......@@ -1199,7 +1199,7 @@ runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn,
*/
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)
const u8 *val, const u32 val_len, ntfs_attr_search_ctx *ctx)
{
ATTR_RECORD *a;
ntfs_volume *vol;
......@@ -1440,13 +1440,13 @@ int load_attribute_list(ntfs_volume *vol, runlist *runlist, u8 *al_start,
* in there and return it.
*
* 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
* have been obtained from a call to ntfs_attr_get_search_ctx(). On subsequent
* calls @ctx->ntfs_ino can be any extent inode, too (@ctx->base_ntfs_ino is
* then the base inode).
*
* After finishing with the attribute/mft record you need to call
* put_attr_search_ctx() to cleanup the search context (unmapping any mapped
* inodes, etc).
* ntfs_attr_put_search_ctx() to cleanup the search context (unmapping any
* mapped inodes, etc).
*
* 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
......@@ -1459,7 +1459,7 @@ int load_attribute_list(ntfs_volume *vol, runlist *runlist, u8 *al_start,
static BOOL ntfs_external_attr_find(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)
const u8 *val, const u32 val_len, ntfs_attr_search_ctx *ctx)
{
ntfs_inode *base_ni, *ni;
ntfs_volume *vol;
......@@ -1692,7 +1692,7 @@ static BOOL ntfs_external_attr_find(const ATTR_TYPES type,
*
* FIXME: Do we really want to do this here? Think about it... (AIA)
*/
reinit_attr_search_ctx(ctx);
ntfs_attr_reinit_search_ctx(ctx);
ntfs_attr_find(type, name, name_len, ic, val, val_len, ctx);
ntfs_debug("Done, not found.");
return FALSE;
......@@ -1711,14 +1711,14 @@ static BOOL ntfs_external_attr_find(const ATTR_TYPES type,
*
* Find an attribute in an ntfs inode. 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().
* ntfs_attr_get_search_ctx().
*
* This function transparently handles attribute lists and @ctx is used to
* continue searches where they were left off at.
*
* After finishing with the attribute/mft record you need to call
* put_attr_search_ctx() to cleanup the search context (unmapping any mapped
* inodes, etc).
* ntfs_attr_put_search_ctx() to cleanup the search context (unmapping any
* mapped inodes, etc).
*
* 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
......@@ -1729,7 +1729,7 @@ static BOOL ntfs_external_attr_find(const ATTR_TYPES type,
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)
ntfs_attr_search_ctx *ctx)
{
ntfs_inode *base_ni;
......@@ -1748,14 +1748,14 @@ BOOL ntfs_attr_lookup(const ATTR_TYPES type, const ntfschar *name,
}
/**
* init_attr_search_ctx - initialize an attribute search context
* ntfs_attr_init_search_ctx - initialize an attribute search context
* @ctx: attribute search context to initialize
* @ni: ntfs inode with which to initialize the search context
* @mrec: mft record with which to initialize the search context
*
* Initialize the attribute search context @ctx with @ni and @mrec.
*/
static inline void init_attr_search_ctx(attr_search_context *ctx,
static inline void ntfs_attr_init_search_ctx(ntfs_attr_search_ctx *ctx,
ntfs_inode *ni, MFT_RECORD *mrec)
{
ctx->mrec = mrec;
......@@ -1770,7 +1770,7 @@ static inline void init_attr_search_ctx(attr_search_context *ctx,
}
/**
* reinit_attr_search_ctx - reinitialize an attribute search context
* ntfs_attr_reinit_search_ctx - reinitialize an attribute search context
* @ctx: attribute search context to reinitialize
*
* Reinitialize the attribute search context @ctx, unmapping an associated
......@@ -1779,7 +1779,7 @@ static inline void init_attr_search_ctx(attr_search_context *ctx,
* This is used when a search for a new attribute is being started to reset
* the search context to the beginning.
*/
void reinit_attr_search_ctx(attr_search_context *ctx)
void ntfs_attr_reinit_search_ctx(ntfs_attr_search_ctx *ctx)
{
if (likely(!ctx->base_ntfs_ino)) {
/* No attribute list. */
......@@ -1791,40 +1791,39 @@ void reinit_attr_search_ctx(attr_search_context *ctx)
} /* Attribute list. */
if (ctx->ntfs_ino != ctx->base_ntfs_ino)
unmap_extent_mft_record(ctx->ntfs_ino);
init_attr_search_ctx(ctx, ctx->base_ntfs_ino, ctx->base_mrec);
ntfs_attr_init_search_ctx(ctx, ctx->base_ntfs_ino, ctx->base_mrec);
return;
}
/**
* get_attr_search_ctx - allocate and initialize a new attribute search context
* ntfs_attr_get_search_ctx - allocate/initialize a new attribute search context
* @ni: ntfs inode with which to initialize the search context
* @mrec: mft record with which to initialize the search context
*
* Allocate a new attribute search context, initialize it with @ni and @mrec,
* and return it. Return NULL if allocation failed.
*/
attr_search_context *get_attr_search_ctx(ntfs_inode *ni, MFT_RECORD *mrec)
ntfs_attr_search_ctx *ntfs_attr_get_search_ctx(ntfs_inode *ni, MFT_RECORD *mrec)
{
attr_search_context *ctx;
ntfs_attr_search_ctx *ctx;
ctx = kmem_cache_alloc(ntfs_attr_ctx_cache, SLAB_NOFS);
if (ctx)
init_attr_search_ctx(ctx, ni, mrec);
ntfs_attr_init_search_ctx(ctx, ni, mrec);
return ctx;
}
/**
* put_attr_search_ctx - release an attribute search context
* ntfs_attr_put_search_ctx - release an attribute search context
* @ctx: attribute search context to free
*
* Release the attribute search context @ctx, unmapping an associated extent
* mft record if present.
*/
void put_attr_search_ctx(attr_search_context *ctx)
void ntfs_attr_put_search_ctx(ntfs_attr_search_ctx *ctx)
{
if (ctx->base_ntfs_ino && ctx->ntfs_ino != ctx->base_ntfs_ino)
unmap_extent_mft_record(ctx->ntfs_ino);
kmem_cache_free(ntfs_attr_ctx_cache, ctx);
return;
}
......@@ -43,7 +43,7 @@ typedef enum {
} LCN_SPECIAL_VALUES;
/**
* attr_search_context - used in attribute search functions
* ntfs_attr_search_ctx - 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 ntfs_attr_lookup() begins search with @attr, else after
......@@ -69,7 +69,7 @@ typedef struct {
ntfs_inode *base_ntfs_ino;
MFT_RECORD *base_mrec;
ATTR_RECORD *base_attr;
} attr_search_context;
} ntfs_attr_search_ctx;
extern runlist_element *decompress_mapping_pairs(const ntfs_volume *vol,
const ATTR_RECORD *attr, runlist_element *old_rl);
......@@ -83,12 +83,12 @@ extern runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn,
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);
const u32 val_len, ntfs_attr_search_ctx *ctx);
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);
ntfs_attr_search_ctx *ctx);
extern int load_attribute_list(ntfs_volume *vol, runlist *rl, u8 *al_start,
const s64 size, const s64 initialized_size);
......@@ -100,9 +100,9 @@ static inline s64 attribute_value_length(const ATTR_RECORD *a)
return sle64_to_cpu(a->data.non_resident.data_size);
}
extern void reinit_attr_search_ctx(attr_search_context *ctx);
extern attr_search_context *get_attr_search_ctx(ntfs_inode *ni,
extern void ntfs_attr_reinit_search_ctx(ntfs_attr_search_ctx *ctx);
extern ntfs_attr_search_ctx *ntfs_attr_get_search_ctx(ntfs_inode *ni,
MFT_RECORD *mrec);
extern void put_attr_search_ctx(attr_search_context *ctx);
extern void ntfs_attr_put_search_ctx(ntfs_attr_search_ctx *ctx);
#endif /* _LINUX_NTFS_ATTRIB_H */
......@@ -83,7 +83,7 @@ MFT_REF ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
INDEX_ALLOCATION *ia;
u8 *index_end;
u64 mref;
attr_search_context *ctx;
ntfs_attr_search_ctx *ctx;
int err, rc;
VCN vcn, old_vcn;
struct address_space *ia_mapping;
......@@ -100,7 +100,7 @@ MFT_REF ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
-PTR_ERR(m));
return ERR_MREF(PTR_ERR(m));
}
ctx = get_attr_search_ctx(dir_ni, m);
ctx = ntfs_attr_get_search_ctx(dir_ni, m);
if (unlikely(!ctx)) {
err = -ENOMEM;
goto err_out;
......@@ -179,7 +179,7 @@ MFT_REF ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
*res = NULL;
}
mref = le64_to_cpu(ie->data.dir.indexed_file);
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(dir_ni);
return mref;
}
......@@ -278,7 +278,7 @@ MFT_REF ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
*/
if (!(ie->flags & INDEX_ENTRY_NODE)) {
if (name) {
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(dir_ni);
return name->mref;
}
......@@ -301,7 +301,7 @@ MFT_REF ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
* We are done with the index root and the mft record. Release them,
* otherwise we deadlock with ntfs_map_page().
*/
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(dir_ni);
m = NULL;
ctx = NULL;
......@@ -582,7 +582,7 @@ MFT_REF ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
ntfs_unmap_page(page);
err_out:
if (ctx)
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
if (m)
unmap_mft_record(dir_ni);
if (name) {
......@@ -634,7 +634,7 @@ u64 ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
INDEX_ALLOCATION *ia;
u8 *index_end;
u64 mref;
attr_search_context *ctx;
ntfs_attr_search_ctx *ctx;
int err, rc;
IGNORE_CASE_BOOL ic;
VCN vcn, old_vcn;
......@@ -649,7 +649,7 @@ u64 ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
-PTR_ERR(m));
return ERR_MREF(PTR_ERR(m));
}
ctx = get_attr_search_ctx(dir_ni, m);
ctx = ntfs_attr_get_search_ctx(dir_ni, m);
if (!ctx) {
err = -ENOMEM;
goto err_out;
......@@ -710,7 +710,7 @@ u64 ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
vol->upcase, vol->upcase_len)) {
found_it:
mref = le64_to_cpu(ie->data.dir.indexed_file);
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(dir_ni);
return mref;
}
......@@ -776,7 +776,7 @@ u64 ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
* We are done with the index root and the mft record. Release them,
* otherwise we deadlock with ntfs_map_page().
*/
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(dir_ni);
m = NULL;
ctx = NULL;
......@@ -979,7 +979,7 @@ u64 ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const ntfschar *uname,
ntfs_unmap_page(page);
err_out:
if (ctx)
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
if (m)
unmap_mft_record(dir_ni);
return ERR_MREF(err);
......@@ -1125,7 +1125,7 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
struct address_space *ia_mapping, *bmp_mapping;
struct page *bmp_page = NULL, *ia_page = NULL;
u8 *kaddr, *bmp, *index_end;
attr_search_context *ctx;
ntfs_attr_search_ctx *ctx;
fpos = filp->f_pos;
ntfs_debug("Entering for inode 0x%lx, fpos 0x%llx.",
......@@ -1175,7 +1175,7 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
m = NULL;
goto err_out;
}
ctx = get_attr_search_ctx(ndir, m);
ctx = ntfs_attr_get_search_ctx(ndir, m);
if (unlikely(!ctx)) {
err = -ENOMEM;
goto err_out;
......@@ -1208,7 +1208,7 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
/* Copy the index root value (it has been verified in read_inode). */
memcpy(ir, (u8*)ctx->attr +
le16_to_cpu(ctx->attr->data.resident.value_offset), rc);
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(ndir);
ctx = NULL;
m = NULL;
......@@ -1460,7 +1460,7 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
if (name)
kfree(name);
if (ctx)
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
if (m)
unmap_mft_record(ndir);
if (!err)
......
......@@ -65,7 +65,7 @@ void ntfs_index_ctx_put(ntfs_index_context *ictx)
if (ictx->entry) {
if (ictx->is_in_root) {
if (ictx->actx)
put_attr_search_ctx(ictx->actx);
ntfs_attr_put_search_ctx(ictx->actx);
if (ictx->base_ni)
unmap_mft_record(ictx->base_ni);
} else {
......@@ -134,7 +134,7 @@ int ntfs_index_lookup(const void *key, const int key_len,
INDEX_ENTRY *ie;
INDEX_ALLOCATION *ia;
u8 *index_end;
attr_search_context *actx;
ntfs_attr_search_ctx *actx;
int rc, err = 0;
VCN vcn, old_vcn;
struct address_space *ia_mapping;
......@@ -162,7 +162,7 @@ int ntfs_index_lookup(const void *key, const int key_len,
-PTR_ERR(m));
return PTR_ERR(m);
}
actx = get_attr_search_ctx(base_ni, m);
actx = ntfs_attr_get_search_ctx(base_ni, m);
if (unlikely(!actx)) {
err = -ENOMEM;
goto err_out;
......@@ -269,7 +269,7 @@ int ntfs_index_lookup(const void *key, const int key_len,
* We are done with the index root and the mft record. Release them,
* otherwise we deadlock with ntfs_map_page().
*/
put_attr_search_ctx(actx);
ntfs_attr_put_search_ctx(actx);
unmap_mft_record(base_ni);
m = NULL;
actx = NULL;
......@@ -448,7 +448,7 @@ int ntfs_index_lookup(const void *key, const int key_len,
ntfs_unmap_page(page);
err_out:
if (actx)
put_attr_search_ctx(actx);
ntfs_attr_put_search_ctx(actx);
if (m)
unmap_mft_record(base_ni);
return err;
......
......@@ -78,7 +78,7 @@ typedef struct {
u16 data_len;
BOOL is_in_root;
INDEX_ROOT *ir;
attr_search_context *actx;
ntfs_attr_search_ctx *actx;
ntfs_inode *base_ni;
INDEX_ALLOCATION *ia;
struct page *page;
......
......@@ -430,12 +430,12 @@ inline ntfs_inode *ntfs_new_extent_inode(struct super_block *sb,
* 0: file is not in $Extend directory
* -EIO: file is corrupt
*/
static int ntfs_is_extended_system_file(attr_search_context *ctx)
static int ntfs_is_extended_system_file(ntfs_attr_search_ctx *ctx)
{
int nr_links;
/* Restart search. */
reinit_attr_search_ctx(ctx);
ntfs_attr_reinit_search_ctx(ctx);
/* Get number of hard links. */
nr_links = le16_to_cpu(ctx->mrec->link_count);
......@@ -525,7 +525,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
ntfs_inode *ni;
MFT_RECORD *m;
STANDARD_INFORMATION *si;
attr_search_context *ctx;
ntfs_attr_search_ctx *ctx;
int err = 0;
ntfs_debug("Entering for i_ino 0x%lx.", vi->i_ino);
......@@ -557,7 +557,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
err = PTR_ERR(m);
goto err_out;
}
ctx = get_attr_search_ctx(ni, m);
ctx = ntfs_attr_get_search_ctx(ni, m);
if (!ctx) {
err = -ENOMEM;
goto unm_err_out;
......@@ -646,7 +646,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
vi->i_atime = ntfs2utc(si->last_access_time);
/* Find the attribute list attribute if present. */
reinit_attr_search_ctx(ctx);
ntfs_attr_reinit_search_ctx(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;
......@@ -733,7 +733,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
char *ir_end, *index_end;
/* It is a directory, find index root attribute. */
reinit_attr_search_ctx(ctx);
ntfs_attr_reinit_search_ctx(ctx);
if (!ntfs_attr_lookup(AT_INDEX_ROOT, I30, 4, CASE_SENSITIVE, 0,
NULL, 0, ctx)) {
// FIXME: File is corrupt! Hot-fix with empty index
......@@ -841,7 +841,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
vi->i_size = ni->initialized_size =
ni->allocated_size = 0;
/* We are done with the mft record, so we release it. */
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(ni);
m = NULL;
ctx = NULL;
......@@ -849,7 +849,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
} /* LARGE_INDEX: Index allocation present. Setup state. */
NInoSetIndexAllocPresent(ni);
/* Find index allocation attribute. */
reinit_attr_search_ctx(ctx);
ntfs_attr_reinit_search_ctx(ctx);
if (!ntfs_attr_lookup(AT_INDEX_ALLOCATION, I30, 4,
CASE_SENSITIVE, 0, NULL, 0, ctx)) {
ntfs_error(vi->i_sb, "$INDEX_ALLOCATION attribute "
......@@ -894,7 +894,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
* We are done with the mft record, so we release it. Otherwise
* we would deadlock in ntfs_attr_iget().
*/
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(ni);
m = NULL;
ctx = NULL;
......@@ -938,7 +938,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
vi->i_mapping->a_ops = &ntfs_mst_aops;
} else {
/* It is a file. */
reinit_attr_search_ctx(ctx);
ntfs_attr_reinit_search_ctx(ctx);
/* Setup the data attribute, even if not present. */
ni->type = AT_DATA;
......@@ -1059,7 +1059,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
}
no_data_attr_special_case:
/* We are done with the mft record, so we release it. */
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(ni);
m = NULL;
ctx = NULL;
......@@ -1098,7 +1098,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
if (!err)
err = -EIO;
if (ctx)
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
if (m)
unmap_mft_record(ni);
err_out:
......@@ -1133,7 +1133,7 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
ntfs_volume *vol = NTFS_SB(vi->i_sb);
ntfs_inode *ni, *base_ni;
MFT_RECORD *m;
attr_search_context *ctx;
ntfs_attr_search_ctx *ctx;
int err = 0;
ntfs_debug("Entering for i_ino 0x%lx.", vi->i_ino);
......@@ -1162,7 +1162,7 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
err = PTR_ERR(m);
goto err_out;
}
ctx = get_attr_search_ctx(base_ni, m);
ctx = ntfs_attr_get_search_ctx(base_ni, m);
if (!ctx) {
err = -ENOMEM;
goto unm_err_out;
......@@ -1333,7 +1333,7 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
ni->ext.base_ntfs_ino = base_ni;
ni->nr_extents = -1;
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(base_ni);
ntfs_debug("Done.");
......@@ -1343,7 +1343,7 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
if (!err)
err = -EIO;
if (ctx)
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(base_ni);
err_out:
ntfs_error(vi->i_sb, "Failed with error code %i while reading "
......@@ -1392,7 +1392,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
ntfs_inode *ni, *base_ni, *bni;
struct inode *bvi;
MFT_RECORD *m;
attr_search_context *ctx;
ntfs_attr_search_ctx *ctx;
INDEX_ROOT *ir;
u8 *ir_end, *index_end;
int err = 0;
......@@ -1419,7 +1419,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
err = PTR_ERR(m);
goto err_out;
}
ctx = get_attr_search_ctx(base_ni, m);
ctx = ntfs_attr_get_search_ctx(base_ni, m);
if (!ctx) {
err = -ENOMEM;
goto unm_err_out;
......@@ -1497,7 +1497,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
/* No index allocation. */
vi->i_size = ni->initialized_size = ni->allocated_size = 0;
/* We are done with the mft record, so we release it. */
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(base_ni);
m = NULL;
ctx = NULL;
......@@ -1505,7 +1505,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
} /* LARGE_INDEX: Index allocation present. Setup state. */
NInoSetIndexAllocPresent(ni);
/* Find index allocation attribute. */
reinit_attr_search_ctx(ctx);
ntfs_attr_reinit_search_ctx(ctx);
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 "
......@@ -1546,7 +1546,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
* We are done with the mft record, so we release it. Otherwise
* we would deadlock in ntfs_attr_iget().
*/
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(base_ni);
m = NULL;
ctx = NULL;
......@@ -1597,7 +1597,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
if (!err)
err = -EIO;
if (ctx)
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
if (m)
unmap_mft_record(base_ni);
err_out:
......@@ -1644,7 +1644,7 @@ int ntfs_read_inode_mount(struct inode *vi)
ntfs_inode *ni;
MFT_RECORD *m = NULL;
ATTR_RECORD *attr;
attr_search_context *ctx;
ntfs_attr_search_ctx *ctx;
unsigned int i, nr_blocks;
int err;
......@@ -1719,7 +1719,7 @@ int ntfs_read_inode_mount(struct inode *vi)
/* Provides readpage() and sync_page() for map_mft_record(). */
vi->i_mapping->a_ops = &ntfs_mft_aops;
ctx = get_attr_search_ctx(ni, m);
ctx = ntfs_attr_get_search_ctx(ni, m);
if (!ctx) {
err = -ENOMEM;
goto err_out;
......@@ -1855,7 +1855,7 @@ int ntfs_read_inode_mount(struct inode *vi)
}
}
reinit_attr_search_ctx(ctx);
ntfs_attr_reinit_search_ctx(ctx);
/* Now load all attribute extents. */
attr = NULL;
......@@ -1955,7 +1955,7 @@ int ntfs_read_inode_mount(struct inode *vi)
"saw this message to "
"linux-ntfs-dev@lists."
"sourceforge.net");
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
/* Revert to the safe super operations. */
ntfs_free(m);
return -1;
......@@ -2005,7 +2005,7 @@ int ntfs_read_inode_mount(struct inode *vi)
(unsigned long long)last_vcn - 1);
goto put_err_out;
}
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
ntfs_debug("Done.");
ntfs_free(m);
return 0;
......@@ -2014,7 +2014,7 @@ int ntfs_read_inode_mount(struct inode *vi)
ntfs_error(sb, "Couldn't find first extent of $DATA attribute in "
"attribute list. $MFT is corrupt. Run chkdsk.");
put_err_out:
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
err_out:
ntfs_error(sb, "Failed. Marking inode as bad.");
make_bad_inode(vi);
......@@ -2317,7 +2317,7 @@ int ntfs_write_inode(struct inode *vi, int sync)
{
s64 nt;
ntfs_inode *ni = NTFS_I(vi);
attr_search_context *ctx;
ntfs_attr_search_ctx *ctx;
MFT_RECORD *m;
STANDARD_INFORMATION *si;
int err = 0;
......@@ -2342,14 +2342,14 @@ int ntfs_write_inode(struct inode *vi, int sync)
goto err_out;
}
/* Update the access times in the standard information attribute. */
ctx = get_attr_search_ctx(ni, m);
ctx = ntfs_attr_get_search_ctx(ni, m);
if (unlikely(!ctx)) {
err = -ENOMEM;
goto unm_err_out;
}
if (unlikely(!ntfs_attr_lookup(AT_STANDARD_INFORMATION, NULL, 0,
CASE_SENSITIVE, 0, NULL, 0, ctx))) {
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
err = -ENOENT;
goto unm_err_out;
}
......@@ -2395,7 +2395,7 @@ int ntfs_write_inode(struct inode *vi, int sync)
*/
if (modified && !NInoTestSetDirty(ctx->ntfs_ino))
__set_page_dirty_nobuffers(ctx->ntfs_ino->page);
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
/* Now the access times are updated, write the base mft record. */
if (NInoDirty(ni))
err = write_mft_record(ni, m, sync);
......
......@@ -171,7 +171,7 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
{
struct dentry *real_dent, *new_dent;
MFT_RECORD *m;
attr_search_context *ctx;
ntfs_attr_search_ctx *ctx;
ntfs_inode *ni = NTFS_I(dent_inode);
int err;
struct qstr nls_name;
......@@ -196,7 +196,7 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
ctx = NULL;
goto err_out;
}
ctx = get_attr_search_ctx(ni, m);
ctx = ntfs_attr_get_search_ctx(ni, m);
if (!ctx) {
err = -ENOMEM;
goto err_out;
......@@ -233,7 +233,7 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
(ntfschar*)&fn->file_name, fn->file_name_length,
(unsigned char**)&nls_name.name, 0);
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(ni);
}
m = NULL;
......@@ -329,7 +329,7 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
err = -EIO;
err_out:
if (ctx)
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
if (m)
unmap_mft_record(ni);
iput(dent_inode);
......@@ -366,7 +366,7 @@ struct dentry *ntfs_get_parent(struct dentry *child_dent)
struct inode *vi = child_dent->d_inode;
ntfs_inode *ni = NTFS_I(vi);
MFT_RECORD *mrec;
attr_search_context *ctx;
ntfs_attr_search_ctx *ctx;
ATTR_RECORD *attr;
FILE_NAME_ATTR *fn;
struct inode *parent_vi;
......@@ -379,7 +379,7 @@ struct dentry *ntfs_get_parent(struct dentry *child_dent)
if (IS_ERR(mrec))
return (struct dentry *)mrec;
/* Find the first file name attribute in the mft record. */
ctx = get_attr_search_ctx(ni, mrec);
ctx = ntfs_attr_get_search_ctx(ni, mrec);
if (unlikely(!ctx)) {
unmap_mft_record(ni);
return ERR_PTR(-ENOMEM);
......@@ -387,7 +387,7 @@ struct dentry *ntfs_get_parent(struct dentry *child_dent)
try_next:
if (unlikely(!ntfs_attr_lookup(AT_FILE_NAME, NULL, 0, CASE_SENSITIVE,
0, NULL, 0, ctx))) {
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(ni);
ntfs_error(vi->i_sb, "Inode 0x%lx does not have a file name "
"attribute. Run chkdsk.", vi->i_ino);
......@@ -404,7 +404,7 @@ struct dentry *ntfs_get_parent(struct dentry *child_dent)
/* Get the inode number of the parent directory. */
parent_ino = MREF_LE(fn->parent_directory);
/* Release the search context and the mft record of the child. */
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(ni);
/* Get the inode of the parent directory. */
parent_vi = ntfs_iget(vi->i_sb, parent_ino);
......
......@@ -318,7 +318,7 @@ static int ntfs_write_volume_flags(ntfs_volume *vol, const VOLUME_FLAGS flags)
ntfs_inode *ni = NTFS_I(vol->vol_ino);
MFT_RECORD *m;
VOLUME_INFORMATION *vi;
attr_search_context *ctx;
ntfs_attr_search_ctx *ctx;
int err;
ntfs_debug("Entering, old flags = 0x%x, new flags = 0x%x.",
......@@ -331,7 +331,7 @@ static int ntfs_write_volume_flags(ntfs_volume *vol, const VOLUME_FLAGS flags)
err = PTR_ERR(m);
goto err_out;
}
ctx = get_attr_search_ctx(ni, m);
ctx = ntfs_attr_get_search_ctx(ni, m);
if (!ctx) {
err = -ENOMEM;
goto put_unm_err_out;
......@@ -346,14 +346,14 @@ static int ntfs_write_volume_flags(ntfs_volume *vol, const VOLUME_FLAGS flags)
vol->vol_flags = vi->flags = flags;
flush_dcache_mft_record_page(ctx->ntfs_ino);
mark_mft_record_dirty(ctx->ntfs_ino);
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(ni);
done:
ntfs_debug("Done.");
return 0;
put_unm_err_out:
if (ctx)
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(ni);
err_out:
ntfs_error(vol->sb, "Failed with error code %i.", -err);
......@@ -1345,7 +1345,7 @@ static BOOL load_system_files(ntfs_volume *vol)
struct super_block *sb = vol->sb;
MFT_RECORD *m;
VOLUME_INFORMATION *vi;
attr_search_context *ctx;
ntfs_attr_search_ctx *ctx;
ntfs_debug("Entering.");
#ifdef NTFS_RW
......@@ -1429,14 +1429,14 @@ static BOOL load_system_files(ntfs_volume *vol)
iput(vol->vol_ino);
goto volume_failed;
}
if (!(ctx = get_attr_search_ctx(NTFS_I(vol->vol_ino), m))) {
if (!(ctx = ntfs_attr_get_search_ctx(NTFS_I(vol->vol_ino), m))) {
ntfs_error(sb, "Failed to get attribute search context.");
goto get_ctx_vol_failed;
}
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);
ntfs_attr_put_search_ctx(ctx);
get_ctx_vol_failed:
unmap_mft_record(NTFS_I(vol->vol_ino));
goto iput_volume_failed;
......@@ -1452,7 +1452,7 @@ static BOOL load_system_files(ntfs_volume *vol)
vol->vol_flags = vi->flags;
vol->major_ver = vi->major_ver;
vol->minor_ver = vi->minor_ver;
put_attr_search_ctx(ctx);
ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(NTFS_I(vol->vol_ino));
printk(KERN_INFO "NTFS volume version %i.%i.\n", vol->major_ver,
vol->minor_ver);
......@@ -2629,7 +2629,7 @@ static int __init init_ntfs_fs(void)
goto ictx_err_out;
}
ntfs_attr_ctx_cache = kmem_cache_create(ntfs_attr_ctx_cache_name,
sizeof(attr_search_context), 0 /* offset */,
sizeof(ntfs_attr_search_ctx), 0 /* offset */,
SLAB_HWCACHE_ALIGN, NULL /* ctor */, NULL /* dtor */);
if (!ntfs_attr_ctx_cache) {
printk(KERN_CRIT "NTFS: Failed to create %s!\n",
......
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