mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 09:17:30 +03:00
dbc9a9f3e6
Summary: See D13964546 for context. Reviewed By: DurhamG, ikostia Differential Revision: D13982878 fbshipit-source-id: abce6f3c005b916cfb2e7a34276b99f9fcaa44b5
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
# Copyright Facebook, Inc. 2018
|
|
#
|
|
# 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"
|
|
ALWAYSCASESENSITIVE = "alwayscasesensitive"
|
|
|
|
_ALL_CAPS = {SYMLINK: True, HARDLINK: True, EXECBIT: True, ALWAYSCASESENSITIVE: True}
|
|
|
|
_FS_CAP_TABLE = {
|
|
"apfs": {SYMLINK: True, HARDLINK: True, EXECBIT: True, ALWAYSCASESENSITIVE: False},
|
|
"btrfs": _ALL_CAPS,
|
|
"eden": {SYMLINK: True, HARDLINK: False, EXECBIT: True, ALWAYSCASESENSITIVE: True},
|
|
"ext2": _ALL_CAPS,
|
|
"ext3": _ALL_CAPS,
|
|
"ext4": _ALL_CAPS,
|
|
"fuse.ntfs": {
|
|
SYMLINK: False,
|
|
HARDLINK: True,
|
|
EXECBIT: False,
|
|
ALWAYSCASESENSITIVE: False,
|
|
},
|
|
"hfs": {SYMLINK: True, HARDLINK: True, EXECBIT: True, ALWAYSCASESENSITIVE: False},
|
|
"jfs": _ALL_CAPS,
|
|
"reiserfs": _ALL_CAPS,
|
|
"tmpfs": _ALL_CAPS,
|
|
"ufs": _ALL_CAPS,
|
|
"xfs": _ALL_CAPS,
|
|
"zfs": _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)
|