From 028c456aca62bd04cf55c09baad73e1ab19b3867 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 13 Feb 2023 20:11:15 -0800 Subject: [PATCH] ircd::fs: Fix application of O_CREAT based on our expected fd::opts behavior. --- ircd/fs.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ircd/fs.cc b/ircd/fs.cc index f2df67363..698daad5b 100644 --- a/ircd/fs.cc +++ b/ircd/fs.cc @@ -2566,7 +2566,7 @@ try "fs::fs::fd(): openat(2): %s", path }; - assert((flags & ~O_CREAT) || mode != 0); + assert(!(flags & O_CREAT) || mode != 0); fdno = syscall(::openat, dirfd, path_cstr(path), flags, mode); } @@ -2686,7 +2686,7 @@ ircd::fs::flags(const fd::opts &opts) ret |= fs::flags(opts.mode); ret |= opts.direct? O_DIRECT : 0UL; ret |= opts.cloexec? O_CLOEXEC : 0UL; - ret |= opts.create? O_CREAT : 0UL; + ret &= !opts.create? ~O_CREAT : ret; ret |= !opts.blocking? O_NONBLOCK : 0UL; ret |= opts.exclusive? O_EXCL : 0UL; return ret;