SHARE
TWEET

Untitled

a guest Aug 12th, 2017 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // sameMount reports whether childInfo and parentInfo describe
  2. // the same file or directory in the same mount. For example,
  3. // on Unix this means that the device fields of the two underlying
  4. // structures are identical; on other systems the decision may
  5. // be based on the path names. sameMount only applies to results
  6. // returned by os.Stat. It returns false in other cases.
  7. func sameMount(childInfo os.FileInfo, childPath string, parentInfo os.FileInfo, parentPath string) bool {
  8.        if childInfo == nil || parentInfo == nil {
  9.                return false
  10.        }
  11.        if childPath == "" || parentPath == "" {
  12.                return false
  13.        }
  14.        fi1, ok1 := childInfo.Sys().(*syscall.Stat_t)
  15.        fi2, ok2 := parentInfo.Sys().(*syscall.Stat_t)
  16.        if !ok1 || !ok2 {
  17.                return false
  18.        }
  19.        return fi1.Dev == fi2.Dev
  20. }
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top