diff options
Diffstat (limited to 'linuxnamespaces/syscalls.py')
-rw-r--r-- | linuxnamespaces/syscalls.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/linuxnamespaces/syscalls.py b/linuxnamespaces/syscalls.py index 667c557..abddffc 100644 --- a/linuxnamespaces/syscalls.py +++ b/linuxnamespaces/syscalls.py @@ -187,7 +187,7 @@ class MountFlags(enum.IntFlag): "unbindable": (UNBINDABLE, False, False), } - def change(self, flagsstr: str) -> "MountFlags": + def change(self, flagsstr: str) -> typing.Self: """Return modified mount flags after applying comma-separated mount flags represented as a str. Raise a ValueError if any given flag does not correspond to a textual mount flag. @@ -215,13 +215,13 @@ class MountFlags(enum.IntFlag): ret |= flag return ret - @staticmethod - def fromstr(flagsstr: str) -> "MountFlags": + @classmethod + def fromstr(cls, flagsstr: str) -> typing.Self: """Construct mount flags by changing flags according to the passed flagsstr using the change method on an initial value with all flags cleared. """ - return MountFlags.NONE.change(flagsstr) + return cls.NONE.change(flagsstr) __flagvals: list[tuple[int, str]] = sorted( [ @@ -286,15 +286,15 @@ class MountSetattrFlags(enum.IntFlag): AT_EMPTY_PATH = 0x1000 AT_RECURSIVE = 0x8000 - @staticmethod - def from_atflags(flags: AtFlags) -> "MountSetattrFlags": - ret = MountSetattrFlags.NONE + @classmethod + def from_atflags(cls, flags: AtFlags) -> typing.Self: + ret = cls.NONE if flags & AtFlags.AT_SYMLINK_NOFOLLOW: - ret |= MountSetattrFlags.AT_SYMLINK_NOFOLLOW + ret |= cls.AT_SYMLINK_NOFOLLOW if flags & AtFlags.AT_NO_AUTOMOUNT: - ret |= MountSetattrFlags.AT_NO_AUTOMOUNT + ret |= cls.AT_NO_AUTOMOUNT if flags & AtFlags.AT_EMPTY_PATH: - ret |= MountSetattrFlags.AT_EMPTY_PATH + ret |= cls.AT_EMPTY_PATH return ret @@ -470,7 +470,7 @@ class CapabilitySets: ) @classmethod - def get(cls, pid: int = 0) -> "CapabilitySets": + def get(cls, pid: int = 0) -> typing.Self: """Call capget to retrieve the current capability sets.""" header = cls._create_header(pid) data = (ctypes.c_uint32 * 6)() |