diff --git a/man2/mount_setattr.2 b/man2/mount_setattr.2 index 07c12e3f8..196e98242 100644 --- a/man2/mount_setattr.2 +++ b/man2/mount_setattr.2 @@ -981,6 +981,18 @@ main(int argc, char *argv[]) /* In the following, \-1 as the \(aqdirfd\(aq argument ensures that open_tree() fails if \(aqsource\(aq is not an absolute pathname. */ +.\" Christian Brauner +.\" When writing programs I like to never use relative paths with AT_FDCWD +.\" because. Because making assumptions about the current working directory +.\" of the calling process is just too easy to get wrong; especially when +.\" pivot_root() or chroot() are in play. +.\" My absolut preference (joke intended) is to open a well-known starting +.\" point with an absolute path to get a dirfd and then scope all future +.\" operations beneath that dirfd. This already works with old-style +.\" openat() and _very_ cautious programming but openat2() and its +.\" resolve-flag space have made this **chef's kiss**. +.\" If I can't operate based on a well-known dirfd I use absolute paths +.\" with a -EBADF dirfd passed to *at() functions. int fd_tree = open_tree(\-1, source, OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC |