From: Mark Kettenis Subject: Re: openat(2) is mostly useless, sadly To: "Theo de Raadt" Cc: h@hartzer.sh, tech@openbsd.org Date: Sat, 31 May 2025 16:56:15 +0200 > From: "Theo de Raadt" > Date: Fri, 30 May 2025 19:17:46 -0600 > > Steffen Nurpmeso wrote: > > > I would not use ENOTTY for F_BELOW on !DIR, maybe ENOTDIR is > > better. > > >From errno(2) manpage: > > 20 ENOTDIR Not a directory. A component of the specified pathname > existed, but it was not a directory, when a directory was > expected. > > F_BELOW is fcntl(2). > > int > fcntl(int fd, int cmd, ...); > > But there is no pathname. Yes it is partly vague, but then grep the whole > tree for ENOTDIR and always anticipates a pathname at a higher level. Note that openat(2) says: [ENOTDIR] The path argument specifies a relative path and the fd argument is a valid file descriptor but it does not reference a directory. So here ENOTDIR does apply to a file descriptor.