diff options
author | Xiaochen Wang <wangxiaochen0@gmail.com> | 2011-09-05 22:58:07 +0800 |
---|---|---|
committer | Stephen Hemminger <shemminger@vyatta.com> | 2011-09-12 08:42:13 -0700 |
commit | 7fc99b7f0f3a5e022a09b6525ef18c58ec25f66d (patch) | |
tree | 42b3d46ec735213edb25d32963211a009790ba9b | |
parent | bb9970a9df95837e39d680021b1f73d231e85406 (diff) | |
download | android_external_brctl-7fc99b7f0f3a5e022a09b6525ef18c58ec25f66d.tar.gz android_external_brctl-7fc99b7f0f3a5e022a09b6525ef18c58ec25f66d.tar.bz2 android_external_brctl-7fc99b7f0f3a5e022a09b6525ef18c58ec25f66d.zip |
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`.
Signed-off-by: Xiaochen Wang <wangxiaochen0@gmail.com>
-rw-r--r-- | 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); |