Debian Codegraph @

fs/fstestutil/mountinfo_darwin.go

raw symbols SCIP
1 package fstestutil
2
3 import (
4 "regexp"
5 "syscall"
6 )
7
8 var re = regexp.MustCompile(`\\(.)`)
9
10 // unescape removes backslash-escaping. The escaped characters are not
11 // mapped in any way; that is, unescape(`\n` ) == `n`.
12 func unescape(s string) string {
13 return re.ReplaceAllString(s, `$1`)
14 }
15
16 func getMountInfo(mnt string) (*MountInfo, error) {
17 var st syscall.Statfs_t
18 err := syscall.Statfs(mnt, &st)
19 if err != nil {
20 return nil, err
21 }
22 i := &MountInfo{
23 // osx getmntent(3) fails to un-escape the data, so we do it..
24 // this might lead to double-unescaping in the future. fun.
25 // TestMountOptionFSNameEvilBackslashDouble checks for that.
26 FSName: unescape(cstr(st.Mntfromname[:])),
27 }
28 return i, nil
29 }