Ethernet Bridge development
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: Xiaochen Wang <wangxiaochen0@gmail.com>
Cc: Lennert Buytenhek <buytenh@gnu.org>, bridge@linux-foundation.org
Subject: Re: [Bridge] [PATCH] skip . and .. in accurately in isbridge()
Date: Mon, 5 Sep 2011 09:43:21 -0700	[thread overview]
Message-ID: <20110905094321.7e0f734c@nehalam.ftrdhcpuser.net> (raw)
In-Reply-To: <20110905145807.GA9179@chii>

On Mon, 5 Sep 2011 22:58:07 +0800
Xiaochen Wang <wangxiaochen0@gmail.com> wrote:

> Hi all,
> 
>  In commit f88f8 "Skip . and .. in foreach_bridge test", the code skips
>  all directories starting with dot.
> 
>  But if we create a bridge staring with dot, e.g. `.br0`, then `brctl show`
>  cannot show this one.
>  `.br0` should not be hidden, because we cannot find it except the command
>  `brctl show .br0`.
> 
> Signed-off-by: Xiaochen Wang <wangxiaochen0@gmail.com>
> ---
>  libbridge/libbridge_init.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/libbridge/libbridge_init.c b/libbridge/libbridge_init.c
> index 1c1acbd..177a391 100644
> --- a/libbridge/libbridge_init.c
> +++ b/libbridge/libbridge_init.c
> @@ -49,9 +49,12 @@ static int isbridge(const struct dirent *entry)
>  	char path[SYSFS_PATH_MAX];
>  	struct stat st;
>  
> -	if (entry->d_name[0] == '.')
> +	if (entry->d_name[0] == '.'
> +	    && (entry->d_name[1] == '\0'
> +		|| (entry->d_name[1] == '.'
> +		    && entry->d_name[2] == '\0')))
>  		return 0;
> -	
> +
>  	snprintf(path, SYSFS_PATH_MAX, 
>  		 SYSFS_CLASS_NET "%s/bridge", entry->d_name);
>  	return stat(path, &st) == 0 && S_ISDIR(st.st_mode);

This was an accident originally, but allowing hidden bridges might be useful.
And is common for other commands to not show names starting with .

  reply	other threads:[~2011-09-05 16:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-05 14:58 [Bridge] [PATCH] skip . and .. in accurately in isbridge() Xiaochen Wang
2011-09-05 16:43 ` Stephen Hemminger [this message]
2011-09-07  7:33   ` Xiaochen Wang
2011-09-07 14:45     ` Stephen Hemminger

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=20110905094321.7e0f734c@nehalam.ftrdhcpuser.net \
    --to=shemminger@vyatta.com \
    --cc=bridge@linux-foundation.org \
    --cc=buytenh@gnu.org \
    --cc=wangxiaochen0@gmail.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox