From 9f4e736ad072ee9b539fa55a6eeb012b98cdded7 Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Thu, 12 Aug 2021 04:05:59 +0200 Subject: [PATCH] access.2, chmod.2, chown.2, execveat.2, futimesat.2, link.2, mkdir.2, mknod.2, mount_setattr.2, open.2, open_by_handle_at.2, readlink.2, rename.2, stat.2, statx.2, symlink.2, unlink.2, utimensat.2, mkfifo.3, scandir.3: Fix EBADF error description Make the description of the EBADF error for invalid 'dirfd' more uniform. In particular, note that the error only occurs when the pathname is relative, and that it occurs when the 'dirfd' is neither valid *nor* has the value AT_FDCWD. Signed-off-by: Michael Kerrisk --- man2/access.2 | 6 +++++- man2/chmod.2 | 6 +++++- man2/chown.2 | 6 +++++- man2/execveat.2 | 7 +++++-- man2/futimesat.2 | 6 +++++- man2/link.2 | 10 +++++++--- man2/mkdir.2 | 6 +++++- man2/mknod.2 | 6 +++++- man2/mount_setattr.2 | 6 +++++- man2/open.2 | 6 +++++- man2/open_by_handle_at.2 | 6 ++++-- man2/readlink.2 | 6 +++++- man2/rename.2 | 6 ++++-- man2/stat.2 | 6 +++++- man2/statx.2 | 6 +++++- man2/symlink.2 | 6 +++++- man2/unlink.2 | 6 +++++- man2/utimensat.2 | 2 +- man3/mkfifo.3 | 6 +++++- man3/scandir.3 | 6 +++++- 20 files changed, 96 insertions(+), 25 deletions(-) diff --git a/man2/access.2 b/man2/access.2 index 3957a2ab8..0fb2a79f7 100644 --- a/man2/access.2 +++ b/man2/access.2 @@ -278,8 +278,12 @@ The following additional errors can occur for .BR faccessat (): .TP .B EBADF +.I pathname +is relative but .I dirfd -is not a valid file descriptor. +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B EINVAL Invalid flag specified in diff --git a/man2/chmod.2 b/man2/chmod.2 index 017aab9d6..6862a7e3d 100644 --- a/man2/chmod.2 +++ b/man2/chmod.2 @@ -309,8 +309,12 @@ The following additional errors can occur for .BR fchmodat (): .TP .B EBADF +.I pathname +is relative but .I dirfd -is not a valid file descriptor. +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B EINVAL Invalid flag specified in diff --git a/man2/chown.2 b/man2/chown.2 index e35587b28..354193c28 100644 --- a/man2/chown.2 +++ b/man2/chown.2 @@ -293,8 +293,12 @@ The following additional errors can occur for .BR fchownat (): .TP .B EBADF +.I pathname +is relative but .I dirfd -is not a valid file descriptor. +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B EINVAL Invalid flag specified in diff --git a/man2/execveat.2 b/man2/execveat.2 index 495617b09..ad952631c 100644 --- a/man2/execveat.2 +++ b/man2/execveat.2 @@ -121,9 +121,12 @@ can also occur for The following additional errors can occur for .BR execveat (): .TP -.B EBADF +.I pathname +is relative but .I dirfd -is not a valid file descriptor. +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B EINVAL Invalid flag specified in diff --git a/man2/futimesat.2 b/man2/futimesat.2 index 86e941fe5..c82e4014c 100644 --- a/man2/futimesat.2 +++ b/man2/futimesat.2 @@ -99,8 +99,12 @@ The following additional errors can occur for .BR futimesat (): .TP .B EBADF +.I pathname +is relative but .I dirfd -is not a valid file descriptor. +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B ENOTDIR .I pathname diff --git a/man2/link.2 b/man2/link.2 index c285ae896..2c9057653 100644 --- a/man2/link.2 +++ b/man2/link.2 @@ -282,10 +282,14 @@ The following additional errors can occur for .BR linkat (): .TP .B EBADF +.I oldpath +.RI ( newpath ) +is relative but .I olddirfd -or -.I newdirfd -is not a valid file descriptor. +.RI ( newdirfd ) +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B EINVAL An invalid flag value was specified in diff --git a/man2/mkdir.2 b/man2/mkdir.2 index e4d7d9472..355ba086e 100644 --- a/man2/mkdir.2 +++ b/man2/mkdir.2 @@ -192,8 +192,12 @@ The following additional errors can occur for .BR mkdirat (): .TP .B EBADF +.I pathname +is relative but .I dirfd -is not a valid file descriptor. +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B ENOTDIR .I pathname diff --git a/man2/mknod.2 b/man2/mknod.2 index 1de3cd027..f5bb0900a 100644 --- a/man2/mknod.2 +++ b/man2/mknod.2 @@ -229,8 +229,12 @@ The following additional errors can occur for .BR mknodat (): .TP .B EBADF +.I pathname +is relative but .I dirfd -is not a valid file descriptor. +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B ENOTDIR .I pathname diff --git a/man2/mount_setattr.2 b/man2/mount_setattr.2 index 81dc4856b..24cd36382 100644 --- a/man2/mount_setattr.2 +++ b/man2/mount_setattr.2 @@ -408,8 +408,12 @@ is set to indicate the cause of the error. .SH ERRORS .TP .B EBADF +.I pathname +is relative but .I dirfd -is not a valid file descriptor. +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B EBADF .I userns_fd diff --git a/man2/open.2 b/man2/open.2 index bfc1b2f6b..7c0e9cd2e 100644 --- a/man2/open.2 +++ b/man2/open.2 @@ -1290,8 +1290,12 @@ The following additional errors can occur for .BR openat (): .TP .B EBADF +.I pathname +is relative but .I dirfd -is not a valid file descriptor. +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B ENOTDIR .I pathname diff --git a/man2/open_by_handle_at.2 b/man2/open_by_handle_at.2 index f3fa2a4f4..9e33f5753 100644 --- a/man2/open_by_handle_at.2 +++ b/man2/open_by_handle_at.2 @@ -349,9 +349,11 @@ is not an open file descriptor. .TP .B EBADF .I pathname -is relative and +is relative but .I dirfd -is not a valid file descriptor. +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B EFAULT .IR handle diff --git a/man2/readlink.2 b/man2/readlink.2 index 7387ee4e0..6ae07c385 100644 --- a/man2/readlink.2 +++ b/man2/readlink.2 @@ -200,8 +200,12 @@ The following additional errors can occur for .BR readlinkat (): .TP .B EBADF +.I pathname +is relative but .I dirfd -is not a valid file descriptor. +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B ENOTDIR .I pathname diff --git a/man2/rename.2 b/man2/rename.2 index dfde1ce6d..a5dbd55ba 100644 --- a/man2/rename.2 +++ b/man2/rename.2 @@ -438,9 +438,11 @@ and .BR renameat2 (): .TP .B EBADF +.I oldpath +.RI ( newpath ) +is relative but .I olddirfd -or -.I newdirfd +.RI ( newdirfd ) is not a valid file descriptor. .TP .B ENOTDIR diff --git a/man2/stat.2 b/man2/stat.2 index 339920d71..e5859abaf 100644 --- a/man2/stat.2 +++ b/man2/stat.2 @@ -434,8 +434,12 @@ The following additional errors can occur for .BR fstatat (): .TP .B EBADF +.I pathname +is relative but .I dirfd -is not a valid file descriptor. +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B EINVAL Invalid flag specified in diff --git a/man2/statx.2 b/man2/statx.2 index 62e86fb1b..85b23dd59 100644 --- a/man2/statx.2 +++ b/man2/statx.2 @@ -505,8 +505,12 @@ in the path prefix of .BR path_resolution (7).) .TP .B EBADF +.I pathname +is relative but .I dirfd -is not a valid open file descriptor. +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B EFAULT .I pathname diff --git a/man2/symlink.2 b/man2/symlink.2 index 87c25d5f4..83d29d3e9 100644 --- a/man2/symlink.2 +++ b/man2/symlink.2 @@ -203,8 +203,12 @@ The following additional errors can occur for .BR symlinkat (): .TP .B EBADF +.I linkpath +is relative but .I newdirfd -is not a valid file descriptor. +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B ENOENT .I linkpath diff --git a/man2/unlink.2 b/man2/unlink.2 index 6f4c187f8..dbb17ea75 100644 --- a/man2/unlink.2 +++ b/man2/unlink.2 @@ -246,8 +246,12 @@ The following additional errors can occur for .BR unlinkat (): .TP .B EBADF +.I pathname +is relative but .I dirfd -is not a valid file descriptor. +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B EINVAL An invalid flag value was specified in diff --git a/man2/utimensat.2 b/man2/utimensat.2 index 006677db8..4ef7be7b8 100644 --- a/man2/utimensat.2 +++ b/man2/utimensat.2 @@ -269,7 +269,7 @@ is not a valid file descriptor. .B EBADF .RB ( utimensat ()) .I pathname -is a relative pathname, but +is relative but .I dirfd is neither .BR AT_FDCWD diff --git a/man3/mkfifo.3 b/man3/mkfifo.3 index e98c3488e..85622b239 100644 --- a/man3/mkfifo.3 +++ b/man3/mkfifo.3 @@ -162,8 +162,12 @@ The following additional errors can occur for .BR mkfifoat (): .TP .B EBADF +.I pathname +is relative but .I dirfd -is not a valid file descriptor. +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B ENOTDIR .I pathname diff --git a/man3/scandir.3 b/man3/scandir.3 index 0ea295ce3..ba7ef58ca 100644 --- a/man3/scandir.3 +++ b/man3/scandir.3 @@ -204,8 +204,12 @@ The following additional errors can occur for .BR scandirat (): .TP .B EBADF +.I dirp +is relative but .I dirfd -is not a valid file descriptor. +is neither +.B AT_FDCWD +nor a valid file descriptor. .TP .B ENOTDIR .I dirp