Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Oct 2025 10:27:20 +0100
From:      Lexi Winter <ivy@freebsd.org>
To:        Olivier Certner <olce@freebsd.org>
Cc:        fs@freebsd.org, current@freebsd.org
Subject:   Re: openat("./...", O_CREAT) fails even though the directory exists
Message-ID:  <aOzF-JAOyg-T-Ule@amaryllis.le-fay.org>
In-Reply-To: <2507674.THHZn3L5Ee@ravel>
References:  <aOy5LUUu5DCwY_XZ@amaryllis.le-fay.org> <2507674.THHZn3L5Ee@ravel>

next in thread | previous in thread | raw e-mail | index | archive | help

--fCeECQ7M9wJ2QMlP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Olivier Certner wrote in <2507674.THHZn3L5Ee@ravel>:
> > 44288: fstatat(AT_FDCWD,"./df59D8I2px044288",0xecbda905210,0x0) ERR#2 '=
No such file or directory'
> > 44288: fstatat(AT_FDCWD,".",{ mode=3Ddrwxr-xr-x ,inode=3D129826,size=3D=
2,blksize=3D131072 },AT_SYMLINK_NOFOLLOW) =3D 0 (0x0)
> > 44288: geteuid()                                 =3D 0 (0x0)
> > 44288: fstatat(AT_FDCWD,".",{ mode=3Ddrwxr-xr-x ,inode=3D129826,size=3D=
2,blksize=3D131072 },0x0) =3D 0 (0x0)
> > 44288: openat(AT_FDCWD,"./df59D8I2px044288",O_RDWR|O_CREAT|O_EXCL,0600)=
 ERR#2 'No such file or directory'
> >=20
> > this doesn't make sense to me: since "." exists, how can openat() return
> > ENOENT here?
>=20
> How do you come to this conclusion?  In what you pasted above, and in
> the full traces, the openat(AT_FDCWD) fails on the same file
> ("./df59D8I2px044288") on which the fstatat(AT_FDCWD) just above
> already failed with ENOENT.  So the most plausible explanation is that
> that file just does not exist at this point.

the file should not exist, and this is expected.  the truss output shows:

- "./df59D8I2px044288" does not exist: fstatat() returns ENOENT.  this
  is expected, because this is a new file we are trying to create (if it
  existed, this would be a different error).

- "." exists: fstatat(AT_FDCWD, ".") returns 0

- trying to create "./df59D8I2px044288", which doesn't exist, with
  O_CREAT|O_EXCL fails with ENOENT.

the issue is in the last item: since this file doesn't exist, and we're
opening it with O_CREAT, how can this fail?

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 am not sure how to fix this, but the impact is that upgrading the
FreeBSD-sendmail package breaks sendmail on a running system, so we
need to fix this somehow for 15.0.  i suspect the fix will be in pkgbase
somewhere: for example, we could restart sendmail on upgrade, or tell
the user to do that.

--fCeECQ7M9wJ2QMlP
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iHUEABYKAB0WIQSyjTg96lp3RifySyn1nT63mIK/YAUCaOzF+AAKCRD1nT63mIK/
YGwNAP4nSy+NXEu+4RvsULeIXBTMPCqnXPm5JwCpOrL7Tev2cQD8DQ2XER2NRNHL
5fy8Eg7bCW/1gpdkF3w4YcAJYdXDZAQ=
=AfG3
-----END PGP SIGNATURE-----

--fCeECQ7M9wJ2QMlP--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?aOzF-JAOyg-T-Ule>