Skip to content

Commit 48e4e03

Browse files
committed
Re-implemented nano-second opt-in in fusepy, changed loggedfs-python accordingly.
2 parents f864448 + 3606c0e commit 48e4e03

File tree

3 files changed

+29
-16
lines changed

3 files changed

+29
-16
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ language: python
3434

3535
# Python version
3636
python:
37-
# - "3.4"
38-
# - "3.5"
37+
- "3.4"
38+
- "3.5"
3939
- "3.6"
4040

4141
# Install dependencies

src/loggedfs/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ def proc_filter_list(in_list):
114114
config_dict = OrderedDict({
115115
'@logEnabled': True,
116116
'@printProcessName': True,
117-
'includes': [],
118-
'excludes': []
117+
'includes': {},
118+
'excludes': {}
119119
})
120120

121121
config_file = None
@@ -125,7 +125,7 @@ def proc_filter_list(in_list):
125125
config_fh.close()
126126

127127
for f_type in ['includes', 'excludes']:
128-
config_dict[f_type] = proc_filter_list(config_dict[f_type][f_type[:-1]])
128+
config_dict[f_type] = proc_filter_list(config_dict[f_type].get(f_type[:-1], None))
129129

130130
return {
131131
'log_includes': config_dict['includes'],

src/loggedfs/core.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,18 @@
4242
import sys
4343
import time
4444

45-
import fuse
4645
from fuse import (
4746
FUSE,
4847
fuse_get_context,
4948
FuseOSError,
50-
Operations
49+
Operations,
50+
UTIME_NOW,
51+
UTIME_OMIT
5152
)
52-
53+
try:
54+
from fuse import __features__ as fuse_features
55+
except ImportError:
56+
fuse_features = {}
5357

5458
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5559
# ROUTINES
@@ -260,10 +264,16 @@ def match_filter(f_path, f_uid, f_action, f_status):
260264
class loggedfs: # (Operations):
261265

262266

263-
WITH_NANOSECOND_INT = True
264267
flag_utime_omit_ok = 1
265268

266269

270+
requested_features = {
271+
'nanosecond_int': True,
272+
'utime_omit_none': True,
273+
'utime_now_auto': True
274+
}
275+
276+
267277
def __init__(self,
268278
directory,
269279
log_includes = [],
@@ -297,7 +307,13 @@ def __init__(self,
297307

298308
self.logger.info(log_configmsg)
299309

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+
301317
self.st_fields = [i for i in dir(os.stat_result) if i.startswith('st_')]
302318
self.stvfs_fields = [i for i in dir(os.statvfs_result) if i.startswith('f_')]
303319

@@ -606,15 +622,12 @@ def unlink(self, path):
606622
@__log__(format_pattern = '{0}', abs_path_fields = [0])
607623
def utimens(self, path, times = None):
608624

609-
UTIME_OMIT = (1 << 30) - 2
610-
UTIME_NOW = (1 << 30) - 1
611-
612625
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]):
614627
st = os.lstat(relpath, dir_fd = self.root_path_fd)
615-
if atime == UTIME_OMIT:
628+
if atime in [UTIME_OMIT, None]:
616629
atime = st.st_atime_ns
617-
if mtime == UTIME_OMIT:
630+
if mtime in [UTIME_OMIT, None]:
618631
mtime = st.st_mtime_ns
619632
if UTIME_NOW in (atime, mtime):
620633
now = int(time.time() * 10**9)

0 commit comments

Comments
 (0)