X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fntfs%2Fnamei.c;h=70b503a85f4d1e48528f71cc7f526d81590e93ec;hb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;hp=6a62738119622f4b89e4960941189803a6183498;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c index 6a6273811..70b503a85 100644 --- a/fs/ntfs/namei.c +++ b/fs/ntfs/namei.c @@ -92,6 +92,8 @@ * file name in the WIN32 namespace corresponding to the matched short file * name. We then convert the name to the current NLS code page, and proceed * searching for a dentry with this name, etc, as in case 2), above. + * + * Locking: Caller must hold i_sem on the directory. */ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent, struct nameidata *nd) @@ -169,7 +171,7 @@ handle_name: { 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; @@ -194,8 +196,8 @@ handle_name: ctx = NULL; goto err_out; } - ctx = get_attr_search_ctx(ni, m); - if (!ctx) { + ctx = ntfs_attr_get_search_ctx(ni, m); + if (unlikely(!ctx)) { err = -ENOMEM; goto err_out; } @@ -203,12 +205,14 @@ handle_name: ATTR_RECORD *a; u32 val_len; - if (!lookup_attr(AT_FILE_NAME, NULL, 0, 0, 0, NULL, 0, - ctx)) { + err = ntfs_attr_lookup(AT_FILE_NAME, NULL, 0, 0, 0, + NULL, 0, ctx); + if (unlikely(err)) { ntfs_error(vol->sb, "Inode corrupt: No WIN32 " "namespace counterpart to DOS " "file name. Run chkdsk."); - err = -EIO; + if (err == -ENOENT) + err = -EIO; goto err_out; } /* Consistency checks. */ @@ -231,7 +235,7 @@ handle_name: (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; @@ -327,7 +331,7 @@ eio_err_out: 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); @@ -364,32 +368,36 @@ 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; struct dentry *parent_dent; unsigned long parent_ino; + int err; ntfs_debug("Entering for inode 0x%lx.", vi->i_ino); /* Get the mft record of the inode belonging to the child dentry. */ mrec = map_mft_record(ni); - if (unlikely(IS_ERR(mrec))) + 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); } try_next: - if (unlikely(!lookup_attr(AT_FILE_NAME, NULL, 0, IGNORE_CASE, 0, - NULL, 0, ctx))) { - put_attr_search_ctx(ctx); + err = ntfs_attr_lookup(AT_FILE_NAME, NULL, 0, CASE_SENSITIVE, 0, NULL, + 0, ctx); + if (unlikely(err)) { + 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); - return ERR_PTR(-ENOENT); + if (err == -ENOENT) + ntfs_error(vi->i_sb, "Inode 0x%lx does not have a " + "file name attribute. Run chkdsk.", + vi->i_ino); + return ERR_PTR(err); } attr = ctx->attr; if (unlikely(attr->non_resident)) @@ -402,11 +410,11 @@ try_next: /* 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); - if (unlikely(IS_ERR(parent_vi) || is_bad_inode(parent_vi))) { + if (IS_ERR(parent_vi) || unlikely(is_bad_inode(parent_vi))) { if (!IS_ERR(parent_vi)) iput(parent_vi); ntfs_error(vi->i_sb, "Failed to get parent directory inode " @@ -449,7 +457,7 @@ struct dentry *ntfs_get_dentry(struct super_block *sb, void *fh) ntfs_debug("Entering for inode 0x%lx, generation 0x%x.", ino, gen); vi = ntfs_iget(sb, ino); - if (unlikely(IS_ERR(vi))) { + if (IS_ERR(vi)) { ntfs_error(sb, "Failed to get inode 0x%lx.", ino); return (struct dentry *)vi; }