platform.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import errno
  2. import os
  3. import subprocess
  4. import sys
  5. # POSIX-only, from borg 1.1 platform.base
  6. def sync_dir(path):
  7. fd = os.open(path, os.O_RDONLY)
  8. try:
  9. os.fsync(fd)
  10. except OSError as os_error:
  11. # Some network filesystems don't support this and fail with EINVAL.
  12. # Other error codes (e.g. EIO) shouldn't be silenced.
  13. if os_error.errno != errno.EINVAL:
  14. raise
  15. finally:
  16. os.close(fd)
  17. # most POSIX platforms (but not Linux), see also borg 1.1 platform.base
  18. def umount(mountpoint):
  19. return subprocess.call(['umount', mountpoint])
  20. if sys.platform.startswith('linux'): # pragma: linux only
  21. from .platform_linux import acl_get, acl_set, umount, API_VERSION
  22. elif sys.platform.startswith('freebsd'): # pragma: freebsd only
  23. from .platform_freebsd import acl_get, acl_set, API_VERSION
  24. elif sys.platform == 'darwin': # pragma: darwin only
  25. from .platform_darwin import acl_get, acl_set, API_VERSION
  26. else: # pragma: unknown platform only
  27. API_VERSION = '1.0_01'
  28. def acl_get(path, item, st, numeric_owner=False):
  29. pass
  30. def acl_set(path, item, numeric_owner=False):
  31. pass