From nobody Sat Jul 18 00:28:14 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4h270v64sZz6ll0S for ; Sat, 18 Jul 2026 00:28:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4h270v1740z3QPK for ; Sat, 18 Jul 2026 00:28:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1784334495; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JN7nmaDxT6EEHg8rtZSFbFv5fEY9WshAp9yjRcsnwiY=; b=P3dQZv2M5pofLmP1yAigcW+gcSGhXLIYbZqrRTRE8EoRY51oXEQfrdFV14toi89aMFUcef PhcNYDIpXstVMA7EjhAvNmDBBZ6EXFsLMnbW5oRnj1w/up5P1/FHMo8edn88+0AIm7Q47m XxGOq2rms7ZyqtOTJJO0AgXmoCj1qCK6lecxmRL+B3ZLu95Q1VYUDdVKhqeLMH/bFA4Atn k/4qk0QAC8XUeCOFa77h5UZA/CEYTt5geobyqyqgBRqmnidtH6CrIoOxma0GUIjBnTcxVS GJFsEoASUcsZIMb/K+n+hvSlLzWIOCqmlVFMzIjQf4uEX56HPmu9JMn3Y0W+3Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1784334495; a=rsa-sha256; cv=none; b=bj2kdOfozhLR7Q93coIOqcjLZr1BkOxMDCScy63sd3t3b1GNMeorSVJHytxdZjreAbHAAQ 4siIdrmrefa3Zv/ySR2ltvmJ6ooFJMPmCi4dWuhUEFcP/k+DajGIpx2nPZk+3hJZPgMQ03 xw0YK7K4oyOhn4HMCmzkdJWgW1F/WPWSmW229LqLdG/MUSXoAI/JAhwJCTefPP8g5dEOt4 Zhc17mfouTfvO4p09YkoR8e8mP6NvQ2UygRL2hC+X/5zYywDHnej8egJ9TkblTgpHL6B1a y8ygFRfhkByQ5nfBx1rrh9oleluec8UDZaHjHX0bbGiM5LByEobYWhBPU7gHaA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1784334495; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JN7nmaDxT6EEHg8rtZSFbFv5fEY9WshAp9yjRcsnwiY=; b=w4LRNkZF55MLRRYGjbtT6nbNt9cmczohD/gWhiLnttSw2BLjcZ0jNXV/K9dXvbJVOEjd5A gTWnAZ9+KclINfnDQJsNE2sLT/Zo0ZXmk91Zo52fW1Hm/1Vni538dRaznCaJJ3GivD+gBU w+W5P57BjJSy7R/HTOpW0xqWvtYfWNrtzMxKXuFjvV1gNE6FxdZz018c7BIqCelZe9xUPf 5w3a2ZW34R/JyMdTd26yhYXdutf7Dn8ihQVXRg+lcykZv9RwEzdjmIvhu5EOPN2VmnF/Ry Ktx/g4B67aZ/w58wwK34DA5ecOB7G9p7ADoR3twWDyq68w93wonuhwj8xKEAGg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h270t4mK1z199T for ; Sat, 18 Jul 2026 00:28:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3d4f7 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 18 Jul 2026 00:28:14 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 672345cd24e1 - stable/15 - tmpfs: implement AT_RENAME_EXCHANGE List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 672345cd24e131f171df469d902165963dab4557 Auto-Submitted: auto-generated Date: Sat, 18 Jul 2026 00:28:14 +0000 Message-Id: <6a5ac89e.3d4f7.72ba1241@gitrepo.freebsd.org> The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=672345cd24e131f171df469d902165963dab4557 commit 672345cd24e131f171df469d902165963dab4557 Author: Konstantin Belousov AuthorDate: 2026-06-18 18:40:40 +0000 Commit: Konstantin Belousov CommitDate: 2026-07-18 00:27:25 +0000 tmpfs: implement AT_RENAME_EXCHANGE (cherry picked from commit 7e06c33151e7664f6d664ee282d8da1985ce94aa) --- sys/fs/tmpfs/tmpfs_vnops.c | 90 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 67 insertions(+), 23 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 9239d146ee9d..61fedc194db5 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -1055,7 +1055,7 @@ tmpfs_rename(struct vop_rename_args *v) struct vnode *tvp = v->a_tvp; struct componentname *tcnp = v->a_tcnp; char *newname; - struct tmpfs_dirent *de; + struct tmpfs_dirent *de, *tde; struct tmpfs_mount *tmp; struct tmpfs_node *fdnode; struct tmpfs_node *fnode; @@ -1063,8 +1063,11 @@ tmpfs_rename(struct vop_rename_args *v) struct tmpfs_node *tdnode; int error; bool want_seqc_end; + bool exchange; want_seqc_end = false; + newname = NULL; + error = 0; /* * Disallow cross-device renames. @@ -1076,16 +1079,15 @@ tmpfs_rename(struct vop_rename_args *v) goto out; } - if ((v->a_flags & ~(AT_RENAME_NOREPLACE)) != 0) { + if ((v->a_flags & ~(AT_RENAME_NOREPLACE | AT_RENAME_EXCHANGE)) != 0) { error = EOPNOTSUPP; goto out; } /* If source and target are the same file, there is nothing to do. */ - if (fvp == tvp) { - error = 0; + if (fvp == tvp) goto out; - } + exchange = (v->a_flags & AT_RENAME_EXCHANGE) != 0; /* * If we need to move the directory between entries, lock the @@ -1138,6 +1140,8 @@ tmpfs_rename(struct vop_rename_args *v) fdnode = VP_TO_TMPFS_DIR(fdvp); fnode = VP_TO_TMPFS_NODE(fvp); de = tmpfs_dir_lookup(fdnode, fnode, fcnp); + if (exchange) + tde = tmpfs_dir_lookup(tdnode, tnode, tcnp); /* * Entry can disappear before we lock fdvp. @@ -1151,6 +1155,13 @@ tmpfs_rename(struct vop_rename_args *v) goto out_locked; } MPASS(de->td_node == fnode); + if (exchange) { + if (tde == NULL) { + error = ENOENT; + goto out_locked; + } + MPASS(tde->td_node == tnode); + } /* * If re-naming a directory to another preexisting directory @@ -1168,22 +1179,27 @@ tmpfs_rename(struct vop_rename_args *v) goto out_locked; } - if (fnode->tn_type == VDIR && tnode->tn_type == VDIR) { - if (tnode->tn_size != 0 && - ((tcnp->cn_flags & IGNOREWHITEOUT) == 0 || - tnode->tn_size > tnode->tn_dir.tn_wht_size)) { - error = ENOTEMPTY; + if (!exchange) { + if (fnode->tn_type == VDIR && tnode->tn_type == VDIR) { + if (tnode->tn_size != 0 && + ((tcnp->cn_flags & IGNOREWHITEOUT) == 0 || + tnode->tn_size > + tnode->tn_dir.tn_wht_size)) { + error = ENOTEMPTY; + goto out_locked; + } + } else if (fnode->tn_type == VDIR && + tnode->tn_type != VDIR) { + error = ENOTDIR; goto out_locked; + } else if (fnode->tn_type != VDIR && + tnode->tn_type == VDIR) { + error = EISDIR; + goto out_locked; + } else { + MPASS(fnode->tn_type != VDIR && + tnode->tn_type != VDIR); } - } else if (fnode->tn_type == VDIR && tnode->tn_type != VDIR) { - error = ENOTDIR; - goto out_locked; - } else if (fnode->tn_type != VDIR && tnode->tn_type == VDIR) { - error = EISDIR; - goto out_locked; - } else { - MPASS(fnode->tn_type != VDIR && - tnode->tn_type != VDIR); } } @@ -1197,11 +1213,9 @@ tmpfs_rename(struct vop_rename_args *v) * Ensure that we have enough memory to hold the new name, if it * has to be changed. */ - if (fcnp->cn_namelen != tcnp->cn_namelen || - bcmp(fcnp->cn_nameptr, tcnp->cn_nameptr, fcnp->cn_namelen) != 0) { + if (!exchange && (fcnp->cn_namelen != tcnp->cn_namelen || + bcmp(fcnp->cn_nameptr, tcnp->cn_nameptr, fcnp->cn_namelen) != 0)) newname = malloc(tcnp->cn_namelen, M_TMPFSNAME, M_WAITOK); - } else - newname = NULL; /* * If the node is being moved to another directory, we have to do @@ -1219,8 +1233,38 @@ tmpfs_rename(struct vop_rename_args *v) free(newname, M_TMPFSNAME); goto out_locked; } + } + if (exchange && tnode->tn_type == VDIR) { + MPASS(newname == NULL); + error = tmpfs_rename_check_parent(tmp, tdnode, tvp, + tnode, tde, fdnode, fcnp->cn_cred); + if (error != 0) + goto out_locked; + } + if (fnode->tn_type == VDIR) tmpfs_rename_set_parent(fdnode, fnode, de, tdnode); + if (exchange && tnode->tn_type == VDIR) + tmpfs_rename_set_parent(tdnode, tnode, tde, fdnode); + } + if (exchange) { + de->td_node = tnode; + tde->td_node = fnode; + if (tmpfs_use_nc(fvp)) { + cache_purge(fvp); + cache_purge(tvp); + cache_enter(tdvp, fvp, tcnp); + cache_enter(fdvp, tvp, fcnp); + } + fdnode->tn_status |= TMPFS_NODE_MODIFIED | TMPFS_NODE_CHANGED; + fdnode->tn_accessed = true; + tmpfs_update(fdvp); + if (fdvp != tdvp) { + tdnode->tn_status |= TMPFS_NODE_MODIFIED | + TMPFS_NODE_CHANGED; + tdnode->tn_accessed = true; + tmpfs_update(tdvp); } + goto out_locked; } /*