Skip to content

Draft: s3:lib:system - add procfd-path for FreeBSD

FreeBSD's proc filesystem lacks the Linux ability to perform race-free path-based system calls on /proc/self/fd/FD paths. The closest equivalent prior to recent work on FreeBSD 13 was the fdescfs filesystem, which would only perform equivalent of dup2() when re-opened. After discussion with FreeBSD team members, two new features were added to FreeBSD: the O_EMPTY_PATH open flag, which allows re-openeing an existing descriptor with new flags in a race-free manner, and a new fdescfs mount option "nodup", which returns a real vnode in VFS_LOOKUP (providing behavior like /proc/self/fd on Linux).

So basically, there's two complementary strategies in this commit with regard to FreeBSD support. First, use O_EMPTY_PATH for converting pathref descriptors in open.c. Second, look for / use an fdescfs filesystem with the appropriate mount option for other cases where we need procfd paths.

Checklist

  • Commits have Signed-off-by: with name/author being identical to the commit author
  • (optional) This MR is just one part towards a larger feature.
  • (optional, if backport required) Bugzilla bug filed and BUG: tag added
  • Test suite updated with functionality tests
  • Test suite updated with negative tests
  • Documentation updated
  • CI timeout is 3h or higher (see Settings/CICD/General pipelines/ Timeout)

Reviewer's checklist:

  • There is a test suite reasonably covering new functionality or modifications
  • Function naming, parameters, return values, types, etc., are consistent and according to README.Coding.md
  • This feature/change has adequate documentation added
  • No obvious mistakes in the code
Edited by Andrew Walker

Merge request reports