apple / swift-nio

Event-driven network application framework for high performance protocol servers & clients, non-blocking.
https://swiftpackageindex.com/apple/swift-nio/documentation
Apache License 2.0
7.85k stars 633 forks source link

Add a fallback path if renameat2 fails #2733

Closed glbrntt closed 1 month ago

glbrntt commented 1 month ago

Motivation:

'renameat2' can fail with EINVAL if the RENAME_NOREPLACE flag isn't supported. However, not all kernel versions support this flag which can result in an error when creating a file 'transactionally'.

Using 'renameat2' only happens on Linux as a fallback when O_TMPFILE isn't available.

Modifications:

Result:

Files can still be created exclusively

glbrntt commented 1 month ago

API break is a false-positive as it's SPI:

16:20:09 1 breaking change detected in _NIOFileSystem:
16:20:09   💔 API breakage: func SystemFileHandle.SendableView._close(materialize:) has been renamed to func _close(materialize:failRenameat2WithEINVAL:)