]> git.ipfire.org Git - thirdparty/systemd.git/commit
fd-util: Add fd_is_writable() to check if FD is opened for writing
authorChris Down <chris@chrisdown.name>
Mon, 17 Nov 2025 03:05:09 +0000 (11:05 +0800)
committerChris Down <chris@chrisdown.name>
Wed, 19 Nov 2025 18:02:21 +0000 (02:02 +0800)
commit592c57e586fa5aac78145d689608c487344605db
treecd24ec4cc5f3c01a1d0c9f730ed7f4176936945a
parent3f0fc9321932f8e0e35922586c7369eec557793d
fd-util: Add fd_is_writable() to check if FD is opened for writing

This checks whether a file descriptor is valid and opened in a mode that
allows writing (O_WRONLY or O_RDWR). This is useful when we want to
verify that inherited FDs can actually be used for output operations
before dup'ing them.

The helper explicitly handles O_PATH file descriptors, which cannot be
used for I/O operations and thus are never writable.
src/basic/fd-util.c
src/basic/fd-util.h
src/test/test-fd-util.c