>> os.open("/mnt/dozer", os.O_DIRECTORY) 3 >>> os.open("/dev/fd/3", os.O_DIRECTORY) Traceback (most recent call last): File "<stdin>", line 1, in <module> NotADirectoryError: [Errno 20] Not a directory: '/dev/fd/3' Manpage states: Flags to the open(2) call other than O_RDONLY, O_WRONLY and O_RDWR are ignored. Ideally, it would be nice to have O_DIRECTORY support. The reason for this preference is that there are various places where Samba needs to be able to convert descriptors opened with O_PATH to regular opens, and it perform these opens with O_DIRECTORY if it is expected to be a directory.
Try https://reviews.freebsd.org/D30131