loggerd: move to system/ (#27534)

old-commit-hash: 94eb2159802d3dba99620db0b08731c68a7e4733
This commit is contained in:
Adeeb Shihadeh
2023-03-08 11:20:49 -08:00
committed by GitHub
parent 47d30174d3
commit 3a968c67e1
46 changed files with 74 additions and 74 deletions
+23
View File
@@ -0,0 +1,23 @@
import os
import errno
from typing import Dict, Tuple, Optional
_cached_attributes: Dict[Tuple, Optional[bytes]] = {}
def getxattr(path: str, attr_name: str) -> Optional[bytes]:
key = (path, attr_name)
if key not in _cached_attributes:
try:
response = os.getxattr(path, attr_name)
except OSError as e:
# ENODATA means attribute hasn't been set
if e.errno == errno.ENODATA:
response = None
else:
raise
_cached_attributes[key] = response
return _cached_attributes[key]
def setxattr(path: str, attr_name: str, attr_value: bytes) -> None:
_cached_attributes.pop((path, attr_name), None)
return os.setxattr(path, attr_name, attr_value)