All of lore.kernel.org
 help / color / mirror / Atom feed
* [Bridge] [PATCH] skip . and .. in accurately in isbridge()
@ 2011-09-05 14:58 Xiaochen Wang
  2011-09-05 16:43 ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Xiaochen Wang @ 2011-09-05 14:58 UTC (permalink / raw)
  To: bridge; +Cc: Lennert Buytenhek, tephen Hemminger

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);
-- 
1.7.2.3


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

* Re: [Bridge] [PATCH] skip . and .. in accurately in isbridge()
  2011-09-05 14:58 [Bridge] [PATCH] skip . and .. in accurately in isbridge() Xiaochen Wang
@ 2011-09-05 16:43 ` Stephen Hemminger
  2011-09-07  7:33   ` Xiaochen Wang
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2011-09-05 16:43 UTC (permalink / raw)
  To: Xiaochen Wang; +Cc: Lennert Buytenhek, bridge

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 .

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

* Re: [Bridge] [PATCH] skip . and .. in accurately in isbridge()
  2011-09-05 16:43 ` Stephen Hemminger
@ 2011-09-07  7:33   ` Xiaochen Wang
  2011-09-07 14:45     ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Xiaochen Wang @ 2011-09-07  7:33 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Lennert Buytenhek, bridge

On Tue, Sep 6, 2011 at 12:43 AM, Stephen Hemminger
<shemminger@vyatta.com> wrote:
> 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 .
>
I see.

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

* Re: [Bridge] [PATCH] skip . and .. in accurately in isbridge()
  2011-09-07  7:33   ` Xiaochen Wang
@ 2011-09-07 14:45     ` Stephen Hemminger
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2011-09-07 14:45 UTC (permalink / raw)
  To: Xiaochen Wang; +Cc: Lennert Buytenhek, bridge

On Wed, 7 Sep 2011 15:33:13 +0800
Xiaochen Wang <wangxiaochen0@gmail.com> wrote:

> On Tue, Sep 6, 2011 at 12:43 AM, Stephen Hemminger
> <shemminger@vyatta.com> wrote:
> > 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 .
> >
> I see.

I will apply your patch, just wanted to make sure no one was using
the old (buggy) behavior

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

end of thread, other threads:[~2011-09-07 14:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-05 14:58 [Bridge] [PATCH] skip . and .. in accurately in isbridge() Xiaochen Wang
2011-09-05 16:43 ` Stephen Hemminger
2011-09-07  7:33   ` Xiaochen Wang
2011-09-07 14:45     ` Stephen Hemminger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.