2019-11-01 22:33:28 +03:00
|
|
|
# Portions Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2.
|
|
|
|
|
|
|
|
# Copyright Matt Mackall <mpm@selenic.com> and others
|
2018-08-21 22:19:45 +03:00
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2 or any later version.
|
|
|
|
"""capabilities of well-known filesystems"""
|
|
|
|
|
|
|
|
SYMLINK = "symlink"
|
|
|
|
HARDLINK = "hardlink"
|
|
|
|
EXECBIT = "execbit"
|
2018-09-25 00:07:21 +03:00
|
|
|
ALWAYSCASESENSITIVE = "alwayscasesensitive"
|
2018-08-21 22:19:45 +03:00
|
|
|
|
2018-09-25 00:07:21 +03:00
|
|
|
_ALL_CAPS = {SYMLINK: True, HARDLINK: True, EXECBIT: True, ALWAYSCASESENSITIVE: True}
|
2018-08-21 22:19:45 +03:00
|
|
|
|
2020-03-18 23:10:38 +03:00
|
|
|
_EDENFS_POSIX_CAPS = {
|
2020-03-19 01:02:25 +03:00
|
|
|
SYMLINK: True,
|
|
|
|
HARDLINK: False,
|
|
|
|
EXECBIT: True,
|
|
|
|
ALWAYSCASESENSITIVE: True,
|
2020-03-18 23:10:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
_FS_CAP_TABLE = {
|
2020-03-24 00:25:06 +03:00
|
|
|
"APFS": {SYMLINK: True, HARDLINK: True, EXECBIT: True, ALWAYSCASESENSITIVE: False},
|
|
|
|
"Btrfs": _ALL_CAPS,
|
|
|
|
"EdenFS": _EDENFS_POSIX_CAPS,
|
2018-08-21 22:19:45 +03:00
|
|
|
"ext4": _ALL_CAPS,
|
2020-03-24 00:25:06 +03:00
|
|
|
"NTFS": {
|
2019-02-07 05:18:44 +03:00
|
|
|
SYMLINK: False,
|
|
|
|
HARDLINK: True,
|
|
|
|
EXECBIT: False,
|
|
|
|
ALWAYSCASESENSITIVE: False,
|
|
|
|
},
|
2020-03-24 00:25:06 +03:00
|
|
|
"HFS": {SYMLINK: True, HARDLINK: True, EXECBIT: True, ALWAYSCASESENSITIVE: False},
|
|
|
|
"XFS": _ALL_CAPS,
|
2018-08-21 22:19:45 +03:00
|
|
|
"tmpfs": _ALL_CAPS,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def getfscap(fstype, cap):
|
|
|
|
"""Test if a filesystem has specified capability.
|
|
|
|
|
|
|
|
Return True if it has, False if it doesn't, or None if unsure.
|
|
|
|
"""
|
|
|
|
return _FS_CAP_TABLE.get(fstype, {}).get(cap)
|