basicfs_lstat_broken.go 791 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright (C) 2015 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. //go:build linux || android
  7. // +build linux android
  8. package fs
  9. import (
  10. "os"
  11. "syscall"
  12. "time"
  13. )
  14. // Lstat is like os.Lstat, except lobotomized for Android. See
  15. // https://forum.syncthing.net/t/2395
  16. func (*BasicFilesystem) underlyingLstat(name string) (fi os.FileInfo, err error) {
  17. for i := 0; i < 10; i++ { // We have to draw the line somewhere
  18. fi, err = os.Lstat(name)
  19. if err, ok := err.(*os.PathError); ok && err.Err == syscall.EINTR {
  20. time.Sleep(time.Duration(i+1) * time.Millisecond)
  21. continue
  22. }
  23. return
  24. }
  25. return
  26. }