platform.py 1.2 KB

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