diff --git a/man2/mount_setattr.2 b/man2/mount_setattr.2 index 0739624cc..6ffe5e009 100644 --- a/man2/mount_setattr.2 +++ b/man2/mount_setattr.2 @@ -961,7 +961,10 @@ main(int argc, char *argv[]) const char *source = argv[optind]; const char *target = argv[optind + 1]; - int fd_tree = open_tree(\-EBADF, source, + /* In the following, \-1 as the \(aqdirfd\(aq argument ensures that + open_tree() fails if \(aqsource\(aq is not an absolute pathname. */ + + int fd_tree = open_tree(\-1, source, OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC | AT_EMPTY_PATH | (recursive ? AT_RECURSIVE : 0)); if (fd_tree == \-1) @@ -980,7 +983,10 @@ main(int argc, char *argv[]) close(fd_userns); - ret = move_mount(fd_tree, "", \-EBADF, target, + /* In the following, \-1 as the \(aqto_dirfd\(aq argument ensures that + open_tree() fails if \(aqtarget\(aq is not an absolute pathname. */ + + ret = move_mount(fd_tree, "", \-1, target, MOVE_MOUNT_F_EMPTY_PATH); if (ret == \-1) exit_log("%m \- Failed to attach mount to %s\en", target);