Skip to content

Commit f459c33

Browse files
authored
Merge pull request #2 from kolyshkin/GetMountsFromReader
mountinfo: add GetMountsFromReader
2 parents 5bb3159 + f401a7b commit f459c33

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

mountinfo/mountinfo.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
package mountinfo
22

3+
import "io"
4+
35
// GetMounts retrieves a list of mounts for the current running process,
46
// with an optional filter applied (use nil for no filter).
57
func GetMounts(f FilterFunc) ([]*Info, error) {
68
return parseMountTable(f)
79
}
810

11+
// GetMountsFromReader retrieves a list of mounts from the
12+
// reader provided, with an optional filter applied (use nil
13+
// for no filter). This can be useful in tests or benchmarks
14+
// that provide a fake mountinfo data.
15+
func GetMountsFromReader(reader io.Reader, f FilterFunc) ([]*Info, error) {
16+
return parseInfoFile(reader, f)
17+
}
18+
919
// Mounted determines if a specified mountpoint has been mounted.
1020
// On Linux it looks at /proc/self/mountinfo.
1121
func Mounted(mountpoint string) (bool, error) {

0 commit comments

Comments
 (0)