|
42 | 42 | import sys |
43 | 43 | import time |
44 | 44 |
|
45 | | -import fuse |
46 | 45 | from fuse import ( |
47 | 46 | FUSE, |
48 | 47 | fuse_get_context, |
49 | 48 | FuseOSError, |
50 | | - Operations |
| 49 | + Operations, |
| 50 | + UTIME_NOW, |
| 51 | + UTIME_OMIT |
51 | 52 | ) |
52 | | - |
| 53 | +try: |
| 54 | + from fuse import __features__ as fuse_features |
| 55 | +except ImportError: |
| 56 | + fuse_features = {} |
53 | 57 |
|
54 | 58 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
55 | 59 | # ROUTINES |
@@ -260,10 +264,16 @@ def match_filter(f_path, f_uid, f_action, f_status): |
260 | 264 | class loggedfs: # (Operations): |
261 | 265 |
|
262 | 266 |
|
263 | | - WITH_NANOSECOND_INT = True |
264 | 267 | flag_utime_omit_ok = 1 |
265 | 268 |
|
266 | 269 |
|
| 270 | + requested_features = { |
| 271 | + 'nanosecond_int': True, |
| 272 | + 'utime_omit_none': True, |
| 273 | + 'utime_now_auto': True |
| 274 | + } |
| 275 | + |
| 276 | + |
267 | 277 | def __init__(self, |
268 | 278 | directory, |
269 | 279 | log_includes = [], |
@@ -297,7 +307,13 @@ def __init__(self, |
297 | 307 |
|
298 | 308 | self.logger.info(log_configmsg) |
299 | 309 |
|
300 | | - self.flag_nanosecond_int = hasattr(self, 'WITH_NANOSECOND_INT') and hasattr(fuse, 'NANOSECOND_INT_AVAILABLE') |
| 310 | + for flag_name in self.requested_features.keys(): |
| 311 | + setattr( |
| 312 | + self, |
| 313 | + 'flag_' + flag_name, |
| 314 | + self.requested_features[flag_name] and fuse_features.get(flag_name, False) |
| 315 | + ) |
| 316 | + |
301 | 317 | self.st_fields = [i for i in dir(os.stat_result) if i.startswith('st_')] |
302 | 318 | self.stvfs_fields = [i for i in dir(os.statvfs_result) if i.startswith('f_')] |
303 | 319 |
|
@@ -606,15 +622,12 @@ def unlink(self, path): |
606 | 622 | @__log__(format_pattern = '{0}', abs_path_fields = [0]) |
607 | 623 | def utimens(self, path, times = None): |
608 | 624 |
|
609 | | - UTIME_OMIT = (1 << 30) - 2 |
610 | | - UTIME_NOW = (1 << 30) - 1 |
611 | | - |
612 | 625 | def _fix_time_(atime, mtime): |
613 | | - if UTIME_OMIT in (atime, mtime): |
| 626 | + if any(val in (atime, mtime) for val in [UTIME_OMIT, None]): |
614 | 627 | st = os.lstat(relpath, dir_fd = self.root_path_fd) |
615 | | - if atime == UTIME_OMIT: |
| 628 | + if atime in [UTIME_OMIT, None]: |
616 | 629 | atime = st.st_atime_ns |
617 | | - if mtime == UTIME_OMIT: |
| 630 | + if mtime in [UTIME_OMIT, None]: |
618 | 631 | mtime = st.st_mtime_ns |
619 | 632 | if UTIME_NOW in (atime, mtime): |
620 | 633 | now = int(time.time() * 10**9) |
|
0 commit comments