Skip to content

Commit f864448

Browse files
committed
Repaired last broken test - filesystem honors UTIME_OMIT and UTIME_NOW and handles them correctly. flag_utime_omit_ok=1 is passed into libfuse2, triggering
utimens even when UTIME_OMIT has been passed into utimensat.
2 parents c5619a6 + c9cc638 commit f864448

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

README.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ LoggedFS-python - Filesystem monitoring with Fuse and Python
1414
PROJECT STATUS NOTICE: **BETA** (UNDER DEVELOPMENT)
1515
---------------------------------------------------
1616

17-
FILESYSTEM PASSES `TEST SUITE FOR POSIX COMPLIANCE`_ - WITH ONE EXCEPTION:
18-
19-
- UPDATING *ATIME* AND *MTIME* FAILS UNDER CERTAIN CIRCUMSTANCES.
20-
THE ROOT SOURCE CAN LIKELY BE FOUND IN LIBFUSE **2**.
21-
THIS IS UNDER FURTHER INVESTIGATION.
22-
ONE TEST WHICH FAILS BECAUSE OF IT IS THEREFORE CURRENTLY BEING IGNORED.
17+
FILESYSTEM PASSES `TEST SUITE FOR POSIX COMPLIANCE`_ - ALL OF IT.
2318

2419
A CUSTOM BUG-FIXED VERSION OF `FUSEPY`_ IS REQUIRED FOR FULL POSIX COMPLIANCE.
2520
IF THE LATEST OFFICIAL RELEASE OF FUSEPY IS USED INSTEAD, TIMESTAMPS WILL BE

src/loggedfs/core.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import re
4141
import stat
4242
import sys
43+
import time
4344

4445
import fuse
4546
from fuse import (
@@ -260,6 +261,7 @@ class loggedfs: # (Operations):
260261

261262

262263
WITH_NANOSECOND_INT = True
264+
flag_utime_omit_ok = 1
263265

264266

265267
def __init__(self,
@@ -604,10 +606,30 @@ def unlink(self, path):
604606
@__log__(format_pattern = '{0}', abs_path_fields = [0])
605607
def utimens(self, path, times = None):
606608

609+
UTIME_OMIT = (1 << 30) - 2
610+
UTIME_NOW = (1 << 30) - 1
611+
612+
def _fix_time_(atime, mtime):
613+
if UTIME_OMIT in (atime, mtime):
614+
st = os.lstat(relpath, dir_fd = self.root_path_fd)
615+
if atime == UTIME_OMIT:
616+
atime = st.st_atime_ns
617+
if mtime == UTIME_OMIT:
618+
mtime = st.st_mtime_ns
619+
if UTIME_NOW in (atime, mtime):
620+
now = int(time.time() * 10**9)
621+
if atime == UTIME_NOW:
622+
atime = now
623+
if mtime == UTIME_NOW:
624+
mtime = now
625+
return (atime, mtime)
626+
627+
relpath = self._rel_path(path)
628+
607629
if self.flag_nanosecond_int:
608-
os.utime(self._rel_path(path), ns = times, dir_fd = self.root_path_fd, follow_symlinks = False)
630+
os.utime(relpath, ns = _fix_time_(*times), dir_fd = self.root_path_fd, follow_symlinks = False)
609631
else:
610-
os.utime(self._rel_path(path), times = times, dir_fd = self.root_path_fd, follow_symlinks = False)
632+
os.utime(relpath, times = times, dir_fd = self.root_path_fd, follow_symlinks = False)
611633

612634

613635
@__log__(format_pattern = '{1} bytes to {0} at offset {2}', abs_path_fields = [0], length_fields = [1])

tests/loggedfs_libtest/param.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ def __ignore_tests__(old_group_list):
128128
# ('rmdir', 3),
129129
# ('rename', 2)
130130
# ] # The original LoggedFS crashes when tested against those.
131-
xfail_group_list = [
132-
('utimensat', 2)
133-
] # likely bugs in libfuse 2.9
131+
xfail_group_list = []
134132

135133
for group_path in old_group_list:
136134

0 commit comments

Comments
 (0)