summaryrefslogtreecommitdiff
path: root/tests/test_helpers
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_helpers')
-rw-r--r--tests/test_helpers/mount_unmount.go27
1 files changed, 22 insertions, 5 deletions
diff --git a/tests/test_helpers/mount_unmount.go b/tests/test_helpers/mount_unmount.go
index 5035c2b..e2eaf1f 100644
--- a/tests/test_helpers/mount_unmount.go
+++ b/tests/test_helpers/mount_unmount.go
@@ -176,14 +176,31 @@ func ListFds(pid int) []string {
log.Panic(err)
}
defer f.Close()
+ // Note: Readdirnames filters "." and ".."
names, err := f.Readdirnames(0)
if err != nil {
log.Panic(err)
}
- for i, n := range names {
- // Note: Readdirnames filters "." and ".."
- target, _ := os.Readlink(dir + "/" + n)
- names[i] = n + "=" + target
+ var out []string
+ for _, n := range names {
+ fdPath := dir + "/" + n
+ fi, err := os.Lstat(fdPath)
+ if err != nil {
+ // fd was closed in the meantime
+ continue
+ }
+ if fi.Mode()&0400 > 0 {
+ n += "r"
+ }
+ if fi.Mode()&0200 > 0 {
+ n += "w"
+ }
+ target, err := os.Readlink(fdPath)
+ if err != nil {
+ // fd was closed in the meantime
+ continue
+ }
+ out = append(out, n+"="+target)
}
- return names
+ return out
}