From nobody Mon Apr 11 20:30:52 2022 X-Original-To: dev-commits-src-main@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 ACA5311DF422; Mon, 11 Apr 2022 20:30:52 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KcgV44R8Lz3Pjy; Mon, 11 Apr 2022 20:30:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649709052; 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=/AJl89NuySk1OR4aYlW1A1iQblCWs2lQPbrA8phwroY=; b=e8Db9PWpZfGbpN347eqrwO2AYii67J1klQRghoMMwLlQfG2VhYfZVBaxaRZrQ1091c+SHt WridWOlTrvAVEj3nJqdeSozGio6NRBlDycn9zal43kOSxrI7sH4jgJmFgwiabl3G7JFEov iFH5E+4by/PAtJ8NVdM79EFlUxm059t2Ux+Dh1/XfptEr3b+o3yE8VZmyp99gm1s8tNn4E w+kjSQ0zLzZe+7ubTf7o7rJZ4y0pVq3nYC7+ohFvEUDhZ4SsPLLbK3UctThUTXOSq5X1rY dXFNA4twCFQo/1NaFUNDPlJ3XsmH2Nr8rEeAv2hnxI8kSlTelyYr5pjLWDyeXA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6DAEF15DA; Mon, 11 Apr 2022 20:30:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23BKUqRq078485; Mon, 11 Apr 2022 20:30:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23BKUqTj078484; Mon, 11 Apr 2022 20:30:52 GMT (envelope-from git) Date: Mon, 11 Apr 2022 20:30:52 GMT Message-Id: <202204112030.23BKUqTj078484@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: c6487446d7e9 - main - getdirentries: return ENOENT for unlinked but still open directory. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c6487446d7e99537551d2e51a2f6c6569fcb89fc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649709052; 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=/AJl89NuySk1OR4aYlW1A1iQblCWs2lQPbrA8phwroY=; b=I9RLJ5XBco9BXid/lo7zoXoOn/+c1cCCQ/k27Uu7SGMD7Gn4A65Sy9r3mXaXSkWb7ufOGE t4MbYddlZLzPEcjCq5EP+k25H8vaPkrShu2ks7pitAaZp4Ia1BDfd/1VfDjE+zXrA/IHjI ERhyC93dH6h8PAygssc4pgRvSEKMUiPIiesnVQP9N+oL2LKVvDQW61GYjOPu+iXl7dhTUQ PPw69XUIRNBlhg6M8rFGEO79EUMkWK0mGis+ll5fDXI6P30QiyZfKf4Jj99OzopysUhglP ANU8GI0cOVQsnE9+Ptr2h2ersF0l78QMHfEIaija+q1/1Q/UYGdFXNL6lOglQA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649709052; a=rsa-sha256; cv=none; b=mz68olQfuR3nEws3SDrx7mWSHWNIMHjNWUG/rQE11lghagr8hGiHn2zN1VXUoGWfWN+TSC /4oeZdOoKCGwxsmThrsjwdOu1xFQkepoKNsyZtFxHfP3XiSbpwI1U6uXpqC12A4arXtSbd esNQJUOZccPSKVr9MnBclUKQ2Uzp2tCNfVW8z2Nss1+j6BaIV6rvgo0GhT/xeRJ2e03wuV miUw+ZU1mLsP8SC/+s45RpR0RZKGfis36sQwz/LOcjCFFiMuNyb4Am/q+gMfb3NzQCH8mk 27nJB9QIh2NO5RT1cel/u2o+1EKPAFwe+Fc49iDjD5sMMa2ri4kcQOaPq105pg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=c6487446d7e99537551d2e51a2f6c6569fcb89fc commit c6487446d7e99537551d2e51a2f6c6569fcb89fc Author: Dmitry Chagin AuthorDate: 2022-04-11 20:30:16 +0000 Commit: Dmitry Chagin CommitDate: 2022-04-11 20:30:16 +0000 getdirentries: return ENOENT for unlinked but still open directory. To be more compatible to IEEE Std 1003.1-2008 (“POSIX.1”). Reviewed by: mjg, Pau Amma (doc) Differential revision: https://reviews.freebsd.org/D34680 MFC after: 2 weeks --- lib/libc/sys/getdirentries.2 | 2 ++ sys/kern/vfs_subr.c | 1 + sys/kern/vfs_syscalls.c | 4 ++++ sys/sys/vnode.h | 2 +- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/libc/sys/getdirentries.2 b/lib/libc/sys/getdirentries.2 index 4185fb84f0f9..76fe18bf6edb 100644 --- a/lib/libc/sys/getdirentries.2 +++ b/lib/libc/sys/getdirentries.2 @@ -193,6 +193,8 @@ An error occurred while reading from or writing to the file system. .It Bq Er EINTEGRITY Corrupted data was detected while reading from the file system. +.It Bq Er ENOENT +Directory unlinked but still open. .El .Sh SEE ALSO .Xr lseek 2 , diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index bbb429085a24..a6344e139502 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -5980,6 +5980,7 @@ vop_rmdir_post(void *ap, int rc) vn_seqc_write_end(dvp); vn_seqc_write_end(vp); if (!rc) { + vp->v_vflag |= VV_UNLINKED; VFS_KNOTE_LOCKED(dvp, NOTE_WRITE | NOTE_LINK); VFS_KNOTE_LOCKED(vp, NOTE_DELETE); } diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 87bf0a9d866b..77a9b9c25290 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -4195,6 +4195,10 @@ unionread: error = EINVAL; goto fail; } + if (__predict_false((vp->v_vflag & VV_UNLINKED) != 0)) { + error = ENOENT; + goto fail; + } aiov.iov_base = buf; aiov.iov_len = count; auio.uio_iov = &aiov; diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 0ff7501837c7..ed292835c12f 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -270,7 +270,7 @@ struct xvnode { #define VV_COPYONWRITE 0x0040 /* vnode is doing copy-on-write */ #define VV_SYSTEM 0x0080 /* vnode being used by kernel */ #define VV_PROCDEP 0x0100 /* vnode is process dependent */ -/* UNUSED 0x0200 */ +#define VV_UNLINKED 0x0200 /* unlinked but stil open directory */ #define VV_DELETED 0x0400 /* should be removed */ #define VV_MD 0x0800 /* vnode backs the md device */ #define VV_FORCEINSMQ 0x1000 /* force the insmntque to succeed */