From c0fa2cfcd67d676dab100150daad2f93948c641b Mon Sep 17 00:00:00 2001 From: Gustavo Moreira Date: Tue, 5 Nov 2024 20:02:55 +1100 Subject: [PATCH] Linux: Boottime API: User linux_constanst import --- .../symbols/linux/extensions/__init__.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/volatility3/framework/symbols/linux/extensions/__init__.py b/volatility3/framework/symbols/linux/extensions/__init__.py index 0099b17e1..d05c34304 100644 --- a/volatility3/framework/symbols/linux/extensions/__init__.py +++ b/volatility3/framework/symbols/linux/extensions/__init__.py @@ -2217,12 +2217,12 @@ class Timespec64Abstract(abc.ABC): # Based on ns_to_timespec64() if nsec > 0: - tv_sec = nsec // NSEC_PER_SEC - tv_nsec = nsec % NSEC_PER_SEC + tv_sec = nsec // linux_constants.NSEC_PER_SEC + tv_nsec = nsec % linux_constants.NSEC_PER_SEC elif nsec < 0: - tv_sec = -((-nsec - 1) // NSEC_PER_SEC) - 1 - rem = (-nsec - 1) % NSEC_PER_SEC - tv_nsec = NSEC_PER_SEC - rem - 1 + tv_sec = -((-nsec - 1) // linux_constants.NSEC_PER_SEC) - 1 + rem = (-nsec - 1) % linux_constants.NSEC_PER_SEC + tv_nsec = linux_constants.NSEC_PER_SEC - rem - 1 else: tv_sec = tv_nsec = 0 @@ -2233,13 +2233,15 @@ class Timespec64Abstract(abc.ABC): # pylint: disable=E1101 return conversion.unixtime_to_datetime( - self.tv_sec + self.tv_nsec / NSEC_PER_SEC + self.tv_sec + self.tv_nsec / linux_constants.NSEC_PER_SEC ) def to_timedelta(self) -> datetime.timedelta: """Converts this Timespec64Abstract subclass object to timedelta""" # pylint: disable=E1101 - return datetime.timedelta(seconds=self.tv_sec + self.tv_nsec / NSEC_PER_SEC) + return datetime.timedelta( + seconds=self.tv_sec + self.tv_nsec / linux_constants.NSEC_PER_SEC + ) def __add__(self, other) -> "Timespec64Concrete": """Returns a new Timespec64Concrete object that sums the current values with those @@ -2282,12 +2284,12 @@ class Timespec64Abstract(abc.ABC): # Based on kernel's set_normalized_timespec64() # pylint: disable=E1101 - while self.tv_nsec >= NSEC_PER_SEC: - self.tv_nsec -= NSEC_PER_SEC + while self.tv_nsec >= linux_constants.NSEC_PER_SEC: + self.tv_nsec -= linux_constants.NSEC_PER_SEC self.tv_sec += 1 while self.tv_nsec < 0: - self.tv_nsec += NSEC_PER_SEC + self.tv_nsec += linux_constants.NSEC_PER_SEC self.tv_sec -= 1