linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [V2] fs/9p: TREADLINK bugfix
@ 2011-01-05 16:49 M. Mohan Kumar
  2011-01-05 17:28 ` Aneesh Kumar K. V
  2011-01-06  5:20 ` Aneesh Kumar K. V
  0 siblings, 2 replies; 4+ messages in thread
From: M. Mohan Kumar @ 2011-01-05 16:49 UTC (permalink / raw)
  To: v9fs-developer, linux-fsdevel@vger.kernel.org, LKML

Remove v9fs_vfs_readlink_dotl function and use generic_readlink. Update
v9fs_vfs_follow_link_dotl function to accommodate this change

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Reported-by:  Dr. David Alan Gilbert <linux@treblig.org>
---
Changes from previous version:
* Use __getname in v9fs_vfs_follow_link_dotl
* Remove v9fs_vfs_readlink_dotl function

 fs/9p/vfs_inode.c |   53 +++++++++++++++++------------------------------------
 1 files changed, 17 insertions(+), 36 deletions(-)

diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 2ce3668..7e613e8 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -1994,30 +1994,6 @@ error:
 	return err;
 }
 
-static int
-v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen)
-{
-	int retval;
-	struct p9_fid *fid;
-	char *target = NULL;
-
-	P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name);
-	retval = -EPERM;
-	fid = v9fs_fid_lookup(dentry);
-	if (IS_ERR(fid))
-		return PTR_ERR(fid);
-
-	retval = p9_client_readlink(fid, &target);
-	if (retval < 0)
-		return retval;
-
-	strncpy(buffer, target, buflen);
-	P9_DPRINTK(P9_DEBUG_VFS, "%s -> %s\n", dentry->d_name.name, buffer);
-
-	retval = strnlen(buffer, buflen);
-	return retval;
-}
-
 /**
  * v9fs_vfs_follow_link_dotl - follow a symlink path
  * @dentry: dentry for symlink
@@ -2028,23 +2004,28 @@ v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen)
 static void *
 v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd)
 {
-	int len = 0;
+	int retval;
+	struct p9_fid *fid;
 	char *link = __getname();
+	char *target;
 
-	P9_DPRINTK(P9_DEBUG_VFS, "%s n", dentry->d_name.name);
+	P9_DPRINTK(P9_DEBUG_VFS, "%s\n", dentry->d_name.name);
 
 	if (!link)
-		link = ERR_PTR(-ENOMEM);
-	else {
-		len = v9fs_vfs_readlink_dotl(dentry, link, PATH_MAX);
-		if (len < 0) {
-			__putname(link);
-			link = ERR_PTR(len);
-		} else
-			link[min(len, PATH_MAX-1)] = 0;
+		return NULL;
+	fid = v9fs_fid_lookup(dentry);
+	if (IS_ERR(fid))
+		return fid;
+	retval = p9_client_readlink(fid, &target);
+	if (retval < 0) {
+		__putname(link);
+		kfree(target);
+		return NULL;
 	}
-	nd_set_link(nd, link);
 
+	strcpy(link, target);
+	nd_set_link(nd, link);
+	kfree(target);
 	return NULL;
 }
 
@@ -2117,7 +2098,7 @@ static const struct inode_operations v9fs_symlink_inode_operations = {
 };
 
 static const struct inode_operations v9fs_symlink_inode_operations_dotl = {
-	.readlink = v9fs_vfs_readlink_dotl,
+	.readlink = generic_readlink,
 	.follow_link = v9fs_vfs_follow_link_dotl,
 	.put_link = v9fs_vfs_put_link,
 	.getattr = v9fs_vfs_getattr_dotl,
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] [V2] fs/9p: TREADLINK bugfix
  2011-01-05 16:49 [PATCH] [V2] fs/9p: TREADLINK bugfix M. Mohan Kumar
@ 2011-01-05 17:28 ` Aneesh Kumar K. V
  2011-01-06  5:20 ` Aneesh Kumar K. V
  1 sibling, 0 replies; 4+ messages in thread
From: Aneesh Kumar K. V @ 2011-01-05 17:28 UTC (permalink / raw)
  To: M. Mohan Kumar, v9fs-developer, linux-fsdevel@vger.kernel.org,
	LKML

On Wed,  5 Jan 2011 22:19:56 +0530, "M. Mohan Kumar" <mohan@in.ibm.com> wrote:
> Remove v9fs_vfs_readlink_dotl function and use generic_readlink. Update
> v9fs_vfs_follow_link_dotl function to accommodate this change
> 
> Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
> Reported-by:  Dr. David Alan Gilbert <linux@treblig.org>
> ---
> Changes from previous version:
> * Use __getname in v9fs_vfs_follow_link_dotl
> * Remove v9fs_vfs_readlink_dotl function
> 
>  fs/9p/vfs_inode.c |   53 +++++++++++++++++------------------------------------
>  1 files changed, 17 insertions(+), 36 deletions(-)
> 
> diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
> index 2ce3668..7e613e8 100644
> --- a/fs/9p/vfs_inode.c
> +++ b/fs/9p/vfs_inode.c
> @@ -1994,30 +1994,6 @@ error:
>  	return err;
>  }
> 
> -static int
> -v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen)
> -{
> -	int retval;
> -	struct p9_fid *fid;
> -	char *target = NULL;
> -
> -	P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name);
> -	retval = -EPERM;
> -	fid = v9fs_fid_lookup(dentry);
> -	if (IS_ERR(fid))
> -		return PTR_ERR(fid);
> -
> -	retval = p9_client_readlink(fid, &target);
> -	if (retval < 0)
> -		return retval;
> -
> -	strncpy(buffer, target, buflen);
> -	P9_DPRINTK(P9_DEBUG_VFS, "%s -> %s\n", dentry->d_name.name, buffer);
> -
> -	retval = strnlen(buffer, buflen);
> -	return retval;
> -}
> -
>  /**
>   * v9fs_vfs_follow_link_dotl - follow a symlink path
>   * @dentry: dentry for symlink
> @@ -2028,23 +2004,28 @@ v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen)
>  static void *
>  v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd)
>  {
> -	int len = 0;
> +	int retval;
> +	struct p9_fid *fid;
>  	char *link = __getname();
> +	char *target;
> 
> -	P9_DPRINTK(P9_DEBUG_VFS, "%s n", dentry->d_name.name);
> +	P9_DPRINTK(P9_DEBUG_VFS, "%s\n", dentry->d_name.name);
> 
>  	if (!link)
> -		link = ERR_PTR(-ENOMEM);
> -	else {
> -		len = v9fs_vfs_readlink_dotl(dentry, link, PATH_MAX);
> -		if (len < 0) {
> -			__putname(link);
> -			link = ERR_PTR(len);
> -		} else
> -			link[min(len, PATH_MAX-1)] = 0;
> +		return NULL;
                
That should either be return ERR_PTR(-ENOMEM);
or link = ERR_PTR(-ENOME) ;nd_set_link(..); return NULL;

> +	fid = v9fs_fid_lookup(dentry);
> +	if (IS_ERR(fid))
> +		return fid;
> +	retval = p9_client_readlink(fid, &target);
> +	if (retval < 0) {
> +		__putname(link);
> +		kfree(target);
> +		return NULL;

same here either return error or do nd_set_link and return NULL;

>  	}
> -	nd_set_link(nd, link);
> 
> +	strcpy(link, target);
> +	nd_set_link(nd, link);
> +	kfree(target);
>  	return NULL;
>  }
> 
> @@ -2117,7 +2098,7 @@ static const struct inode_operations v9fs_symlink_inode_operations = {
>  };
> 
>  static const struct inode_operations v9fs_symlink_inode_operations_dotl = {
> -	.readlink = v9fs_vfs_readlink_dotl,
> +	.readlink = generic_readlink,
>  	.follow_link = v9fs_vfs_follow_link_dotl,
>  	.put_link = v9fs_vfs_put_link,
>  	.getattr = v9fs_vfs_getattr_dotl,
> -- 

-aneesh

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [V2] fs/9p: TREADLINK bugfix
  2011-01-05 16:49 [PATCH] [V2] fs/9p: TREADLINK bugfix M. Mohan Kumar
  2011-01-05 17:28 ` Aneesh Kumar K. V
@ 2011-01-06  5:20 ` Aneesh Kumar K. V
  2011-01-06  5:55   ` M. Mohan Kumar
  1 sibling, 1 reply; 4+ messages in thread
From: Aneesh Kumar K. V @ 2011-01-06  5:20 UTC (permalink / raw)
  To: M. Mohan Kumar, v9fs-developer, linux-fsdevel@vger.kernel.org,
	LKML

On Wed,  5 Jan 2011 22:19:56 +0530, "M. Mohan Kumar" <mohan@in.ibm.com> wrote:
> Remove v9fs_vfs_readlink_dotl function and use generic_readlink. Update
> v9fs_vfs_follow_link_dotl function to accommodate this change
> 
> Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
> Reported-by:  Dr. David Alan Gilbert <linux@treblig.org>
> ---
> Changes from previous version:
> * Use __getname in v9fs_vfs_follow_link_dotl
> * Remove v9fs_vfs_readlink_dotl function
> 
>  fs/9p/vfs_inode.c |   53 +++++++++++++++++------------------------------------
>  1 files changed, 17 insertions(+), 36 deletions(-)
> 
> diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
> index 2ce3668..7e613e8 100644
> --- a/fs/9p/vfs_inode.c
> +++ b/fs/9p/vfs_inode.c
> @@ -1994,30 +1994,6 @@ error:
>  	return err;
>  }
> 
> -static int
> -v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen)
> -{
> -	int retval;
> -	struct p9_fid *fid;
> -	char *target = NULL;
> -
> -	P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name);
> -	retval = -EPERM;
> -	fid = v9fs_fid_lookup(dentry);
> -	if (IS_ERR(fid))
> -		return PTR_ERR(fid);
> -
> -	retval = p9_client_readlink(fid, &target);
> -	if (retval < 0)
> -		return retval;
> -
> -	strncpy(buffer, target, buflen);
> -	P9_DPRINTK(P9_DEBUG_VFS, "%s -> %s\n", dentry->d_name.name, buffer);
> -
> -	retval = strnlen(buffer, buflen);
> -	return retval;
> -}
> -
>  /**
>   * v9fs_vfs_follow_link_dotl - follow a symlink path
>   * @dentry: dentry for symlink
> @@ -2028,23 +2004,28 @@ v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen)
>  static void *
>  v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd)
>  {
> -	int len = 0;
> +	int retval;
> +	struct p9_fid *fid;
>  	char *link = __getname();
> +	char *target;
> 
> -	P9_DPRINTK(P9_DEBUG_VFS, "%s n", dentry->d_name.name);
> +	P9_DPRINTK(P9_DEBUG_VFS, "%s\n", dentry->d_name.name);
> 
>  	if (!link)
> -		link = ERR_PTR(-ENOMEM);
> -	else {
> -		len = v9fs_vfs_readlink_dotl(dentry, link, PATH_MAX);
> -		if (len < 0) {
> -			__putname(link);
> -			link = ERR_PTR(len);
> -		} else
> -			link[min(len, PATH_MAX-1)] = 0;
> +		return NULL;
> +	fid = v9fs_fid_lookup(dentry);
> +	if (IS_ERR(fid))
> +		return fid;

need to do a __putname(link) and do a nd_set_link(nd, ERR_PTR(fid))

> +	retval = p9_client_readlink(fid, &target);
> +	if (retval < 0) {
> +		__putname(link);
> +		kfree(target);

On error target should not be allocated right ? So why kfree ?

> +		return NULL;
>  	}
> -	nd_set_link(nd, link);
> 
> +	strcpy(link, target);
> +	nd_set_link(nd, link);
> +	kfree(target);
>  	return NULL;
>  }
> 

-aneesh

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [V2] fs/9p: TREADLINK bugfix
  2011-01-06  5:20 ` Aneesh Kumar K. V
@ 2011-01-06  5:55   ` M. Mohan Kumar
  0 siblings, 0 replies; 4+ messages in thread
From: M. Mohan Kumar @ 2011-01-06  5:55 UTC (permalink / raw)
  To: Aneesh Kumar K. V; +Cc: v9fs-developer, linux-fsdevel, LKML

Thanks Aneesh, I will be posting the patch with addressing your comments.

On Thursday 06 January 2011 10:50:26 am Aneesh Kumar K. V wrote:
> On Wed,  5 Jan 2011 22:19:56 +0530, "M. Mohan Kumar" <mohan@in.ibm.com> 
wrote:
> > Remove v9fs_vfs_readlink_dotl function and use generic_readlink. Update
> > v9fs_vfs_follow_link_dotl function to accommodate this change
> > 
> > Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
> > Reported-by:  Dr. David Alan Gilbert <linux@treblig.org>
> > ---
> > Changes from previous version:
> > * Use __getname in v9fs_vfs_follow_link_dotl
> > * Remove v9fs_vfs_readlink_dotl function
> > 
> >  fs/9p/vfs_inode.c |   53
> >  +++++++++++++++++------------------------------------ 1 files changed,
> >  17 insertions(+), 36 deletions(-)
> > 
> > diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
> > index 2ce3668..7e613e8 100644
> > --- a/fs/9p/vfs_inode.c
> > +++ b/fs/9p/vfs_inode.c
> > 
> > @@ -1994,30 +1994,6 @@ error:
> >  	return err;
> >  
> >  }
> > 
> > -static int
> > -v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen)
> > -{
> > -	int retval;
> > -	struct p9_fid *fid;
> > -	char *target = NULL;
> > -
> > -	P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name);
> > -	retval = -EPERM;
> > -	fid = v9fs_fid_lookup(dentry);
> > -	if (IS_ERR(fid))
> > -		return PTR_ERR(fid);
> > -
> > -	retval = p9_client_readlink(fid, &target);
> > -	if (retval < 0)
> > -		return retval;
> > -
> > -	strncpy(buffer, target, buflen);
> > -	P9_DPRINTK(P9_DEBUG_VFS, "%s -> %s\n", dentry->d_name.name, buffer);
> > -
> > -	retval = strnlen(buffer, buflen);
> > -	return retval;
> > -}
> > -
> > 
> >  /**
> >  
> >   * v9fs_vfs_follow_link_dotl - follow a symlink path
> >   * @dentry: dentry for symlink
> > 
> > @@ -2028,23 +2004,28 @@ v9fs_vfs_readlink_dotl(struct dentry *dentry,
> > char *buffer, int buflen)
> > 
> >  static void *
> >  v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd)
> >  {
> > 
> > -	int len = 0;
> > +	int retval;
> > +	struct p9_fid *fid;
> > 
> >  	char *link = __getname();
> > 
> > +	char *target;
> > 
> > -	P9_DPRINTK(P9_DEBUG_VFS, "%s n", dentry->d_name.name);
> > +	P9_DPRINTK(P9_DEBUG_VFS, "%s\n", dentry->d_name.name);
> > 
> >  	if (!link)
> > 
> > -		link = ERR_PTR(-ENOMEM);
> > -	else {
> > -		len = v9fs_vfs_readlink_dotl(dentry, link, PATH_MAX);
> > -		if (len < 0) {
> > -			__putname(link);
> > -			link = ERR_PTR(len);
> > -		} else
> > -			link[min(len, PATH_MAX-1)] = 0;
> > +		return NULL;
> > +	fid = v9fs_fid_lookup(dentry);
> > +	if (IS_ERR(fid))
> > +		return fid;
> 
> need to do a __putname(link) and do a nd_set_link(nd, ERR_PTR(fid))
> 
> > +	retval = p9_client_readlink(fid, &target);
> > +	if (retval < 0) {
> > +		__putname(link);
> > +		kfree(target);
> 
> On error target should not be allocated right ? So why kfree ?
> 
> > +		return NULL;
> > 
> >  	}
> > 
> > -	nd_set_link(nd, link);
> > 
> > +	strcpy(link, target);
> > +	nd_set_link(nd, link);
> > +	kfree(target);
> > 
> >  	return NULL;
> >  
> >  }
> 
> -aneesh

----
M. Mohan Kumar

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-01-06  5:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-05 16:49 [PATCH] [V2] fs/9p: TREADLINK bugfix M. Mohan Kumar
2011-01-05 17:28 ` Aneesh Kumar K. V
2011-01-06  5:20 ` Aneesh Kumar K. V
2011-01-06  5:55   ` M. Mohan Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).