Commit 3c23072e authored by Anton Altaparmakov's avatar Anton Altaparmakov

NTFS: Finally fix NFS exporting of mounted NTFS volumes by checking the

return of d_splice_alias() and acting accordingly rather than just
ignoring the returned dentry.
parent ce812c28
...@@ -36,6 +36,8 @@ ToDo: ...@@ -36,6 +36,8 @@ ToDo:
fs/ntfs/aops.c::ntfs_commit_nonresident_write(). fs/ntfs/aops.c::ntfs_commit_nonresident_write().
- Enforce no atime and no dir atime updates at mount/remount time as - Enforce no atime and no dir atime updates at mount/remount time as
they are not implemented yet anyway. they are not implemented yet anyway.
- Move a few assignments in fs/ntfs/attrib.c::load_attribute_list() to
after a NULL check. Thanks to Dave Jones for pointing this out.
2.1.6 - Fix minor bug in handling of compressed directories. 2.1.6 - Fix minor bug in handling of compressed directories.
......
...@@ -93,7 +93,8 @@ ...@@ -93,7 +93,8 @@
* name. We then convert the name to the current NLS code page, and proceed * 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. * searching for a dentry with this name, etc, as in case 2), above.
*/ */
static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent, struct nameidata *nd) static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
struct nameidata *nd)
{ {
ntfs_volume *vol = NTFS_SB(dir_ino->i_sb); ntfs_volume *vol = NTFS_SB(dir_ino->i_sb);
struct inode *dent_inode; struct inode *dent_inode;
...@@ -125,9 +126,8 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent, st ...@@ -125,9 +126,8 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent, st
dent_ino == FILE_MFT) { dent_ino == FILE_MFT) {
/* Perfect WIN32/POSIX match. -- Case 1. */ /* Perfect WIN32/POSIX match. -- Case 1. */
if (!name) { if (!name) {
d_splice_alias(dent_inode, dent);
ntfs_debug("Done."); ntfs_debug("Done.");
return NULL; return d_splice_alias(dent_inode, dent);
} }
/* /*
* We are too indented. Handle imperfect * We are too indented. Handle imperfect
...@@ -259,8 +259,12 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent, st ...@@ -259,8 +259,12 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent, st
err = -ENOMEM; err = -ENOMEM;
goto err_out; goto err_out;
} }
d_splice_alias(dent_inode, real_dent); new_dent = d_splice_alias(dent_inode, real_dent);
return real_dent; if (new_dent)
dput(real_dent);
else
new_dent = real_dent;
return new_dent;
} }
kfree(nls_name.name); kfree(nls_name.name);
/* Matching dentry exists, check if it is negative. */ /* Matching dentry exists, check if it is negative. */
...@@ -367,7 +371,7 @@ struct dentry *ntfs_get_parent(struct dentry *child_dent) ...@@ -367,7 +371,7 @@ struct dentry *ntfs_get_parent(struct dentry *child_dent)
struct dentry *parent_dent; struct dentry *parent_dent;
unsigned long parent_ino; unsigned long parent_ino;
ntfs_debug("Entering for inode %lu.", vi->i_ino); ntfs_debug("Entering for inode 0x%lx.", vi->i_ino);
/* Get the mft record of the inode belonging to the child dentry. */ /* Get the mft record of the inode belonging to the child dentry. */
mrec = map_mft_record(ni); mrec = map_mft_record(ni);
if (unlikely(IS_ERR(mrec))) if (unlikely(IS_ERR(mrec)))
...@@ -383,6 +387,8 @@ struct dentry *ntfs_get_parent(struct dentry *child_dent) ...@@ -383,6 +387,8 @@ struct dentry *ntfs_get_parent(struct dentry *child_dent)
NULL, 0, ctx))) { 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 "
"attribute. Run chkdsk.", vi->i_ino);
return ERR_PTR(-ENOENT); return ERR_PTR(-ENOENT);
} }
attr = ctx->attr; attr = ctx->attr;
...@@ -403,6 +409,9 @@ struct dentry *ntfs_get_parent(struct dentry *child_dent) ...@@ -403,6 +409,9 @@ struct dentry *ntfs_get_parent(struct dentry *child_dent)
if (unlikely(IS_ERR(parent_vi) || is_bad_inode(parent_vi))) { if (unlikely(IS_ERR(parent_vi) || is_bad_inode(parent_vi))) {
if (!IS_ERR(parent_vi)) if (!IS_ERR(parent_vi))
iput(parent_vi); iput(parent_vi);
ntfs_error(vi->i_sb, "Failed to get parent directory inode "
"0x%lx of child inode 0x%lx.", parent_ino,
vi->i_ino);
return ERR_PTR(-EACCES); return ERR_PTR(-EACCES);
} }
/* Finally get a dentry for the parent directory and return it. */ /* Finally get a dentry for the parent directory and return it. */
...@@ -411,7 +420,7 @@ struct dentry *ntfs_get_parent(struct dentry *child_dent) ...@@ -411,7 +420,7 @@ struct dentry *ntfs_get_parent(struct dentry *child_dent)
iput(parent_vi); iput(parent_vi);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
ntfs_debug("Done for inode %lu.", vi->i_ino); ntfs_debug("Done for inode 0x%lx.", vi->i_ino);
return parent_dent; return parent_dent;
} }
...@@ -438,14 +447,16 @@ struct dentry *ntfs_get_dentry(struct super_block *sb, void *fh) ...@@ -438,14 +447,16 @@ struct dentry *ntfs_get_dentry(struct super_block *sb, void *fh)
unsigned long ino = ((u32 *)fh)[0]; unsigned long ino = ((u32 *)fh)[0];
u32 gen = ((u32 *)fh)[1]; u32 gen = ((u32 *)fh)[1];
ntfs_debug("Entering for inode %lu, generation %u.", ino, gen); ntfs_debug("Entering for inode 0x%lx, generation 0x%x.", ino, gen);
vi = ntfs_iget(sb, ino); vi = ntfs_iget(sb, ino);
if (unlikely(IS_ERR(vi))) if (unlikely(IS_ERR(vi))) {
ntfs_error(sb, "Failed to get inode 0x%lx.", ino);
return (struct dentry *)vi; return (struct dentry *)vi;
}
if (unlikely(is_bad_inode(vi) || vi->i_generation != gen)) { if (unlikely(is_bad_inode(vi) || vi->i_generation != gen)) {
/* We didn't find the right inode. */ /* We didn't find the right inode. */
ntfs_debug("Inode %lu, bad count: %d %d or version %u %u.", ntfs_error(sb, "Inode 0x%lx, bad count: %d %d or version 0x%x "
vi->i_ino, vi->i_nlink, "0x%x.", vi->i_ino, vi->i_nlink,
atomic_read(&vi->i_count), vi->i_generation, atomic_read(&vi->i_count), vi->i_generation,
gen); gen);
iput(vi); iput(vi);
...@@ -457,7 +468,6 @@ struct dentry *ntfs_get_dentry(struct super_block *sb, void *fh) ...@@ -457,7 +468,6 @@ struct dentry *ntfs_get_dentry(struct super_block *sb, void *fh)
iput(vi); iput(vi);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
ntfs_debug("Done for inode %lu, generation %u.", ino, gen); ntfs_debug("Done for inode 0x%lx, generation 0x%x.", ino, gen);
return dent; return dent;
} }
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