Re: openat("./...", O_CREAT) fails even though the directory exists

From: Lexi Winter <ivy_at_freebsd.org>
Date: Thu, 23 Oct 2025 15:22:00 UTC
Marcin Cieslak wrote in <s1qo29n2-23s2-sqp5-2060-n8qr5rsr5584@fncre.vasb>:
> On Mon, 13 Oct 2025, Lexi Winter wrote:
> 
> > after some more debugging, i think what's going on here is that pkg(8)
> > is deleting and recreating /var/spool/mqueue on upgrade, which means
> > smmsp's open fd to that directory is no longer valid, and therefore
> > openat() returns this unusual error.
> 
> I think mail spool queues should be left untouched by pkg(8). There might be some mail
> there waiting to be sent.

if there are files in the directory, it won't be removed, as far as i
know.  this is why /var/spool/clientmqueue isn't affected, because smmsp
puts it PID file there, so pkg doesn't remove the directory.

one proposal to "fix" this problem was to have sendmail's rc.d script
create a dummy file there while sendmail is running, but this doesn't
fix the underlying issue.

my preference would be to fix this in pkg(8).  there is some additional
discussion on the review: https://reviews.freebsd.org/D53061.