LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: linuxram@us.ibm.com
Cc: miklos@szeredi.hu, akpm@linux-foundation.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	viro@ftp.linux.org.uk, a.p.zijlstra@chello.nl
Subject: Re: [RFC PATCH] vfs: optimization to /proc/<pid>/mountinfo patch
Date: Mon, 04 Feb 2008 12:49:19 +0100	[thread overview]
Message-ID: <E1JLzp9-0002QN-PP@pomaz-ex.szeredi.hu> (raw)
In-Reply-To: <1202116505.3949.91.camel@ram.us.ibm.com> (message from Ram Pai on Mon, 04 Feb 2008 01:15:05 -0800)

> 1) reports deleted inode in dentry_path() consistent with that in __d_path()
> 2) modified __d_path() to use prepend(), reducing the size of __d_path()
> 3) moved all the functionality that reports mount information in /proc under
> 	CONFIG_PROC_FS.
> 
> Could not verify if the code would work with CONFIG_PROC_FS=n, since it was
> impossible to disable CONFIG_PROC_FS. Looking for ideas on how to disable
> CONFIG_PROC_FS.
> 	
> 
> 
> Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> ---
>  fs/dcache.c              |   59 +++++++++++++++++++----------------------------
>  fs/namespace.c           |    2 +
>  fs/seq_file.c            |    2 +
>  include/linux/dcache.h   |    3 ++
>  include/linux/seq_file.h |    3 ++
>  5 files changed, 34 insertions(+), 35 deletions(-)
> 
> Index: linux-2.6.23/fs/dcache.c
> ===================================================================
> --- linux-2.6.23.orig/fs/dcache.c
> +++ linux-2.6.23/fs/dcache.c
> @@ -1747,6 +1747,17 @@ shouldnt_be_hashed:
>  	goto shouldnt_be_hashed;
>  }
>  
> +static int prepend(char **buffer, int *buflen, const char *str,
> +			  int namelen)
> +{
> +	*buflen -= namelen;
> +	if (*buflen < 0)
> +		return 1;

This is confusing.  Should return -ENAMETOOLONG intead (see Chapter 16
in Documentation/CodingStyle).

> +	*buffer -= namelen;
> +	memcpy(*buffer, str, namelen);
> +	return 0;
> +}
> +
>  /**
>   * d_path - return the path of a dentry
>   * @dentry: dentry to report
> @@ -1768,17 +1779,11 @@ static char *__d_path(struct dentry *den
>  {
>  	char * end = buffer+buflen;
>  	char * retval;
> -	int namelen;
>  
> -	*--end = '\0';
> -	buflen--;
> -	if (!IS_ROOT(dentry) && d_unhashed(dentry)) {
> -		buflen -= 10;
> -		end -= 10;
> -		if (buflen < 0)
> +	prepend(&end, &buflen, "\0", 1);
> +	if (!IS_ROOT(dentry) && d_unhashed(dentry) &&
> +		prepend(&end, &buflen, " (deleted)", 10))

And this should test for "prepend() != 0" or "prepend() < 0" instead,
otherwise it could easily be misread as "if prepend() succeeded,
then...".

And similarly for all the later calls.

Thanks,
Miklos

      parent reply	other threads:[~2008-02-04 11:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-29 13:57 [patch] vfs: create /proc/<pid>/mountinfo Miklos Szeredi
2008-01-31  0:08 ` Andrew Morton
2008-01-31  9:17   ` Miklos Szeredi
2008-01-31 18:45     ` Ram Pai
2008-02-04  9:15       ` [RFC PATCH] vfs: optimization to /proc/<pid>/mountinfo patch Ram Pai
2008-02-04  9:28         ` Andrew Morton
2008-02-11  7:36           ` Ram Pai
2008-02-04 11:49         ` Miklos Szeredi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1JLzp9-0002QN-PP@pomaz-ex.szeredi.hu \
    --to=miklos@szeredi.hu \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxram@us.ibm.com \
    --cc=viro@ftp.linux.org.uk \
    --subject='Re: [RFC PATCH] vfs: optimization to /proc/<pid>/mountinfo patch' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).