From nobody Mon Apr 18 21:55:48 2022 X-Original-To: dev-commits-src-all@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 4952511DE780; Mon, 18 Apr 2022 21:55:49 +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 4Kj12s1254z3N8y; Mon, 18 Apr 2022 21:55:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650318949; 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=mG/iK5AWidmiDRdsNtKz6b9zz4qvPBBEjiKryN4ZgRk=; b=Yvxfj3bQAWn6G8tsqYFjL7FZFOBDexT/bwQZM4TH3T0LzCpzFUuOAGknqEeEu3uaupVNgK LysgDlwxeVQmXAkDkgwREDynkxWq5vPwGSJSnUu+kn4zUP9r+iYyo6svfq4ye20mb9aVcx LXMXwzA1/eyaboYd7U26CNw6ABDWybje+BNQ1mb+SP397IUOPbO69VR1v7h3zHCfqVMhbd lkdcRy9IJEqOiHOv1DRgHBq/RemGG/N9OC1ZN5jNXCGBGH1C/UIhFYDe0gmtcgUoC7cBJz EtxoLR8Xgh9yArMKWwZ0qDFD6128AdgeMJ/pemIX9fSVEUEWLx8QoJmgwdwvRQ== 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 F0CCD1AF0D; Mon, 18 Apr 2022 21:55:48 +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 23ILtmsa018441; Mon, 18 Apr 2022 21:55:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23ILtmYG018440; Mon, 18 Apr 2022 21:55:48 GMT (envelope-from git) Date: Mon, 18 Apr 2022 21:55:48 GMT Message-Id: <202204182155.23ILtmYG018440@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: b13ac6784202 - main - path_test: Verify that operations on unlinked files work List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b13ac678420292f5994b0b6e0f27995b9399268b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650318949; 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=mG/iK5AWidmiDRdsNtKz6b9zz4qvPBBEjiKryN4ZgRk=; b=fFSl4iOu3/8F/7zbRi3yaHFb0vjM/0pxLHQ20+JHfx1wXBWZ+WKK5YLxTEbs/IUiHx938Q oGpZYiOd876FC9pGNWUQghuAfhSVwPluyF9FXSDP8lHgi4W1cbRYcx3pRN4QPycSXoawNQ QayR+iQZufd+SomOnrDCpo5JHrO/6NRLhax4364XByub8pRP9oZVQaM9PYSS59u9yIAmTB kDsN4o26zsUsGZIkhI5Tu8knt8UsdkGhrvtCKiFMw/M7SQWR5ssJLYIBKgEyNe14dzKY3E nNarl454h7Xg/s7XrXJP25IA7GeyFJsidf/SQOHph8NQGUAzk1nCyroIic2aCQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1650318949; a=rsa-sha256; cv=none; b=buHUgng5egH9czVgrjoZAg1tnGqyRhgaNvMUqShZvmdEJ49i/7Kl+vhGgdrdWD3MThWtO9 0Cai94hvTvu2FVzpVlCAfEjGrkVU7kl0t8KEqOjId8SiJKMsd9Z3B8utDop5+QiXp1L8gs 2wwp1pZKIFBg4z1Mq65GWRReJMjnSQcl1o5Fzh0TjvYUZrg96rrCprZOn9eIHvLqpl7pzV QWqRF/OQ7BtmT8itD5O9satjAtgD0fauTefz0xu3FluWviQyqdmoIceuQsRQM/MrJoAeU/ ENfYzP4lWnMzIjC/Mfv3Jm+bagKNa/14TKeDy6gKCXXPgAysoSyGnGY12S7zrA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b13ac678420292f5994b0b6e0f27995b9399268b commit b13ac678420292f5994b0b6e0f27995b9399268b Author: Mark Johnston AuthorDate: 2022-04-18 21:46:04 +0000 Commit: Mark Johnston CommitDate: 2022-04-18 21:55:24 +0000 path_test: Verify that operations on unlinked files work MFC after: 1 week Sponsored by: The FreeBSD Foundation --- tests/sys/file/path_test.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/sys/file/path_test.c b/tests/sys/file/path_test.c index e8c8410a0bdf..a212325c7db6 100644 --- a/tests/sys/file/path_test.c +++ b/tests/sys/file/path_test.c @@ -900,6 +900,38 @@ ATF_TC_BODY(path_unix, tc) CHECKED_CLOSE(pathfd); } +/* + * Check that we can perform operations using an O_PATH fd for an unlinked file. + */ +ATF_TC_WITHOUT_HEAD(path_unlinked); +ATF_TC_BODY(path_unlinked, tc) +{ + char path[PATH_MAX]; + struct stat sb; + int pathfd; + + mktfile(path, "path_rights.XXXXXX"); + + pathfd = open(path, O_PATH); + ATF_REQUIRE_MSG(pathfd >= 0, FMT_ERR("open")); + + ATF_REQUIRE_MSG(fstatat(pathfd, "", &sb, AT_EMPTY_PATH) == 0, + FMT_ERR("fstatat")); + ATF_REQUIRE(sb.st_nlink == 1); + ATF_REQUIRE_MSG(fstat(pathfd, &sb) == 0, FMT_ERR("fstat")); + ATF_REQUIRE(sb.st_nlink == 1); + + ATF_REQUIRE_MSG(unlink(path) == 0, FMT_ERR("unlink")); + + ATF_REQUIRE_MSG(fstatat(pathfd, "", &sb, AT_EMPTY_PATH) == 0, + FMT_ERR("fstatat")); + ATF_REQUIRE(sb.st_nlink == 0); + ATF_REQUIRE_MSG(fstat(pathfd, &sb) == 0, FMT_ERR("fstat")); + ATF_REQUIRE(sb.st_nlink == 0); + + CHECKED_CLOSE(pathfd); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, path_access); @@ -922,6 +954,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, path_pipe_fstatat); ATF_TP_ADD_TC(tp, path_rights); ATF_TP_ADD_TC(tp, path_unix); + ATF_TP_ADD_TC(tp, path_unlinked); return (atf_no_error()); }