mount.go 530 B

123456789101112131415161718192021222324
  1. package mount
  2. // GetMounts retrieves a list of mounts for the current running process.
  3. func GetMounts() ([]*Info, error) {
  4. return parseMountTable()
  5. }
  6. // Mounted looks at /proc/self/mountinfo to determine of the specified
  7. // mountpoint has been mounted
  8. func Mounted(mountpoint string) (bool, error) {
  9. entries, err := parseMountTable()
  10. if err != nil {
  11. return false, err
  12. }
  13. // Search the table for the mountpoint
  14. for _, e := range entries {
  15. if e.Mountpoint == mountpoint {
  16. return true, nil
  17. }
  18. }
  19. return false, nil
  20. }