From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-a8-smtp.messagingengine.com (fhigh-a8-smtp.messagingengine.com [103.168.172.159]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BB093A4F5D; Tue, 31 Mar 2026 19:14:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.159 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774984459; cv=none; b=vFtaTat5jHZpACTqfTDWxLtKejWo9nN9Apru91nFvlydsYuFIoXZCctUYiBCan2ftZihcNIj4TNnhVi3pasqOEAgX/JWvOb+BLJEGPRKSa9y/Nm8Rx4HDe1AdwIVdxl9obq6N5gRug2KDQKuSxFEsCNZoZRlirZGz+j+9A+m4UA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774984459; c=relaxed/simple; bh=6UfukQtBmWKYp02VBb+8KF+mHtOfziVMOpzDUst/kuY=; h=MIME-Version:Date:From:To:Cc:Message-Id:In-Reply-To:References: Subject:Content-Type; b=V9nRJOf3vTVJFmso333jmlyzMd0TR/WK9QxnUKJBqbNErxgHWOP6YuDeGtCJPDXlqkgpIkiMLxf5GUDSj6bFCPaJC11uEb+53P5wpdQLo+wI1z4+I3osuww/B7mIgWTxjulTW+pUXGvVOVcw7JuH1xjgYkZp/jN999vDuhwcPU8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de; spf=pass smtp.mailfrom=arndb.de; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b=GbCrd7S/; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=UXUZA9Om; arc=none smtp.client-ip=103.168.172.159 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arndb.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b="GbCrd7S/"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="UXUZA9Om" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id 800E51400050; Tue, 31 Mar 2026 15:14:16 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-04.internal (MEProxy); Tue, 31 Mar 2026 15:14:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1774984456; x=1775070856; bh=2qDuSoZzFYhBvW0zARX8aWcBYydHA20yyvvWr3QXkMg=; b= GbCrd7S/Hz7kuAczlaApsolK/1cCYgSFtN3DKf5x8jls+WqX1vgAMLjQsChwgJ2c ReIc3wjun+nOwci6NBX7pL/43IcVUQAIfijbzf/P3UKePZl3u5oMV2G90Z4GKEIa AYcux/qD4OGLbBww2FkDZEs8+6QxCFKVeEyqfk2GDletx4XlV/+Smp/wQubOdNcJ PIb7/IpCg1510CapjvpLz/Vj/2LjQ3pLOp8BWsCOup1hicZnCoPK7u7m32guXZh5 gmM12hVg7Po83jJlA5bUur1sxfzl7GLof/RZORBs3ttHu2g9IwxP8uGzwWirmz9X 4bCD461wMP3DwOni3oeOvw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1774984456; x= 1775070856; bh=2qDuSoZzFYhBvW0zARX8aWcBYydHA20yyvvWr3QXkMg=; b=U XUZA9OmLKQwHTrupNOy1AOBmSGJPjq6d4bTs6eDLJOPbhynRy58J7oo8os41/EtN hkfmDLgoFpkBVOyMeVxjhSNBvbcJ2MY2+yw22JQ+iZy/uKCvnHtzYGI53/ZBtI1x CAbw89NOFat996CHOzhaRZUCDqGshBBZ14xw3JZEr6PmcsGqu9lPCf0URmtbYxbs gETAA2hkQMWG58BvJliCqBpSkcPJvqCP1Yf+C40g4LAw85brtJ8NmKFAMHoJVMPY ux6UZ4E8m4CB3JXnECgHYFO04vaD1DgYJ4EWi4eyDipi21wZ71RR9f5DwyPEjkVj zt8Te35C8WZlIVRwzugIA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgddutdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurh epofggfffhvfevkfgjfhfutgfgsehtjeertdertddtnecuhfhrohhmpedftehrnhguuceu vghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrdguvgeqnecuggftrfgrthhtvghrnh epjefhudekueettedtffetvefhjeegteekhfehueeliefhhfegveehffehhedvjeffnecu ffhomhgrihhnpehgihhthhhusgdrtghomhdplhifnhdrnhgvthenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrrhhnugesrghrnhgusgdruggv pdhnsggprhgtphhtthhopeefvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepsg hpsegrlhhivghnkedruggvpdhrtghpthhtoheptgihphhhrghrsegthihphhgrrhdrtgho mhdprhgtphhtthhopehmrghthhhivghurdguvghsnhhohigvrhhssegvfhhfihgtihhosh drtghomhdprhgtphhtthhopegrlhgvgidrrghrihhnghesghhmrghilhdrtghomhdprhgt phhtthhopehpvghtvghriiesihhnfhhrrgguvggrugdrohhrghdprhgtphhtthhopegsrh gruhhnvghrsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehjlhgrhihtohhnsehkvghr nhgvlhdrohhrghdprhgtphhtthhopehjohhlshgrsehkvghrnhgvlhdrohhrghdprhgtph htthhopehluhhtoheskhgvrhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id C3FFE700065; Tue, 31 Mar 2026 15:14:14 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk X-Mailing-List: linux-api@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ThreadId: ALL_5dcvP_Dc Date: Tue, 31 Mar 2026 21:13:34 +0200 From: "Arnd Bergmann" To: "Jori Koolstra" , "Andy Lutomirski" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , x86@kernel.org, "Alexander Viro" , "Christian Brauner" , "Jeff Layton" , "Chuck Lever" , shuah , "Greg Kroah-Hartman" , "H. Peter Anvin" , "Jan Kara" , "Alexander Aring" Cc: "Peter Zijlstra" , "Oleg Nesterov" , "Andrey Albershteyn" , "Jiri Olsa" , "Mathieu Desnoyers" , =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= , "Namhyung Kim" , "Arnaldo Carvalho de Melo" , "Aleksa Sarai" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, Linux-Arch , linux-kselftest@vger.kernel.org, cmirabil@redhat.com, "Masami Hiramatsu" Message-Id: In-Reply-To: <20260331172011.3512876-2-jkoolstra@xs4all.nl> References: <20260331172011.3512876-1-jkoolstra@xs4all.nl> <20260331172011.3512876-2-jkoolstra@xs4all.nl> Subject: Re: [RFC PATCH 1/2] vfs: syscalls: add mkdirat_fd() Content-Type: text/plain Content-Transfer-Encoding: 7bit On Tue, Mar 31, 2026, at 19:19, Jori Koolstra wrote: > Currently there is no way to race-freely create and open a directory. > For regular files we have open(O_CREAT) for creating a new file inode, > and returning a pinning fd to it. The lack of such functionality for > directories means that when populating a directory tree there's always > a race involved: the inodes first need to be created, and then opened > to adjust their permissions/ownership/labels/timestamps/acls/xattrs/..., > but in the time window between the creation and the opening they might > be replaced by something else. > > Addressing this race without proper APIs is possible (by immediately > fstat()ing what was opened, to verify that it has the right inode type), > but difficult to get right. Hence, mkdirat_fd() that creates a directory > and returns an O_DIRECTORY fd is useful. > > This feature idea (and description) is taken from the UAPI group: > https://github.com/uapi-group/kernel-features?tab=readme-ov-file#race-free-creation-and-opening-of-non-file-inodes > > Signed-off-by: Jori Koolstra I checked that the calling conventions are fine, i.e. this will work as expected across all architectures. I assume you are also aware that the non-RFC patch will need to add the syscall number to all .tbl files. The hardest problem here does seem to be the naming of the new syscall, and I'm sorry to not be able to offer any solution either, just two observations: - mkdirat/mkdirat_fd sounds similar to the existing quotactl/quotactl_fd pair, but quotactl_fd() takes a file descriptor argument rather than returning it, which makes this addition quite confusing. - the nicest interface IMO would have been a variation of openat(dfd, filename, O_CREAT | O_DIRECTORY, mode) but that is a minefield of incompatible implementations[1], so we can't do that without changing the behavior for existing callers that currently run into an error. Arnd [1] https://lwn.net/Articles/926782/