skip . and .. in accurately in isbridge()
PATCH 1/1 skip . and .. in accurately in isbridge()
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.
--- libbridge/libbridge_init.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
libbridge/libbridge_init.c +5 -2
@@ -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);
Signature · 1 line
1.7.2.3
Quoted 24 lines · On Mon, 5 Sep 2011 22:58:07 +0800 Xiaochen Wang <[email protected]> wrote:
Hi all,
In commit f88f8 "Skip . and .. in
foreach_bridgetest", the code skips all directories starting with dot.But if we create a bridge staring with dot, e.g.
.br0, thenbrctl showcannot show this one.
.br0should not be hidden, because we cannot find it except the commandbrctl show .br0.Signed-off-by Xiaochen Wang <[email protected]>--- libbridge/libbridge_init.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)libbridge/libbridge_init.c +0
-1@@ -49,9 +49,12 @@ static int isbridge(const struct dirent *entry)char path[SYSFS_PATH_MAX ];struct stat st; -if (entry->d_name[0 ] =='.' )
libbridge/libbridge_init.c static int isbridge(const struct dirent *entry) · line 60
Quoted 10 lines
libbridge/libbridge_init.c +5
-1+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 .
Quoted 26 lines · Stephen Hemminger
Quoted 23 lines · On Mon, 5 Sep 2011 22:58:07 +0800 Xiaochen Wang <[email protected]> wrote:
Hi all,
In commit f88f8 "Skip . and .. in
foreach_bridgetest", the code skips all directories starting with dot.But if we create a bridge staring with dot, e.g.
.br0, thenbrctl showcannot show this one.
.br0should not be hidden, because we cannot find it except the commandbrctl show .br0.Signed-off-by Xiaochen Wang <[email protected]>---
libbridge/libbridge_init.c | 7 +++++--1 files changed, 5 insertions(+), 2 deletions(-)libbridge/libbridge_init.c +0
-0@@ -49,9 +49,12 @@ static int isbridge(const struct dirent *entry) char path[SYSFS_PATH_MAX]; struct stat st;
Quoted 15 lines
libbridge/libbridge_init.c static int isbridge(const struct dirent *entry) · line 60
Quoted 11 lines
libbridge/libbridge_init.c +5
-2- 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.
Quoted 43 lines · On Wed, 7 Sep 2011 15:33:13 +0800 Xiaochen Wang <[email protected]> wrote:
Quoted 26 lines · Stephen Hemminger
Quoted 23 lines · On Mon, 5 Sep 2011 22:58:07 +0800 Xiaochen Wang <[email protected]> wrote:
Hi all,
In commit f88f8 "Skip . and .. in
foreach_bridgetest", the code skips all directories starting with dot.But if we create a bridge staring with dot, e.g.
.br0, thenbrctl showcannot show this one.
.br0should not be hidden, because we cannot find it except the commandbrctl show .br0.Signed-off-by Xiaochen Wang <[email protected]>---
libbridge/libbridge_init.c | 7 +++++--1 files changed, 5 insertions(+), 2 deletions(-)libbridge/libbridge_init.c +0
-0@@ -49,9 +49,12 @@ static int isbridge(const struct dirent *entry) char path[SYSFS_PATH_MAX]; struct stat st;Quoted 15 lines
libbridge/libbridge_init.c static int isbridge(const struct dirent *entry) · line 60
Quoted 11 lines
libbridge/libbridge_init.c +5
-2- 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 .
Quoted 1 line
I see.
I will apply your patch, just wanted to make sure no one was using the old (buggy) behavior