@@ -652,6 +652,10 @@ def _dispatch(self, notif: SeccompNotif) -> None:
652652 nr_getdents = _SYSCALL_NR .get ("getdents" )
653653
654654 if nr in (nr_getdents64 , nr_getdents ) and self ._cow_handler is not None :
655+ # Fast path: no changes yet → kernel handles readdir correctly
656+ if not self ._cow_handler ._branch .has_changes :
657+ self ._respond_continue (notif .id )
658+ return
655659 child_fd_num = notif .data .args [0 ] & 0xFFFFFFFF
656660 try :
657661 target = os .readlink (f"/proc/{ pid } /fd/{ child_fd_num } " )
@@ -701,6 +705,15 @@ def _dispatch(self, notif: SeccompNotif) -> None:
701705 # Special arg layouts
702706 cow_special_nrs = {nr_symlinkat , nr_symlink ,
703707 nr_linkat , nr_link } - {None }
708+ # Read-only COW syscalls — can skip when no changes yet
709+ cow_readonly_nrs = {nr_newfstatat , nr_statx , nr_faccessat ,
710+ nr_stat , nr_lstat , nr_access ,
711+ nr_readlinkat , nr_readlink } - {None }
712+
713+ # Fast path: read-only COW syscalls with no changes → let kernel handle
714+ if nr in cow_readonly_nrs and not self ._cow_handler ._branch .has_changes :
715+ self ._respond_continue (notif .id )
716+ return
704717
705718 # symlink/link have special arg layouts — handle separately
706719 if nr in cow_special_nrs :
@@ -900,6 +913,12 @@ def _dispatch(self, notif: SeccompNotif) -> None:
900913
901914 # --- COW: redirect opens under workdir to upper dir ---
902915 if self ._cow_handler is not None and self ._cow_handler .matches (path ):
916+ # Fast path: read-only open with no changes → kernel handles it
917+ from .cowfs ._handler import _WRITE_FLAGS , O_DIRECTORY
918+ is_read_only = not (flags & (_WRITE_FLAGS | O_DIRECTORY ))
919+ if is_read_only and not self ._cow_handler ._branch .has_changes :
920+ self ._respond_continue (notif .id )
921+ return
903922 self ._handle_cow_open (notif , path , flags )
904923 return
905924
0 commit comments