]> git.ipfire.org Git - thirdparty/man-pages.git/commit
mount_setattr.2: EXAMPLES: use -1 rather than -EBADF
authorMichael Kerrisk <mtk.manpages@gmail.com>
Thu, 12 Aug 2021 03:16:42 +0000 (05:16 +0200)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Thu, 12 Aug 2021 05:33:53 +0000 (07:33 +0200)
commit45ea537cf2fc7d9804f510e823a8c340db52f7a4
tree31e13da15c0aca47c1933156457b4ac00ffc9eb3
parentfaf2534942862b35b8427f348c01c60d6b8b8944
mount_setattr.2: EXAMPLES: use -1 rather than -EBADF

From email with Christian Braner:

> [1]: In this code "source" is expected to be absolute. If it's not
>      absolute we should fail. This can be achieved by passing -1/-EBADF,
>      afaict.
D'oh! Okay. I hadn't considered that use case for an invalid dirfd.
(And now I've done some adjustments to openat(2),which contains a
rationale for the *at() functions.)

So, now I understand your purpose, but still the code is obscure,
since

* You use a magic value (-EBADF) rather than (say) -1.
* There's no explanation (comment about) of the fact that you want
  to prevent relative pathnames.

So, I've changed the code to use -1, not -EBADF, and I've added some
comments to explain that the intent is to prevent relative pathnames.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
man2/mount_setattr.2